]>
Commit | Line | Data |
---|---|---|
f0cfe83e AD |
1 | define("dojo/selector/_loader", ["../has", "require"], |
2 | function(has, require){ | |
3 | ||
4 | "use strict"; | |
5 | var testDiv = document.createElement("div"); | |
6 | has.add("dom-qsa2.1", !!testDiv.querySelectorAll); | |
7 | has.add("dom-qsa3", function(){ | |
8 | // test to see if we have a reasonable native selector engine available | |
9 | try{ | |
10 | testDiv.innerHTML = "<p class='TEST'></p>"; // test kind of from sizzle | |
11 | // Safari can't handle uppercase or unicode characters when | |
12 | // in quirks mode, IE8 can't handle pseudos like :empty | |
13 | return testDiv.querySelectorAll(".TEST:empty").length == 1; | |
14 | }catch(e){} | |
15 | }); | |
16 | var fullEngine; | |
17 | var acme = "./acme", lite = "./lite"; | |
18 | return { | |
19 | // summary: | |
20 | // This module handles loading the appropriate selector engine for the given browser | |
21 | ||
22 | load: function(id, parentRequire, loaded, config){ | |
23 | var req = require; | |
24 | // here we implement the default logic for choosing a selector engine | |
25 | id = id == "default" ? has("config-selectorEngine") || "css3" : id; | |
26 | id = id == "css2" || id == "lite" ? lite : | |
27 | id == "css2.1" ? has("dom-qsa2.1") ? lite : acme : | |
28 | id == "css3" ? has("dom-qsa3") ? lite : acme : | |
29 | id == "acme" ? acme : (req = parentRequire) && id; | |
30 | if(id.charAt(id.length-1) == '?'){ | |
31 | id = id.substring(0,id.length - 1); | |
32 | var optionalLoad = true; | |
33 | } | |
34 | // the query engine is optional, only load it if a native one is not available or existing one has not been loaded | |
35 | if(optionalLoad && (has("dom-compliant-qsa") || fullEngine)){ | |
36 | return loaded(fullEngine); | |
37 | } | |
38 | // load the referenced selector engine | |
39 | req([id], function(engine){ | |
40 | if(id != "./lite"){ | |
41 | fullEngine = engine; | |
42 | } | |
43 | loaded(engine); | |
44 | }); | |
45 | } | |
46 | }; | |
47 | }); |