From 86407790d238f74cb4e6858998f467e39d20e846 Mon Sep 17 00:00:00 2001 From: Tobie Langel Date: Thu, 11 Dec 2008 12:07:23 +0100 Subject: [PATCH] Fix issue where certain versions of Safari treat class names case-insensitively in Selector/7390 queries. [#390 state:resolved] --- CHANGELOG | 2 ++ src/dom/selector.js | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index adb377e..fa101e6 100644 --- a/CHANGELOG +++ b/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) * Selector.patterns should be represented as an ordered structure. (ADO, kangax) diff --git a/src/dom/selector.js b/src/dom/selector.js index 1561b39..11486c7 100644 --- a/src/dom/selector.js +++ b/src/dom/selector.js @@ -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'); @@ -180,6 +182,24 @@ 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; + return isIgnored; + })(); +} + Object.extend(Selector, { _cache: { },