Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix issue where certain versions of Safari treat class names case-ins…

…ensitively in Selector/$$ queries. [#390 state:resolved]
  • Loading branch information...
commit 3ad847ce4b824608b1f6f9c5a163db21c7744a4e 1 parent 9f09a8c
Andrew Dupont savetheclocktower authored
Showing with 23 additions and 0 deletions.
  1. +2 −0  CHANGELOG
  2. +21 −0 src/dom/selector.js
2  CHANGELOG
View
@@ -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)
* Performance improvements in Function methods (Samuel Lebeau, kangax, jddalton, Tobie Langel).
21 src/dom/selector.js
View
@@ -38,6 +38,8 @@ var Selector = Class.create({
shouldUseSelectorsAPI: function() {
if (!Prototype.BrowserFeatures.SelectorsAPI) return false;
+
+ if (Selector.CASE_INSENSITIVE_CLASS_NAMES) return false;
if (!Selector._div) Selector._div = new Element('div');
@@ -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);
Juriy Zaytsev Collaborator
kangax added a note

this should go, right? : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ return isIgnored;
+ })();
+}
+
Object.extend(Selector, {
_cache: { },

3 comments on commit 3ad847c

Juriy Zaytsev
Collaborator

this should go, right? : )

John-David Dalton

why should Prototype care about quirksmode if nothing else in the code supports it ?

John-David Dalton

(btw I think quriksmode support is a good thing)

Andrew Dupont
Collaborator

@kangax: Yeah, that’s the danger of committing something late at night. Plus I didn’t run unit tests for this since we don’t test in quirks mode. ;-)

@jdalton: This is a serious enough issue that we decided it warranted fixing, even if we don’t officially support quirks mode. You’re welcome to write a plugin that patches all our positioning methods to support quirks mode. ;-)

Please sign in to comment.
Something went wrong with that request. Please try again.