|
6 | 6 | * Released under the MIT license
|
7 | 7 | * https://js.foundation/
|
8 | 8 | *
|
9 |
| - * Date: 2018-10-20 |
| 9 | + * Date: 2018-11-04 |
10 | 10 | */
|
11 | 11 | (function( window ) {
|
12 | 12 |
|
@@ -132,6 +132,8 @@ var i,
|
132 | 132 |
|
133 | 133 | rsibling = /[+~]/,
|
134 | 134 |
|
| 135 | + rcomplex = new RegExp(whitespace + "|>"), |
| 136 | + |
135 | 137 | // CSS escapes
|
136 | 138 | // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
|
137 | 139 | runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
|
@@ -304,20 +306,26 @@ function Sizzle( selector, context, results, seed ) {
|
304 | 306 | // Exclude object elements
|
305 | 307 | } else if ( context.nodeName.toLowerCase() !== "object" ) {
|
306 | 308 |
|
307 |
| - // Capture the context ID, setting it first if necessary |
308 |
| - if ( (nid = context.getAttribute( "id" )) ) { |
309 |
| - nid = nid.replace( rcssescape, fcssescape ); |
| 309 | + // The workaround is only necessary if the selector |
| 310 | + // contains child or descendant combinators. |
| 311 | + if ( !rcomplex.test( selector ) ) { |
| 312 | + newSelector = selector; |
310 | 313 | } else {
|
311 |
| - context.setAttribute( "id", (nid = expando) ); |
312 |
| - } |
| 314 | + // Capture the context ID, setting it first if necessary |
| 315 | + if ( (nid = context.getAttribute( "id" )) ) { |
| 316 | + nid = nid.replace( rcssescape, fcssescape ); |
| 317 | + } else { |
| 318 | + context.setAttribute( "id", (nid = expando) ); |
| 319 | + } |
313 | 320 |
|
314 |
| - // Prefix every selector in the list |
315 |
| - groups = tokenize( selector ); |
316 |
| - i = groups.length; |
317 |
| - while ( i-- ) { |
318 |
| - groups[i] = "#" + nid + " " + toSelector( groups[i] ); |
| 321 | + // Prefix every selector in the list |
| 322 | + groups = tokenize( selector ); |
| 323 | + i = groups.length; |
| 324 | + while ( i-- ) { |
| 325 | + groups[i] = "#" + nid + " " + toSelector( groups[i] ); |
| 326 | + } |
| 327 | + newSelector = groups.join( "," ); |
319 | 328 | }
|
320 |
| - newSelector = groups.join( "," ); |
321 | 329 |
|
322 | 330 | // Expand context for sibling selectors
|
323 | 331 | newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
|
|
0 commit comments