File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,8 @@ var rootjQuery,
1414 // A simple way to check for HTML strings
1515 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
1616 // Strict HTML recognition (#11290: must start with <)
17- rquickExpr = / ^ (?: \s * ( < [ \w \W ] + > ) [ ^ > ] * | # ( [ \w - ] * ) ) $ / ,
17+ // Shortcut simple #id case for speed
18+ rquickExpr = / ^ (?: \s * ( < [ \w \W ] + > ) [ ^ > ] * | # ( [ \w - ] + ) ) $ / ,
1819
1920 init = jQuery . fn . init = function ( selector , context ) {
2021 var match , elem ;
Original file line number Diff line number Diff line change @@ -57,10 +57,15 @@ test("jQuery()", function() {
5757 equal ( jQuery ( undefined ) . length , 0 , "jQuery(undefined) === jQuery([])" ) ;
5858 equal ( jQuery ( null ) . length , 0 , "jQuery(null) === jQuery([])" ) ;
5959 equal ( jQuery ( "" ) . length , 0 , "jQuery('') === jQuery([])" ) ;
60- equal ( jQuery ( "#" ) . length , 0 , "jQuery('#') === jQuery([])" ) ;
61-
6260 equal ( jQuery ( obj ) . selector , "div" , "jQuery(jQueryObj) == jQueryObj" ) ;
6361
62+ // Invalid #id goes to Sizzle which will throw an error (gh-1682)
63+ try {
64+ jQuery ( "#" ) ;
65+ } catch ( e ) {
66+ ok ( true , "Threw an error on #id with no id" ) ;
67+ }
68+
6469 // can actually yield more than one, when iframes are included, the window is an array as well
6570 equal ( jQuery ( window ) . length , 1 , "Correct number of elements generated for jQuery(window)" ) ;
6671
You can’t perform that action at this time.
0 commit comments