diff --git a/sizzle.js b/sizzle.js index 07654d59..3035fb0f 100644 --- a/sizzle.js +++ b/sizzle.js @@ -96,7 +96,7 @@ var Sizzle = function( selector, context, results, seed ) { 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 ); + Sizzle.find( parts.pop(), parts.length >= 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : diff --git a/test/unit/selector.js b/test/unit/selector.js index 3e287a7a..472797f3 100644 --- a/test/unit/selector.js +++ b/test/unit/selector.js @@ -230,7 +230,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"] ); t( "Child", "p >a", ["simon1","google","groups","mark","yahoo","simon"] ); @@ -252,6 +252,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"] ); same( jQuery("#siblingfirst").find("~ em").get(), q("siblingnext"), "Element Preceded By with a context." ); same( jQuery("#siblingfirst").find("+ em").get(), q("siblingnext"), "Element Directly Preceded By with a context." );