1
0
mirror of https://github.com/lancedikson/bowser synced 2024-10-27 20:34:22 +00:00

Fixes two compatibility issues that makes bowser play nicer with others

When the 'define' function exists, bowser tried to register itself
against it. The problem is that it does not supply a name for the
definitation, causing it to be lost forever.

The second problem has to do with semi-colons. When the source file
is minified with uglify it breaks horibly. I've added ending semi-
colons where to ending control statements, which allows it to be
compatible with the majority of other compressors.
This commit is contained in:
Ferdi Schmidt 2013-09-03 15:33:33 +02:00
parent 20826d1ea5
commit 7f4376f262
3 changed files with 51 additions and 51 deletions

View File

@ -4,10 +4,10 @@
* MIT License | (c) Dustin Diaz 2013 * MIT License | (c) Dustin Diaz 2013
*/ */
!function (name, definition) { ;!function (name, definition) {
if (typeof define == 'function') define(definition) if (typeof define == 'function') define(name, [], definition);
else if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition() else if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition();
else this[name] = definition() else this[name] = definition();
}('bowser', function () { }('bowser', function () {
/** /**
* navigator.userAgent => * navigator.userAgent =>
@ -40,33 +40,33 @@
, seamonkey = /seamonkey\//i.test(ua) , seamonkey = /seamonkey\//i.test(ua)
, webkitVersion = /version\/(\d+(\.\d+)?)/i , webkitVersion = /version\/(\d+(\.\d+)?)/i
, firefoxVersion = /firefox\/(\d+(\.\d+)?)/i , firefoxVersion = /firefox\/(\d+(\.\d+)?)/i
, o , o;
function detect() { function detect() {
if (ie) return { if (ie) return {
msie: t msie: t
, version: ua.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2] , version: ua.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]
} };
if (opera) return { if (opera) return {
opera: t opera: t
, version: ua.match(webkitVersion) ? ua.match(webkitVersion)[1] : ua.match(/opr\/(\d+(\.\d+)?)/i) , version: ua.match(webkitVersion) ? ua.match(webkitVersion)[1] : ua.match(/opr\/(\d+(\.\d+)?)/i)
} };
if (chrome) return { if (chrome) return {
webkit: t webkit: t
, chrome: t , chrome: t
, version: ua.match(/chrome\/(\d+(\.\d+)?)/i)[1] , version: ua.match(/chrome\/(\d+(\.\d+)?)/i)[1]
} };
if (phantom) return { if (phantom) return {
webkit: t webkit: t
, phantom: t , phantom: t
, version: ua.match(/phantomjs\/(\d+(\.\d+)+)/i)[1] , version: ua.match(/phantomjs\/(\d+(\.\d+)+)/i)[1]
} };
if (touchpad) return { if (touchpad) return {
webkit: t webkit: t
, touchpad: t , touchpad: t
, version : ua.match(/touchpad\/(\d+(\.\d+)?)/i)[1] , version : ua.match(/touchpad\/(\d+(\.\d+)?)/i)[1]
} };
if (iphone || ipad) { if (iphone || ipad) {
o = { o = {
webkit: t webkit: t
@ -74,41 +74,41 @@
, ios: t , ios: t
, iphone: iphone , iphone: iphone
, ipad: ipad , ipad: ipad
} };
// WTF: version is not part of user agent in web apps // WTF: version is not part of user agent in web apps
if (webkitVersion.test(ua)) { if (webkitVersion.test(ua)) {
o.version = ua.match(webkitVersion)[1] o.version = ua.match(webkitVersion)[1];
} }
return o return o;
} }
if (android) return { if (android) return {
webkit: t webkit: t
, android: t , android: t
, mobile: t , mobile: t
, version: (ua.match(webkitVersion) || ua.match(firefoxVersion))[1] , version: (ua.match(webkitVersion) || ua.match(firefoxVersion))[1]
} };
if (safari) return { if (safari) return {
webkit: t webkit: t
, safari: t , safari: t
, version: ua.match(webkitVersion)[1] , version: ua.match(webkitVersion)[1]
} };
if (gecko) { if (gecko) {
o = { o = {
gecko: t gecko: t
, mozilla: t , mozilla: t
, version: ua.match(firefoxVersion)[1] , version: ua.match(firefoxVersion)[1]
} };
if (firefox) o.firefox = t if (firefox) o.firefox = t;
return o return o;
} }
if (seamonkey) return { if (seamonkey) return {
seamonkey: t seamonkey: t
, version: ua.match(/seamonkey\/(\d+(\.\d+)?)/i)[1] , version: ua.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]
} };
return {} return {};
} }
var bowser = detect() var bowser = detect();
// Graded Browser Support // Graded Browser Support
// http://developer.yahoo.com/yui/articles/gbs // http://developer.yahoo.com/yui/articles/gbs
@ -125,8 +125,8 @@
(bowser.firefox && bowser.version < 4.0) || (bowser.firefox && bowser.version < 4.0) ||
(bowser.safari && bowser.version < 5) || (bowser.safari && bowser.version < 5) ||
(bowser.opera && bowser.version < 10.0)) { (bowser.opera && bowser.version < 10.0)) {
bowser.c = t bowser.c = t;
} else bowser.x = t } else bowser.x = t;
return bowser return bowser;
}) });

2
bowser.min.js vendored
View File

@ -3,4 +3,4 @@
* https://github.com/ded/bowser * https://github.com/ded/bowser
* MIT License | (c) Dustin Diaz 2013 * MIT License | (c) Dustin Diaz 2013
*/ */
!function(e,t){typeof define=="function"?define(t):typeof module!="undefined"&&module.exports?module.exports.browser=t():this[e]=t()}("bowser",function(){function g(){return n?{msie:t,version:e.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]}:l?{opera:t,version:e.match(d)?e.match(d)[1]:e.match(/opr\/(\d+(\.\d+)?)/i)}:r?{webkit:t,chrome:t,version:e.match(/chrome\/(\d+(\.\d+)?)/i)[1]}:i?{webkit:t,phantom:t,version:e.match(/phantomjs\/(\d+(\.\d+)+)/i)[1]}:a?{webkit:t,touchpad:t,version:e.match(/touchpad\/(\d+(\.\d+)?)/i)[1]}:o||u?(m={webkit:t,mobile:t,ios:t,iphone:o,ipad:u},d.test(e)&&(m.version=e.match(d)[1]),m):f?{webkit:t,android:t,mobile:t,version:(e.match(d)||e.match(v))[1]}:s?{webkit:t,safari:t,version:e.match(d)[1]}:h?(m={gecko:t,mozilla:t,version:e.match(v)[1]},c&&(m.firefox=t),m):p?{seamonkey:t,version:e.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]}:{}}var e=navigator.userAgent,t=!0,n=/(msie|trident)/i.test(e),r=/chrome/i.test(e),i=/phantom/i.test(e),s=/safari/i.test(e)&&!r&&!i,o=/iphone/i.test(e),u=/ipad/i.test(e),a=/touchpad/i.test(e),f=/android/i.test(e),l=/opera/i.test(e)||/opr/i.test(e),c=/firefox/i.test(e),h=/gecko\//i.test(e),p=/seamonkey\//i.test(e),d=/version\/(\d+(\.\d+)?)/i,v=/firefox\/(\d+(\.\d+)?)/i,m,y=g();return y.msie&&y.version>=8||y.chrome&&y.version>=10||y.firefox&&y.version>=4||y.safari&&y.version>=5||y.opera&&y.version>=10?y.a=t:y.msie&&y.version<8||y.chrome&&y.version<10||y.firefox&&y.version<4||y.safari&&y.version<5||y.opera&&y.version<10?y.c=t:y.x=t,y}) !function(e,t){typeof define=="function"?define(e,[],t):typeof module!="undefined"&&module.exports?module.exports.browser=t():this[e]=t()}("bowser",function(){function g(){return n?{msie:t,version:e.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]}:l?{opera:t,version:e.match(d)?e.match(d)[1]:e.match(/opr\/(\d+(\.\d+)?)/i)}:r?{webkit:t,chrome:t,version:e.match(/chrome\/(\d+(\.\d+)?)/i)[1]}:i?{webkit:t,phantom:t,version:e.match(/phantomjs\/(\d+(\.\d+)+)/i)[1]}:a?{webkit:t,touchpad:t,version:e.match(/touchpad\/(\d+(\.\d+)?)/i)[1]}:o||u?(m={webkit:t,mobile:t,ios:t,iphone:o,ipad:u},d.test(e)&&(m.version=e.match(d)[1]),m):f?{webkit:t,android:t,mobile:t,version:(e.match(d)||e.match(v))[1]}:s?{webkit:t,safari:t,version:e.match(d)[1]}:h?(m={gecko:t,mozilla:t,version:e.match(v)[1]},c&&(m.firefox=t),m):p?{seamonkey:t,version:e.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]}:{}}var e=navigator.userAgent,t=!0,n=/(msie|trident)/i.test(e),r=/chrome/i.test(e),i=/phantom/i.test(e),s=/safari/i.test(e)&&!r&&!i,o=/iphone/i.test(e),u=/ipad/i.test(e),a=/touchpad/i.test(e),f=/android/i.test(e),l=/opera/i.test(e)||/opr/i.test(e),c=/firefox/i.test(e),h=/gecko\//i.test(e),p=/seamonkey\//i.test(e),d=/version\/(\d+(\.\d+)?)/i,v=/firefox\/(\d+(\.\d+)?)/i,m,y=g();return y.msie&&y.version>=8||y.chrome&&y.version>=10||y.firefox&&y.version>=4||y.safari&&y.version>=5||y.opera&&y.version>=10?y.a=t:y.msie&&y.version<8||y.chrome&&y.version<10||y.firefox&&y.version<4||y.safari&&y.version<5||y.opera&&y.version<10?y.c=t:y.x=t,y})

View File

@ -1,7 +1,7 @@
!function (name, definition) { ;!function (name, definition) {
if (typeof define == 'function') define(definition) if (typeof define == 'function') define(name, [], definition);
else if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition() else if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition();
else this[name] = definition() else this[name] = definition();
}('bowser', function () { }('bowser', function () {
/** /**
* navigator.userAgent => * navigator.userAgent =>
@ -34,33 +34,33 @@
, seamonkey = /seamonkey\//i.test(ua) , seamonkey = /seamonkey\//i.test(ua)
, webkitVersion = /version\/(\d+(\.\d+)?)/i , webkitVersion = /version\/(\d+(\.\d+)?)/i
, firefoxVersion = /firefox\/(\d+(\.\d+)?)/i , firefoxVersion = /firefox\/(\d+(\.\d+)?)/i
, o , o;
function detect() { function detect() {
if (ie) return { if (ie) return {
msie: t msie: t
, version: ua.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2] , version: ua.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]
} };
if (opera) return { if (opera) return {
opera: t opera: t
, version: ua.match(webkitVersion) ? ua.match(webkitVersion)[1] : ua.match(/opr\/(\d+(\.\d+)?)/i) , version: ua.match(webkitVersion) ? ua.match(webkitVersion)[1] : ua.match(/opr\/(\d+(\.\d+)?)/i)
} };
if (chrome) return { if (chrome) return {
webkit: t webkit: t
, chrome: t , chrome: t
, version: ua.match(/chrome\/(\d+(\.\d+)?)/i)[1] , version: ua.match(/chrome\/(\d+(\.\d+)?)/i)[1]
} };
if (phantom) return { if (phantom) return {
webkit: t webkit: t
, phantom: t , phantom: t
, version: ua.match(/phantomjs\/(\d+(\.\d+)+)/i)[1] , version: ua.match(/phantomjs\/(\d+(\.\d+)+)/i)[1]
} };
if (touchpad) return { if (touchpad) return {
webkit: t webkit: t
, touchpad: t , touchpad: t
, version : ua.match(/touchpad\/(\d+(\.\d+)?)/i)[1] , version : ua.match(/touchpad\/(\d+(\.\d+)?)/i)[1]
} };
if (iphone || ipad) { if (iphone || ipad) {
o = { o = {
webkit: t webkit: t
@ -68,41 +68,41 @@
, ios: t , ios: t
, iphone: iphone , iphone: iphone
, ipad: ipad , ipad: ipad
} };
// WTF: version is not part of user agent in web apps // WTF: version is not part of user agent in web apps
if (webkitVersion.test(ua)) { if (webkitVersion.test(ua)) {
o.version = ua.match(webkitVersion)[1] o.version = ua.match(webkitVersion)[1];
} }
return o return o;
} }
if (android) return { if (android) return {
webkit: t webkit: t
, android: t , android: t
, mobile: t , mobile: t
, version: (ua.match(webkitVersion) || ua.match(firefoxVersion))[1] , version: (ua.match(webkitVersion) || ua.match(firefoxVersion))[1]
} };
if (safari) return { if (safari) return {
webkit: t webkit: t
, safari: t , safari: t
, version: ua.match(webkitVersion)[1] , version: ua.match(webkitVersion)[1]
} };
if (gecko) { if (gecko) {
o = { o = {
gecko: t gecko: t
, mozilla: t , mozilla: t
, version: ua.match(firefoxVersion)[1] , version: ua.match(firefoxVersion)[1]
} };
if (firefox) o.firefox = t if (firefox) o.firefox = t;
return o return o;
} }
if (seamonkey) return { if (seamonkey) return {
seamonkey: t seamonkey: t
, version: ua.match(/seamonkey\/(\d+(\.\d+)?)/i)[1] , version: ua.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]
} };
return {} return {};
} }
var bowser = detect() var bowser = detect();
// Graded Browser Support // Graded Browser Support
// http://developer.yahoo.com/yui/articles/gbs // http://developer.yahoo.com/yui/articles/gbs
@ -119,8 +119,8 @@
(bowser.firefox && bowser.version < 4.0) || (bowser.firefox && bowser.version < 4.0) ||
(bowser.safari && bowser.version < 5) || (bowser.safari && bowser.version < 5) ||
(bowser.opera && bowser.version < 10.0)) { (bowser.opera && bowser.version < 10.0)) {
bowser.c = t bowser.c = t;
} else bowser.x = t } else bowser.x = t;
return bowser return bowser;
}) });