View Full Version : Ext.isGecko35
dolittle
17 Jun 2009, 10:43 AM
FF3.5 RC1 released today so I think we need:
isGecko3 = isGecko && check(/rv:1\.9\.0/),
isGecko35 = isGecko && check(/rv:1\.9\.1/),
tryanDLS
17 Jun 2009, 11:21 AM
Is there a valid reason for needing this? Are there any known functional differences between 3 and 3.5 that would warrant behavior changes?
dolittle
17 Jun 2009, 11:31 AM
Is there a valid reason for needing this? Are there any known functional differences between 3 and 3.5 that would warrant behavior changes?
I use it to know if I can use cross-domain xmlhttprequest(XDR) or have to use scriptTagProxy.
FF3.5 and Safari4 supports XDR. not sure about chrome/opera. IE8 defines a new object.
FF3.5 also supports native JSON, web worker threads and is geo location aware.
So yes I do believe it will be helpful and it is only one line of code.
mystix
17 Jun 2009, 6:58 PM
I use it to know if I can use cross-domain xmlhttprequest(XDR) or have to use scriptTagProxy.
FF3.5 and Safari4 supports XDR. not sure about chrome/opera. IE8 defines a new object.
FF3.5 also supports native JSON, web worker threads and is geo location aware.
So yes I do believe it will be helpful and it is only one line of code.
it doesn't make sense imho to add a new browser detection flag for minor browser revisions.
if you need to use new functionaility, don't sniff for browsers - use object detection.
this will prevent the need to tack on an endless stream of browser detection flags for each minor revision which introduces some new feature.
evant
17 Jun 2009, 7:00 PM
Agreed, so far the convention we've used is to detect major versions. Unless there's some significant reason for doing so, we probably won't add this.
mystix
17 Jun 2009, 7:03 PM
Agreed, so far the convention we've used is to detect major versions. Unless there's some significant reason for doing so, we probably won't add this.
i've got a pending feature request to end the browser + version detection madness and will definitely alleviate dolittle's situation here. the FR's buried in another FR though -- i'll try to break it out into a new FR when i get home tonight as suggested by @mj.
joeri
18 Jun 2009, 1:25 AM
i've got a pending feature request to end the browser + version detection madness and will definitely alleviate dolittle's situation here. the FR's buried in another FR though -- i'll try to break it out into a new FR when i get home tonight as suggested by @mj.
I can understand not wanting to rely on this in the core ExtJS library, favoring feature detection instead, but why take this away from people who want to use it? The only thing you achieve is that they implement it themselves, badly, and the web is worse off because of it. So, what gain does it have for the ExtJS users to remove these properties?
As far as the difference between minor and major, that's completely arbitrary. The amount of new features in firefox 3.5 for web developers is just as big as in firefox 3.0 (vs 2.0). If 3.0 warranted a check because it introduced a lot of changes, why doesn't 3.5. What objective measure of change is used to determine what version gets a check?
mystix
18 Jun 2009, 2:00 AM
I can understand not wanting to rely on this in the core ExtJS library, favoring feature detection instead, but why take this away from people who want to use it? The only thing you achieve is that they implement it themselves, badly, and the web is worse off because of it. So, what gain does it have for the ExtJS users to remove these properties?
my FR isn't about removing version detection.
it's about making it manageable and sensible by not creating an endless string of flags
-- all this through just 2 flags -- browser flavour (e.g Ext.isSafari) and browser version (e.g. Ext.browserVersion)
here's the post (haven't had time to break it out into a separate FR yet -- read the rest of the thread for more info):
307730
i vote against adding yet another flag in light of my pending FR.
hendricd
18 Jun 2009, 6:04 PM
Here's a few recent detection goodies and type tests added to the latest ext-basex adapter:
Ext.applyIf(Ext,{
overload : overload( overload,
[
function(fn){ return overload(null, fn);},
function(obj, mname, fn){
return obj[mname] = overload(obj[mname],fn);}
]),
isArray : function(v){
return Object.prototype.toString.apply(v) === '[object Array]';
},
isObject:function(obj){
return (obj !== null) && typeof obj === 'object';
},
isDocument : function(obj){
return Object.prototype.toString.apply(obj) === '[object HTMLDocument]' || (obj && obj.nodeType === 9);
},
isElement : function(obj){
return obj && Ext.type(obj)=== 'element';
},
isEvent : function(obj){
return Object.prototype.toString.apply(obj) === '[object Event]' || (Ext.isObject(obj) && !Ext.type(o.constructor) && (window.event && o.clientX && o.clientX === window.event.clientX));
},
isFunction: function(obj){
return typeof obj === 'function';
},
isString : function(obj){
return Ext.type(obj)==='string';
},
isEventSupported : (function(){
var TAGNAMES = {
'select':'input','change':'input',
'submit':'form','reset':'form',
'error':'img','load':'img','abort':'img'
};
//Cached results
var cache = {};
//Get a tokenized string unique to the node and event type
var getKey = function(type, el){
return (el ?
(Ext.isElement(el) || Ext.isDocument(el) ?
el.nodeName.toLowerCase() :
el.id || Ext.type(el))
: 'div') + ':' + type;
};
return function (evName, testEl) {
var key = getKey(evName, testEl);
if(key in cache){
//Use a previously cached result if available
return cache[key];
}
var el, isSupported = window.Event ? String(evName).toUpperCase() in window.Event: false;
if(!isSupported){
var eventName = 'on' + evName;
el = testEl || document.createElement(TAGNAMES[eventName] || 'div');
isSupported = (eventName in el);
}
if (!isSupported && el) {
el.setAttribute && el.setAttribute(eventName, 'return;');
isSupported = Ext.isFunction(el[eventName]);
}
//save the cached result for future tests
cache[getKey(evName, el)] = isSupported;
el = null;
return isSupported;
};
})(),
capabilities : {
hasActiveX : !!window.ActiveXObject,
hasXDR : function(){
return (Ext.isIE && defined(window.XDomainRequest))
|| Ext.isSafari4
|| (Ext.isGecko && 'withCredentials' in new XMLHttpRequest()) ;
}(),
hasFlash : (function(){
//Check for ActiveX first because some versions of IE support navigator.plugins, just not the same as other browsers
if(window.ActiveXObject){
try{
//try to create a flash instance
new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
return true;
}catch(e){};
//If the try-catch fails, return false
return false;
}else if(navigator.plugins){
//Loop through all the plugins
for(var i=0, length = navigator.plugins.length; i < length; i++){
//test to see if any plugin names contain the word flash, if so it must support it - return true
if((/flash/gi).test(navigator.plugins[i].name)){
return true;
}
}
//return false if no plugins match
return false;
}
//Return false if ActiveX and nagivator.plugins are not supported
return false;
})(),
hasCookies : !!navigator.cookieEnabled && navigator.cookieEnabled,
hasCanvas : !!document.createElement("canvas").getContext,
hasSVG : !!(document.createElementNS && document.createElementNS('http://www.w3.org/2000/svg', 'svg').width),
hasXpath : !!document.evaluate,
hasBasex : true
}
mystix
18 Jun 2009, 6:13 PM
@hendricd, sweet =D>
noticed 1 thing though -- the typeof function always returns a string.
so there's no need to do a strict equality check like
typeof obj === 'object'
where this will suffice
typeof obj == 'object'
hendricd
18 Jun 2009, 6:21 PM
Creature of habit, I guess. ;)
mystix
18 Jun 2009, 6:27 PM
ooooh, just came across this on ajaxian:
http://robertnyman.com/javascript/
that might come in real handy.
hendricd
18 Jun 2009, 8:03 PM
ooooh, just came across this on ajaxian:
http://robertnyman.com/javascript/
that might come in real handy.
Just added all the string and array extras (for IE). ;)
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.