Skip to content

Commit

Permalink
Fix issue where certain versions of Safari treat class names case-ins…
Browse files Browse the repository at this point in the history
…ensitively in Selector/$$ queries. [#390 state:resolved]
  • Loading branch information
savetheclocktower committed Nov 19, 2008
1 parent 9f09a8c commit 3ad847c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,3 +1,5 @@
* Fix issue where certain versions of Safari treat class names case-insensitively in Selector/$$ queries. (Andrew Dupont, kangax, Brice)

* Fix issue where Function#argumentNames returned incorrect results in IE when comments were intermixed with argument names. (Christophe Porteneuve, T.J. Crowder) * Fix issue where Function#argumentNames returned incorrect results in IE when comments were intermixed with argument names. (Christophe Porteneuve, T.J. Crowder)


* Performance improvements in Function methods (Samuel Lebeau, kangax, jddalton, Tobie Langel). * Performance improvements in Function methods (Samuel Lebeau, kangax, jddalton, Tobie Langel).
Expand Down
21 changes: 21 additions & 0 deletions src/dom/selector.js
Expand Up @@ -38,6 +38,8 @@ var Selector = Class.create({


shouldUseSelectorsAPI: function() { shouldUseSelectorsAPI: function() {
if (!Prototype.BrowserFeatures.SelectorsAPI) return false; if (!Prototype.BrowserFeatures.SelectorsAPI) return false;

if (Selector.CASE_INSENSITIVE_CLASS_NAMES) return false;


if (!Selector._div) Selector._div = new Element('div'); if (!Selector._div) Selector._div = new Element('div');


Expand Down Expand Up @@ -177,6 +179,25 @@ var Selector = Class.create({
} }
}); });


if (Prototype.BrowserFeatures.SelectorsAPI &&
document.compatMode === 'BackCompat') {
// Versions of Safari 3 before 3.1.2 treat class names case-insensitively in
// quirks mode. If we detect this behavior, we should use a different
// approach.
Selector.CASE_INSENSITIVE_CLASS_NAMES = (function(){
var div = document.createElement('div'),
span = document.createElement('span');

div.id = "prototype_test_id";
span.className = 'Test';
div.appendChild(span);
var isIgnored = (div.querySelector('#prototype_test_id .test') !== null);
div = span = null;
alert(isIgnored);
return isIgnored;
})();
}

Object.extend(Selector, { Object.extend(Selector, {
_cache: { }, _cache: { },


Expand Down

0 comments on commit 3ad847c

Please sign in to comment.