Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions src/sizzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ var i,

rsibling = /[+~]/,

rcomplex = new RegExp(whitespace + "|>"),

// CSS escapes
// http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
Expand Down Expand Up @@ -304,20 +306,26 @@ function Sizzle( selector, context, results, seed ) {
// Exclude object elements
} else if ( context.nodeName.toLowerCase() !== "object" ) {

// Capture the context ID, setting it first if necessary
if ( (nid = context.getAttribute( "id" )) ) {
nid = nid.replace( rcssescape, fcssescape );
// The workaround is only necessary if the selector
// contains child or descendant combinators.
if ( !rcomplex.test( selector ) ) {
newSelector = selector;
} else {
context.setAttribute( "id", (nid = expando) );
}
// Capture the context ID, setting it first if necessary
if ( (nid = context.getAttribute( "id" )) ) {
nid = nid.replace( rcssescape, fcssescape );
} else {
context.setAttribute( "id", (nid = expando) );
}

// Prefix every selector in the list
groups = tokenize( selector );
i = groups.length;
while ( i-- ) {
groups[i] = "#" + nid + " " + toSelector( groups[i] );
// Prefix every selector in the list
groups = tokenize( selector );
i = groups.length;
while ( i-- ) {
groups[i] = "#" + nid + " " + toSelector( groups[i] );
}
newSelector = groups.join( "," );
}
newSelector = groups.join( "," );

// Expand context for sibling selectors
newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
Expand Down