`Prototype.Browser.Opera` now uses stronger inference and is determined by [[Class]] of `window.opera` being - "Opera". (kangax)

This commit is contained in:
Andrew Dupont 2009-05-15 21:50:32 -05:00
parent cc0a75fe19
commit c44a071a3f
3 changed files with 16 additions and 10 deletions

View File

@ -1,3 +1,5 @@
* `Prototype.Browser.Opera` now uses stronger inference and is determined by [[Class]] of `window.opera` being - "Opera". (kangax)
* Fix error in event.js which prevented attaching more than one responder for an event name/element combination. [#651 state:resolved] (Rob Lineweaver)
* Do not sniff when testing for IE's proprietary mouseenter/mouseleave events support. Use more robust inference instead. (kangax)

22
src/prototype.js vendored
View File

@ -9,15 +9,19 @@
var Prototype = {
Version: '<%= PROTOTYPE_VERSION %>',
Browser: {
IE: !!(window.attachEvent &&
navigator.userAgent.indexOf('Opera') === -1),
Opera: navigator.userAgent.indexOf('Opera') > -1,
WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
Gecko: navigator.userAgent.indexOf('Gecko') > -1 &&
navigator.userAgent.indexOf('KHTML') === -1,
MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
},
Browser: (function(){
var ua = navigator.userAgent;
// Opera (at least) 8.x+ has "Opera" as a [[Class]] of `window.opera`
// This is a safer inference than plain boolean type conversion of `window.opera`
var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]';
return {
IE: !!window.attachEvent && !isOpera,
Opera: isOpera,
WebKit: ua.indexOf('AppleWebKit/') > -1,
Gecko: ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') === -1,
MobileSafari: /Apple.*Mobile.*Safari/.test(ua)
}
})(),
BrowserFeatures: {
XPath: !!document.evaluate,

View File

@ -25,7 +25,7 @@ new Test.Unit.Runner({
this.assert(Prototype.Browser.WebKit);
}
if(!!window.opera) {
if(Object.prototype.toString.call(window.opera) === '[object Opera]') {
this.info('Running on Opera');
this.assert(Prototype.Browser.Opera);
}