diff options
author | Ben Alman <cowboy@rj3.net> | 2010-01-23 12:13:46 -0500 |
---|---|---|
committer | jeresig <jeresig@gmail.com> | 2010-01-23 12:13:46 -0500 |
commit | 09ef5b7598bcdd9e6c254b24b55a54e6bfb2b4ca (patch) | |
tree | 7206073b7c8b36a8444db2284b18530bfc1ca787 | |
parent | 01f72026ec939e87da85a7afc1a5262872ea3ce5 (diff) | |
download | jquery-09ef5b7598bcdd9e6c254b24b55a54e6bfb2b4ca.tar.gz jquery-09ef5b7598bcdd9e6c254b24b55a54e6bfb2b4ca.zip |
Simplification of uaMatch, based upon the patch by Ben Alman.
-rw-r--r-- | src/core.js | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/src/core.js b/src/core.js index 5b8388ead..4102e5c8c 100644 --- a/src/core.js +++ b/src/core.js @@ -653,26 +653,15 @@ jQuery.extend({ // Use of jQuery.browser is frowned upon. // More details: http://docs.jquery.com/Utilities/jQuery.browser uaMatch: function( ua ) { - var ret = { browser: "" }; - ua = ua.toLowerCase(); - if ( /webkit/.test( ua ) ) { - ret = { browser: "webkit", version: /webkit[\/ ]([\w.]+)/ }; - - } else if ( /opera/.test( ua ) ) { - ret = { browser: "opera", version: /version/.test( ua ) ? /version[\/ ]([\w.]+)/ : /opera[\/ ]([\w.]+)/ }; - - } else if ( /msie/.test( ua ) ) { - ret = { browser: "msie", version: /msie ([\w.]+)/ }; + var match = /(webkit)[ \/]([\w.]+)/.exec( ua ) || + /(opera)(?:.*version)?[ \/]([\w.]+)/.exec( ua ) || + /(msie) ([\w.]+)/.exec( ua ) || + !/compatible/.test( ua ) && /(mozilla)(?:.*? rv:([\w.]+))?/.exec( ua ) || + []; - } else if ( /mozilla/.test( ua ) && !/compatible/.test( ua ) ) { - ret = { browser: "mozilla", version: /rv:([\w.]+)/ }; - } - - ret.version = (ret.version && ret.version.exec( ua ) || [0, "0"])[1]; - - return ret; + return { browser: match[1] || "", version: match[2] || "0" }; }, browser: {} |