aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/core.js
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2014-12-03 14:51:24 -0500
committerDave Methvin <dave.methvin@gmail.com>2014-12-03 14:51:24 -0500
commit80022c81ce4a07a232afd3c580b0977555a2daec (patch)
tree023abd5908fd43324d1a4bf0de94ce2442aa65ca /test/unit/core.js
parentcfe2eae38df411c0f15cbbf927612bc515063bf5 (diff)
downloadjquery-80022c81ce4a07a232afd3c580b0977555a2daec.tar.gz
jquery-80022c81ce4a07a232afd3c580b0977555a2daec.zip
Core: Throw an error on $("#") rather than returning 0-length collection
Closes gh-1682 Thanks @goob for the issue report!
Diffstat (limited to 'test/unit/core.js')
-rw-r--r--test/unit/core.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/test/unit/core.js b/test/unit/core.js
index 8b820397f..66c02ac57 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -57,10 +57,15 @@ test("jQuery()", function() {
equal( jQuery(undefined).length, 0, "jQuery(undefined) === jQuery([])" );
equal( jQuery(null).length, 0, "jQuery(null) === jQuery([])" );
equal( jQuery("").length, 0, "jQuery('') === jQuery([])" );
- equal( jQuery("#").length, 0, "jQuery('#') === jQuery([])" );
-
equal( jQuery(obj).selector, "div", "jQuery(jQueryObj) == jQueryObj" );
+ // Invalid #id goes to Sizzle which will throw an error (gh-1682)
+ try {
+ jQuery( "#" );
+ } catch ( e ) {
+ ok( true, "Threw an error on #id with no id" );
+ }
+
// can actually yield more than one, when iframes are included, the window is an array as well
equal( jQuery(window).length, 1, "Correct number of elements generated for jQuery(window)" );