@@ -165,7 +165,8 @@ Sizzle.find = function(expr, context, isXML){
165165} ;
166166
167167Sizzle . 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 ] ) ;
169170
170171 while ( expr && set . length ) {
171172 for ( var type in Expr . filter ) {
@@ -178,7 +179,7 @@ Sizzle.filter = function(expr, set, inplace, not){
178179 }
179180
180181 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 ) ;
182183
183184 if ( ! match ) {
184185 anyFound = found = true ;
@@ -357,9 +358,13 @@ var Expr = Sizzle.selectors = {
357358 }
358359 } ,
359360 preFilter : {
360- CLASS : function ( match , curLoop , inplace , result , not ) {
361+ CLASS : function ( match , curLoop , inplace , result , not , isXML ) {
361362 match = " " + match [ 1 ] . replace ( / \\ / g, "" ) + " " ;
362363
364+ if ( isXML ) {
365+ return match ;
366+ }
367+
363368 for ( var i = 0 , elem ; ( elem = curLoop [ i ] ) != null ; i ++ ) {
364369 if ( elem ) {
365370 if ( not ^ ( elem . className && ( " " + elem . className + " " ) . indexOf ( match ) >= 0 ) ) {
@@ -397,10 +402,10 @@ var Expr = Sizzle.selectors = {
397402
398403 return match ;
399404 } ,
400- ATTR : function ( match ) {
405+ ATTR : function ( match , curLoop , inplace , result , not , isXML ) {
401406 var name = match [ 1 ] . replace ( / \\ / g, "" ) ;
402407
403- if ( Expr . attrMap [ name ] ) {
408+ if ( ! isXML && Expr . attrMap [ name ] ) {
404409 match [ 1 ] = Expr . attrMap [ name ] ;
405410 }
406411
@@ -588,7 +593,8 @@ var Expr = Sizzle.selectors = {
588593 return ( match === "*" && elem . nodeType === 1 ) || elem . nodeName === match ;
589594 } ,
590595 CLASS : function ( elem , match ) {
591- return match . test ( elem . className ) ;
596+ return ( " " + ( elem . className || elem . getAttribute ( "class" ) ) + " " )
597+ . indexOf ( match ) > - 1 ;
592598 } ,
593599 ATTR : function ( elem , match ) {
594600 var name = match [ 1 ] ,
@@ -815,8 +821,10 @@ if ( document.getElementsByClassName && document.documentElement.getElementsByCl
815821 return ;
816822
817823 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+ }
820828 } ;
821829} ) ( ) ;
822830
0 commit comments