From 059ce21040ce1c469d13c3633ead78d03fc610c3 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Fri, 17 Jul 2009 12:13:47 +0200 Subject: [PATCH] Proper fix (and unit tests) for selector escaping issue. --- src/dom/selector.js | 2 +- test/unit/fixtures/selector.html | 11 +++++++++++ test/unit/selector_test.js | 8 ++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/dom/selector.js b/src/dom/selector.js index 7d30418..947fd89 100644 --- a/src/dom/selector.js +++ b/src/dom/selector.js @@ -170,7 +170,7 @@ var Selector = Class.create({ if (root !== document) { var oldId = root.id, id = $(root).identify(); // Escape special characters in the ID. - id = id.replace(/[\.:]/g, "\\$1"); + id = id.replace(/([\.:])/g, "\\$1"); e = "#" + id + " " + e; } diff --git a/test/unit/fixtures/selector.html b/test/unit/fixtures/selector.html index cad88a6..42abcd4 100644 --- a/test/unit/fixtures/selector.html +++ b/test/unit/fixtures/selector.html @@ -53,6 +53,17 @@ +
+ + + + + + + + + +
grandfather
father diff --git a/test/unit/selector_test.js b/test/unit/selector_test.js index 9ec3c34..fc2eae2 100644 --- a/test/unit/selector_test.js +++ b/test/unit/selector_test.js @@ -397,6 +397,14 @@ new Test.Unit.Runner({ this.assertEqual(a, b); }, + testElementDownWithDotAndColon: function() { + var a = $('dupL4_dotcolon'); + var b = $('dupContainer.withdot:active').down('#dupL4_dotcolon'); + var c = $('dupContainer.withdot:active').select('#dupL4_dotcolon'); + + this.assertEqual(a, b); + this.assertEnumEqual([a], c); + }, testDescendantSelectorBuggy: function() { var el = document.createElement('div');