File tree Expand file tree Collapse file tree 2 files changed +14
-11
lines changed Expand file tree Collapse file tree 2 files changed +14
-11
lines changed Original file line number Diff line number Diff line change 1
1
var runtil = / U n t i l $ / ,
2
2
rparentsprev = / ^ (?: p a r e n t s | p r e v (?: U n t i l | A l l ) ) / ,
3
3
isSimple = / ^ .[ ^ : # \[ \. , ] * $ / ,
4
- POS = jQuery . expr . match . globalPOS ,
4
+ rneedsContext = jQuery . expr . match . needsContext ,
5
5
// methods guaranteed to produce a unique set when starting from a unique set
6
6
guaranteedUnique = {
7
7
children : true ,
@@ -72,9 +72,9 @@ jQuery.fn.extend({
72
72
is : function ( selector ) {
73
73
return ! ! selector && (
74
74
typeof selector === "string" ?
75
- // If this is a positional selector, check membership in the returned set
75
+ // If this is a positional/relative selector, check membership in the returned set
76
76
// so $("p:first").is("p:last") won't return true for a doc with two "p".
77
- POS . test ( selector ) ?
77
+ rneedsContext . test ( selector ) ?
78
78
jQuery ( selector , this . context ) . index ( this [ 0 ] ) >= 0 :
79
79
jQuery . filter ( selector , this ) . length > 0 :
80
80
this . filter ( selector ) . length > 0 ) ;
@@ -85,7 +85,7 @@ jQuery.fn.extend({
85
85
i = 0 ,
86
86
l = this . length ,
87
87
ret = [ ] ,
88
- pos = POS . test ( selectors ) || typeof selectors !== "string" ?
88
+ pos = rneedsContext . test ( selectors ) || typeof selectors !== "string" ?
89
89
jQuery ( selectors , context || this . context ) :
90
90
0 ;
91
91
Original file line number Diff line number Diff line change @@ -2342,17 +2342,20 @@ test("jQuery.off using dispatched jQuery.Event", function() {
2342
2342
. remove ( ) ;
2343
2343
} ) ;
2344
2344
2345
- test ( "delegated event with delegateTarget-relative selector (#) " , function ( ) {
2346
- expect ( 1 ) ;
2347
- var markup = jQuery ( '<ul><li><ul id="u1 "><li id="f1 "></li></ ul></li>' ) . appendTo ( "body" ) ;
2345
+ test ( "delegated event with delegateTarget-relative selector" , function ( ) {
2346
+ expect ( 2 ) ;
2347
+ var markup = jQuery ( '<ul><li><a id="a0"></a>< ul id="ul0 "><li><a id="a0_0 "></a></ li><li><a id="a0_1"></a></li></ ul></li></ul >' ) . appendTo ( "body" ) ;
2348
2348
2349
2349
markup
2350
- . find ( "#u1" )
2351
- . on ( "click" , "li:first" , function ( ) {
2352
- ok ( this . id === "f1" , "first li under #u1 was clicked" ) ;
2350
+ . on ( "click" , ">li>a" , function ( ) {
2351
+ ok ( this . id === "a0" , "child li was clicked" ) ;
2352
+ } )
2353
+ . find ( "#ul0" )
2354
+ . on ( "click" , "li:first>a" , function ( ) {
2355
+ ok ( this . id === "a0_0" , "first li under #u10 was clicked" ) ;
2353
2356
} )
2354
- . find ( "#f1" ) . click ( ) . end ( )
2355
2357
. end ( )
2358
+ . find ( "a" ) . click ( ) . end ( )
2356
2359
. remove ( ) ;
2357
2360
} ) ;
2358
2361
You can’t perform that action at this time.
0 commit comments