Skip to content
Closed
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion sizzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,8 @@ function handlePOSGroup( selector, posfilter, argument, contexts, seed, not ) {
}

if ( selector || !(results = seed) ) {
multipleContexts( selector || "*", contexts, (results = []), seed );
// Make sure the selector is not a bunch of white spaces. Fixes jQuery #12474
multipleContexts( selector.replace( rtrim, "$1" ) || "*", contexts, (results = []), seed );
}

return results.length > 0 ? fn( results, argument, not ) : [];
Expand Down
10 changes: 9 additions & 1 deletion test/unit/selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -711,13 +711,21 @@ test("pseudo - :not", function() {
});

test("pseudo - position", function() {
expect( 32 );
expect( 34 );

t( "First element", "div:first", ["qunit-testrunner-toolbar"] );
t( "First element(case-insensitive)", "div:fiRst", ["qunit-testrunner-toolbar"] );
t( "nth Element", "#qunit-fixture p:nth(1)", ["ap"] );
t( "First Element", "#qunit-fixture p:first", ["firstp"] );
t( "Last Element", "p:last", ["first"] );

var ret = [], foo = document.getElementById("foo");
Sizzle( ":first", foo, ret );
Sizzle( ":last", foo, ret );

equal( ret[0].id, "sndp", "plain :first working on specific context" );
equal( ret[1].id, "simon", "plain :last working on specific context" );

t( "Even Elements", "#qunit-fixture p:even", ["firstp","sndp","sap"] );
t( "Odd Elements", "#qunit-fixture p:odd", ["ap","en","first"] );
t( "Position Equals", "#qunit-fixture p:eq(1)", ["ap"] );
Expand Down