diff --git a/src/sizzle b/src/sizzle index 5003e3131..0afda8fcb 160000 --- a/src/sizzle +++ b/src/sizzle @@ -1 +1 @@ -Subproject commit 5003e31312b9309f88cc1019b0a8702daac20b16 +Subproject commit 0afda8fcb59cfb16fa75e25b9eea25ee32841bb3 diff --git a/test/unit/traversing.js b/test/unit/traversing.js index 4cbcee912..18f9ad9f8 100644 --- a/test/unit/traversing.js +++ b/test/unit/traversing.js @@ -101,6 +101,49 @@ test("is(jQuery)", function() { ok( !jQuery("#simon").is( jQuery(".blogTest")[0] ), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" ); }); +test("filter() with positional selectors", function() { + expect(19); + + var html = jQuery('' + + '

' + + '' + + 'first' + + '' + + '' + + 'test' + + '' + + '' + + '

').appendTo( "body" ), + filterit = function(sel, filter, length) { + equal( jQuery( sel ).filter( filter ).length, length, "jQuery( " + sel + " ).filter( " + filter + " )" ); + }; + + filterit( "#posp", "#posp:first", 1); + filterit( "#posp", "#posp:eq(2)", 0 ); + filterit( "#posp", "#posp a:first", 0 ); + + // Keep in mind this is within the selection and + // not in relation to other elements (.is() is a different story) + filterit( "#posp .firsta", "#posp a:first", 1 ); + filterit( "#posp .firsta", "#posp a:last", 1 ); + filterit( "#posp .firsta", "#posp a:last-child", 0 ); + filterit( "#posp .firsta", "#posp a:even", 1 ); + filterit( "#posp .firsta", "#posp a:odd", 0 ); + filterit( "#posp .firsta", "#posp a:eq(0)", 1 ); + filterit( "#posp .firsta", "#posp a:eq(9)", 0 ); + filterit( "#posp .firsta", "#posp em:eq(0)", 0 ); + filterit( "#posp .firsta", "#posp em:first", 0 ); + filterit( "#posp .firsta", "#posp:first", 0 ); + + filterit( "#posp .seconda", "#posp a:first", 1 ); + filterit( "#posp .seconda", "#posp em:first", 0 ); + filterit( "#posp .seconda", "#posp a:last", 1 ); + filterit( "#posp .seconda", "#posp a:gt(0)", 0 ); + filterit( "#posp .seconda", "#posp a:lt(5)", 1 ); + filterit( "#posp .seconda", "#posp a:lt(1)", 1 ); + html.remove(); +}); + test("index()", function() { expect( 2 );