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