diff --git a/sizzle.js b/sizzle.js index 0f4df28f..f7a23bfc 100644 --- a/sizzle.js +++ b/sizzle.js @@ -1029,7 +1029,8 @@ function tokenize( selector, parseOnly ) { // Comma and first run if ( !matched || (match = rcomma.exec( soFar )) ) { if ( match ) { - soFar = soFar.slice( match[0].length ); + // Don't consume trailing commas as valid + soFar = soFar.slice( match[0].length ) || soFar; } groups.push( tokens = [] ); } diff --git a/test/unit/selector.js b/test/unit/selector.js index aa6ebd44..73d78471 100644 --- a/test/unit/selector.js +++ b/test/unit/selector.js @@ -164,7 +164,7 @@ test("XML Document Selectors", function() { }); test("broken", function() { - expect( 21 ); + expect( 22 ); function broken( name, selector ) { raises(function() { @@ -183,6 +183,7 @@ test("broken", function() { broken( "Broken Selector", "{}" ); broken( "Broken Selector", "," ); broken( "Broken Selector", ",a" ); + broken( "Broken Selector", "a," ); // Hangs on IE 9 if regular expression is inefficient broken( "Broken Selector", "[id=012345678901234567890123456789"); broken( "Doesn't exist", ":visble" );