This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO: should probably convert result to plain array (since different engines return different things -- arrays, nodelists, objects, etc.) | |
var query = (function() { | |
var engine, engines = 'NW.Dom.select,base2.dom.querySelectorAll,Sizzle,$$,$,YAHOO.util.Selector.query,dojo.query,Ext.DomQuery.select'.split(','); | |
while ((engine = engines.shift())) { | |
if (Function('try{return ' + engine + '}catch(e){}')()) { | |
return Function('cssExpr, ctx', 'ctx || (ctx = document);return ' + engine + '(' + | |
(engine.indexOf('base2') > -1 ? 'ctx, cssExpr' : 'cssExpr, ctx') + ')'); | |
} | |
} | |
return 'querySelectorAll' in document ? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// first alert(1), then alert(2) | |
var foo = 1; | |
alert(1); | |
var bar = (function(){ alert(2); })(); | |
// first alert(2), then alert(1) | |
var foo=1,bar=(function(){alert(2);})();alert(1); |