Permalink
Browse files

parentNode logic in the call to Sizzle.find should apply when parts.l…

…ength >= 1. Fixes jQuery bug #9939. Closes #70.
  • Loading branch information...
1 parent 2b2f7ac commit 0f71c4062ce1724e9ecf3c6cac0df601969b767d timmywil committed May 29, 2012
Showing with 4 additions and 3 deletions.
  1. +2 −2 sizzle.js
  2. +2 −1 test/unit/selector.js
View
@@ -211,8 +211,8 @@ var select = function( selector, context, results, seed, contextXML ) {
if ( context ) {
ret = seed ?
- { expr: parts.pop(), set: makeArray(seed) } :
- Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
+ { expr: parts.pop(), set: makeArray( seed ) } :
+ Sizzle.find( parts.pop(), parts.length >= 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
@gibson042

gibson042 May 29, 2012

Member

? context.parentNode : -> ||

@timmywil

timmywil May 29, 2012

Owner

sure, why not

set = ret.expr ?
Sizzle.filter( ret.expr, ret.set ) :
View
@@ -258,7 +258,7 @@ test("multiple", function() {
});
test("child and adjacent", function() {
- expect( 33 );
+ expect( 34 );
t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );
t( "Child", "p> a", ["simon1","google","groups","mark","yahoo","simon"] );
@@ -281,6 +281,7 @@ test("child and adjacent", function() {
t( "Element Preceded By", "#groups ~ a", ["mark"] );
t( "Element Preceded By", "#length ~ input", ["idTest"] );
t( "Element Preceded By", "#siblingfirst ~ em", ["siblingnext"] );
+ t( "Element Preceded By, Containing", "#liveHandlerOrder ~ div em:contains('1')", ["siblingfirst"] );
var siblingFirst = document.getElementById("siblingfirst");

0 comments on commit 0f71c40

Please sign in to comment.