@@ -8,61 +8,61 @@ var chars = jQuery.browser.safari && parseInt(jQuery.browser.version) < 417 ?
8
8
9
9
jQuery . extend ( {
10
10
expr : {
11
- "" : "m [2]=='*' ||jQuery.nodeName(a,m[2])" ,
12
- "#" : "a .getAttribute('id' )==m[2]" ,
11
+ "" : function ( a , i , m ) { return m [ 2 ] == "*" || jQuery . nodeName ( a , m [ 2 ] ) ; } ,
12
+ "#" : function ( a , i , m ) { return a . getAttribute ( "id" ) == m [ 2 ] ; } ,
13
13
":" : {
14
14
// Position Checks
15
- lt : "i <m[3]-0" ,
16
- gt : "i >m[3]-0" ,
17
- nth : "m [3]-0==i" ,
18
- eq : "m [3]-0==i" ,
19
- first : "i ==0" ,
20
- last : "i ==r.length-1" ,
21
- even : "i %2==0" ,
22
- odd : "i%2" ,
15
+ lt : function ( a , i , m ) { return i < m [ 3 ] - 0 ; } ,
16
+ gt : function ( a , i , m ) { return i > m [ 3 ] - 0 ; } ,
17
+ nth : function ( a , i , m ) { return m [ 3 ] - 0 == i ; } ,
18
+ eq : function ( a , i , m ) { return m [ 3 ] - 0 == i ; } ,
19
+ first : function ( a , i ) { return i == 0 ; } ,
20
+ last : function ( a , i , m , r ) { return i == r . length - 1 ; } ,
21
+ even : function ( a , i ) { return i % 2 == 0 ; } ,
22
+ odd : function ( a , i ) { return i % 2 ; } ,
23
23
24
24
// Child Checks
25
- "first-child" : "a .parentNode.getElementsByTagName('*' )[0]==a" ,
26
- "last-child" : " jQuery.nth(a.parentNode.lastChild,1,' previousSibling' )==a" ,
27
- "only-child" : " !jQuery.nth(a.parentNode.lastChild,2,' previousSibling')" ,
25
+ "first-child" : function ( a ) { return a . parentNode . getElementsByTagName ( "*" ) [ 0 ] == a ; } ,
26
+ "last-child" : function ( a ) { return jQuery . nth ( a . parentNode . lastChild , 1 , " previousSibling" ) == a ; } ,
27
+ "only-child" : function ( a ) { return ! jQuery . nth ( a . parentNode . lastChild , 2 , " previousSibling" ) ; } ,
28
28
29
29
// Parent Checks
30
- parent : "a .firstChild" ,
31
- empty : " !a.firstChild" ,
30
+ parent : function ( a ) { return a . firstChild ; } ,
31
+ empty : function ( a ) { return ! a . firstChild ; } ,
32
32
33
33
// Text Check
34
- contains : "(a .textContent||a.innerText||jQuery(a).text()||'' ).indexOf(m[3])>=0" ,
34
+ contains : function ( a , i , m ) { return ( a . textContent || a . innerText || jQuery ( a ) . text ( ) || "" ) . indexOf ( m [ 3 ] ) >= 0 ; } ,
35
35
36
36
// Visibility
37
- visible : ' "hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden"' ,
38
- hidden : ' "hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden"' ,
37
+ visible : function ( a ) { return "hidden" != a . type && jQuery . css ( a , "display" ) != "none" && jQuery . css ( a , "visibility" ) != "hidden" ; } ,
38
+ hidden : function ( a ) { return "hidden" == a . type || jQuery . css ( a , "display" ) == "none" || jQuery . css ( a , "visibility" ) == "hidden" ; } ,
39
39
40
40
// Form attributes
41
- enabled : " !a.disabled" ,
42
- disabled : "a .disabled" ,
43
- checked : "a .checked" ,
44
- selected : "a .selected||jQuery.attr(a,' selected')" ,
41
+ enabled : function ( a ) { return ! a . disabled ; } ,
42
+ disabled : function ( a ) { return a . disabled ; } ,
43
+ checked : function ( a ) { return a . checked ; } ,
44
+ selected : function ( a ) { return a . selected || jQuery . attr ( a , " selected" ) ; } ,
45
45
46
46
// Form elements
47
- text : "' text' ==a.type" ,
48
- radio : "' radio' ==a.type" ,
49
- checkbox : "' checkbox' ==a.type" ,
50
- file : "' file' ==a.type" ,
51
- password : "' password' ==a.type" ,
52
- submit : "' submit' ==a.type" ,
53
- image : "' image' ==a.type" ,
54
- reset : "' reset' ==a.type" ,
55
- button : ' "button"==a.type||jQuery.nodeName(a,"button")' ,
56
- input : " /input|select|textarea|button/i.test(a.nodeName)" ,
47
+ text : function ( a ) { return " text" == a . type ; } ,
48
+ radio : function ( a ) { return " radio" == a . type ; } ,
49
+ checkbox : function ( a ) { return " checkbox" == a . type ; } ,
50
+ file : function ( a ) { return " file" == a . type ; } ,
51
+ password : function ( a ) { return " password" == a . type ; } ,
52
+ submit : function ( a ) { return " submit" == a . type ; } ,
53
+ image : function ( a ) { return " image" == a . type ; } ,
54
+ reset : function ( a ) { return " reset" == a . type ; } ,
55
+ button : function ( a ) { return "button" == a . type || jQuery . nodeName ( a , "button" ) ; } ,
56
+ input : function ( a ) { return / i n p u t | s e l e c t | t e x t a r e a | b u t t o n / i. test ( a . nodeName ) ; } ,
57
57
58
58
// :has()
59
- has : " jQuery.find(m[3],a).length" ,
59
+ has : function ( a , i , m ) { return jQuery . find ( m [ 3 ] , a ) . length ; } ,
60
60
61
61
// :header
62
- header : " /h\\ d/i.test(a.nodeName)" ,
62
+ header : function ( a ) { return / h \d / i. test ( a . nodeName ) ; } ,
63
63
64
64
// :animated
65
- animated : " jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length"
65
+ animated : function ( a ) { return jQuery . grep ( jQuery . timers , function ( fn ) { return a == fn . elem ; } ) . length ; }
66
66
}
67
67
} ,
68
68
@@ -390,15 +390,17 @@ jQuery.extend({
390
390
391
391
// Otherwise, find the expression to execute
392
392
} else {
393
- var f = jQuery . expr [ m [ 1 ] ] ;
394
- if ( typeof f != "string " )
395
- f = jQuery . expr [ m [ 1 ] ] [ m [ 2 ] ] ;
393
+ var fn = jQuery . expr [ m [ 1 ] ] ;
394
+ if ( typeof fn == "object " )
395
+ fn = fn [ m [ 2 ] ] ;
396
396
397
- // Build a custom macro to enclose it
398
- f = eval ( "false||function(a,i){return " + f + "}" ) ;
397
+ if ( typeof fn == "string" )
398
+ fn = eval ( "false||function(a,i){return " + fn + "; }" ) ;
399
399
400
400
// Execute it against the current filter
401
- r = jQuery . grep ( r , f , not ) ;
401
+ r = jQuery . grep ( r , function ( elem , i ) {
402
+ return fn ( elem , i , m , r ) ;
403
+ } , not ) ;
402
404
}
403
405
}
404
406
0 commit comments