From a993d5b5ca1ec8dd9b4662d8644aa669902a75bb Mon Sep 17 00:00:00 2001 From: James Rowe Date: Fri, 13 May 2016 08:40:46 -0700 Subject: [PATCH] don't fail when requirejs parses the file at build time (cherry picked from commit 3542d23498dcbb393a8c0c0a7b634e17a77150ff) --- selector/_loader.js | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/selector/_loader.js b/selector/_loader.js index 16b5b1f9bd..db0839d6a1 100644 --- a/selector/_loader.js +++ b/selector/_loader.js @@ -2,17 +2,20 @@ define(["../has", "require"], function(has, require){ "use strict"; -var testDiv = document.createElement("div"); -has.add("dom-qsa2.1", !!testDiv.querySelectorAll); -has.add("dom-qsa3", function(){ - // test to see if we have a reasonable native selector engine available - try{ - testDiv.innerHTML = "

"; // test kind of from sizzle - // Safari can't handle uppercase or unicode characters when - // in quirks mode, IE8 can't handle pseudos like :empty - return testDiv.querySelectorAll(".TEST:empty").length == 1; - }catch(e){} - }); +if (typeof document !== "undefined") { + var testDiv = document.createElement("div"); + has.add("dom-qsa2.1", !!testDiv.querySelectorAll); + has.add("dom-qsa3", function(){ + // test to see if we have a reasonable native selector engine available + try{ + testDiv.innerHTML = "

"; // test kind of from sizzle + // Safari can't handle uppercase or unicode characters when + // in quirks mode, IE8 can't handle pseudos like :empty + return testDiv.querySelectorAll(".TEST:empty").length == 1; + }catch(e){} + }); +} + var fullEngine; var acme = "./acme", lite = "./lite"; return { @@ -20,6 +23,15 @@ return { // This module handles loading the appropriate selector engine for the given browser load: function(id, parentRequire, loaded, config){ + if (config.isBuild) { + //Indicate that the optimizer should not wait + //for this resource any more and complete optimization. + //This resource will be resolved dynamically during + //run time in the web browser. + loaded(); + return; + } + var req = require; // here we implement the default logic for choosing a selector engine id = id == "default" ? has("config-selectorEngine") || "css3" : id;