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');