@@ -165,7 +165,8 @@ Sizzle.find = function(expr, context, isXML){
165
165
} ;
166
166
167
167
Sizzle . filter = function ( expr , set , inplace , not ) {
168
- var old = expr , result = [ ] , curLoop = set , match , anyFound ;
168
+ var old = expr , result = [ ] , curLoop = set , match , anyFound ,
169
+ isXMLFilter = set && set [ 0 ] && isXML ( set [ 0 ] ) ;
169
170
170
171
while ( expr && set . length ) {
171
172
for ( var type in Expr . filter ) {
@@ -178,7 +179,7 @@ Sizzle.filter = function(expr, set, inplace, not){
178
179
}
179
180
180
181
if ( Expr . preFilter [ type ] ) {
181
- match = Expr . preFilter [ type ] ( match , curLoop , inplace , result , not ) ;
182
+ match = Expr . preFilter [ type ] ( match , curLoop , inplace , result , not , isXMLFilter ) ;
182
183
183
184
if ( ! match ) {
184
185
anyFound = found = true ;
@@ -357,9 +358,13 @@ var Expr = Sizzle.selectors = {
357
358
}
358
359
} ,
359
360
preFilter : {
360
- CLASS : function ( match , curLoop , inplace , result , not ) {
361
+ CLASS : function ( match , curLoop , inplace , result , not , isXML ) {
361
362
match = " " + match [ 1 ] . replace ( / \\ / g, "" ) + " " ;
362
363
364
+ if ( isXML ) {
365
+ return match ;
366
+ }
367
+
363
368
for ( var i = 0 , elem ; ( elem = curLoop [ i ] ) != null ; i ++ ) {
364
369
if ( elem ) {
365
370
if ( not ^ ( elem . className && ( " " + elem . className + " " ) . indexOf ( match ) >= 0 ) ) {
@@ -397,10 +402,10 @@ var Expr = Sizzle.selectors = {
397
402
398
403
return match ;
399
404
} ,
400
- ATTR : function ( match ) {
405
+ ATTR : function ( match , curLoop , inplace , result , not , isXML ) {
401
406
var name = match [ 1 ] . replace ( / \\ / g, "" ) ;
402
407
403
- if ( Expr . attrMap [ name ] ) {
408
+ if ( ! isXML && Expr . attrMap [ name ] ) {
404
409
match [ 1 ] = Expr . attrMap [ name ] ;
405
410
}
406
411
@@ -588,7 +593,8 @@ var Expr = Sizzle.selectors = {
588
593
return ( match === "*" && elem . nodeType === 1 ) || elem . nodeName === match ;
589
594
} ,
590
595
CLASS : function ( elem , match ) {
591
- return match . test ( elem . className ) ;
596
+ return ( " " + ( elem . className || elem . getAttribute ( "class" ) ) + " " )
597
+ . indexOf ( match ) > - 1 ;
592
598
} ,
593
599
ATTR : function ( elem , match ) {
594
600
var name = match [ 1 ] ,
@@ -815,8 +821,10 @@ if ( document.getElementsByClassName && document.documentElement.getElementsByCl
815
821
return ;
816
822
817
823
Expr . order . splice ( 1 , 0 , "CLASS" ) ;
818
- Expr . find . CLASS = function ( match , context ) {
819
- return context . getElementsByClassName ( match [ 1 ] ) ;
824
+ Expr . find . CLASS = function ( match , context , isXML ) {
825
+ if ( typeof context . getElementsByClassName !== "undefined" && ! isXML ) {
826
+ return context . getElementsByClassName ( match [ 1 ] ) ;
827
+ }
820
828
} ;
821
829
} ) ( ) ;
822
830
0 commit comments