aboutsummaryrefslogtreecommitdiffstats
path: root/src/selector.js
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2009-02-07 16:54:11 +0000
committerJohn Resig <jeresig@gmail.com>2009-02-07 16:54:11 +0000
commit2b7642cff025be3b8ac019ae77f2f19ecd07fa87 (patch)
tree661d72e5085d63e7272dfb8fb0c5f1d35304db7b /src/selector.js
parentce00f88ae20b3b569138435c6dd87f44bf5d2be0 (diff)
downloadjquery-2b7642cff025be3b8ac019ae77f2f19ecd07fa87.tar.gz
jquery-2b7642cff025be3b8ac019ae77f2f19ecd07fa87.zip
Added logic for not using getElementsByClassName in different failure states. Fixes jQuery bugs #4058 and #4042.
Diffstat (limited to 'src/selector.js')
-rw-r--r--src/selector.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/selector.js b/src/selector.js
index 5425d9482..9fb674ec3 100644
--- a/src/selector.js
+++ b/src/selector.js
@@ -741,12 +741,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 = "<div class='test e'></div><div class='test'></div>";
+
+ // 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++ ) {