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:55:33 -0500
commit93f95c966355f02b5695f50523f88687eadb4c81 (patch)
tree7927ade77363f17b3e88ef17da3fd350cba9d8f6 /test/unit/core.js
parent503e54564a8a88b7e968b64a920f2eeceffb0b74 (diff)
downloadjquery-93f95c966355f02b5695f50523f88687eadb4c81.tar.gz
jquery-93f95c966355f02b5695f50523f88687eadb4c81.zip
Core: Throw an error on $("#") rather than returning 0-length collection
Closes gh-1682 Thanks @goob for the issue report! (cherry picked from commit 80022c81ce4a07a232afd3c580b0977555a2daec)
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 2fefb3725..9d02f1a86 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)" );