diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/selector.js | 4 | ||||
-rw-r--r-- | src/selector/rbuggyQSA.js | 16 | ||||
-rw-r--r-- | src/selector/var/whitespace.js | 2 |
3 files changed, 18 insertions, 4 deletions
diff --git a/src/selector.js b/src/selector.js index 019f25d62..66abe7935 100644 --- a/src/selector.js +++ b/src/selector.js @@ -5,6 +5,7 @@ import documentElement from "./var/documentElement.js"; import indexOf from "./var/indexOf.js"; import pop from "./var/pop.js"; import push from "./var/push.js"; +import whitespace from "./selector/var/whitespace.js"; import rbuggyQSA from "./selector/rbuggyQSA.js"; import support from "./selector/support.js"; @@ -41,9 +42,6 @@ var i, // Regular expressions - // https://www.w3.org/TR/css3-selectors/#whitespace - whitespace = "[\\x20\\t\\r\\n\\f]", - // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+", diff --git a/src/selector/rbuggyQSA.js b/src/selector/rbuggyQSA.js index f638fc429..2c853a0f1 100644 --- a/src/selector/rbuggyQSA.js +++ b/src/selector/rbuggyQSA.js @@ -1,8 +1,10 @@ import document from "../var/document.js"; import isIE from "../var/isIE.js"; +import whitespace from "./var/whitespace.js"; var rbuggyQSA = [], - testEl = document.createElement( "div" ); + testEl = document.createElement( "div" ), + input = document.createElement( "input" ); testEl.innerHTML = "<a href=''></a>"; @@ -19,6 +21,18 @@ if ( isIE ) { rbuggyQSA.push( ":enabled", ":disabled" ); } +// Support: IE 11+, Edge 15 - 18+ +// IE 11/Edge don't find elements on a `[name='']` query in some cases. +// Adding a temporary attribute to the document before the selection works +// around the issue. +// Interestingly, IE 10 & older don't seem to have the issue. +input.setAttribute( "name", "" ); +testEl.appendChild( input ); +if ( !testEl.querySelectorAll( "[name='']" ).length ) { + rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" + + whitespace + "*(?:''|\"\")" ); +} + rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) ); export default rbuggyQSA; diff --git a/src/selector/var/whitespace.js b/src/selector/var/whitespace.js new file mode 100644 index 000000000..dcac814c7 --- /dev/null +++ b/src/selector/var/whitespace.js @@ -0,0 +1,2 @@ +// https://www.w3.org/TR/css3-selectors/#whitespace +export default "[\\x20\\t\\r\\n\\f]"; |