Skip to content

Commit bbd453c

Browse files
committed
Revert "Core: Throw an error on $("#") rather than returning 0-length collection"
This reverts commit 80022c8.
1 parent f1fb094 commit bbd453c

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

src/core/init.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ var rootjQuery,
1212
// A simple way to check for HTML strings
1313
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
1414
// Strict HTML recognition (#11290: must start with <)
15-
// Shortcut simple #id case for speed
16-
rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
15+
rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
1716

1817
init = jQuery.fn.init = function( selector, context, root ) {
1918
var match, elem;

test/unit/core.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,9 @@ QUnit.test( "jQuery()", function( assert ) {
5656
assert.equal( jQuery(undefined).length, 0, "jQuery(undefined) === jQuery([])" );
5757
assert.equal( jQuery(null).length, 0, "jQuery(null) === jQuery([])" );
5858
assert.equal( jQuery("").length, 0, "jQuery('') === jQuery([])" );
59-
assert.equal( jQuery(obj).selector, "div", "jQuery(jQueryObj) == jQueryObj" );
59+
assert.equal( jQuery("#").length, 0, "jQuery('#') === jQuery([])" );
6060

61-
// Invalid #id goes to Sizzle which will throw an error (gh-1682)
62-
try {
63-
jQuery( "#" );
64-
} catch ( e ) {
65-
assert.ok( true, "Threw an error on #id with no id" );
66-
}
61+
assert.equal( jQuery(obj).selector, "div", "jQuery(jQueryObj) == jQueryObj" );
6762

6863
// can actually yield more than one, when iframes are included, the window is an array as well
6964
assert.equal( jQuery( window ).length, 1, "Correct number of elements generated for jQuery(window)" );

0 commit comments

Comments
 (0)