X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fselector.js;h=7c0bf4082cbdc1cde73ce5f9e06c68a7f41cb1fb;hb=6b938e1c162877ee62681f8aefe6f64ba208eead;hp=5425d94821db4d0c2b4adf53018aa4f4e0b36469;hpb=d1a34f79081dfcfcfe851412dafd172428a6d92a;p=jquery.git diff --git a/src/selector.js b/src/selector.js index 5425d94..7c0bf40 100644 --- a/src/selector.js +++ b/src/selector.js @@ -6,7 +6,7 @@ */ (function(){ -var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]+['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[]+)+|[>+~])(\s*,\s*)?/g, +var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[]+)+|[>+~])(\s*,\s*)?/g, done = 0, toString = Object.prototype.toString; @@ -564,7 +564,16 @@ var Expr = Sizzle.selectors = { return match.test( elem.className ); }, ATTR: function(elem, match){ - var result = Expr.attrHandle[ match[1] ] ? Expr.attrHandle[ match[1] ]( elem ) : elem[ match[1] ] || elem.getAttribute( match[1] ), value = result + "", type = match[2], check = match[4]; + var name = match[1], + result = Expr.attrHandle[ name ] ? + Expr.attrHandle[ name ]( elem ) : + elem[ name ] != null ? + elem[ name ] : + elem.getAttribute( name ), + value = result + "", + type = match[2], + check = match[4]; + return result == null ? type === "!=" : type === "=" ? @@ -573,8 +582,8 @@ var Expr = Sizzle.selectors = { value.indexOf(check) >= 0 : type === "~=" ? (" " + value + " ").indexOf(check) >= 0 : - !match[4] ? - result : + !check ? + value && result !== false : type === "!=" ? value != check : type === "^=" ? @@ -741,12 +750,25 @@ if ( document.querySelectorAll ) (function(){ Sizzle.matches = oldSizzle.matches; })(); -if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) { +if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){ + var div = document.createElement("div"); + div.innerHTML = "
"; + + // Opera can't find a second classname (in 9.6) + if ( div.getElementsByClassName("e").length === 0 ) + return; + + // Safari caches class attributes, doesn't catch changes (in 3.2) + div.lastChild.className = "e"; + + if ( div.getElementsByClassName("e").length === 1 ) + return; + Expr.order.splice(1, 0, "CLASS"); Expr.find.CLASS = function(match, context) { return context.getElementsByClassName(match[1]); }; -} +})(); function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { for ( var i = 0, l = checkSet.length; i < l; i++ ) {