Skip to content

Commit

Permalink
Escape ":" and "." characters when doing contextual CSS selection in …
Browse files Browse the repository at this point in the history
…browsers that support querySelectorAll. [#559 state:resolved] (fxtentacle, Andrew Dupont)
  • Loading branch information
savetheclocktower committed Feb 22, 2009
1 parent 9da5045 commit 97fc24a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,3 +1,5 @@
* Escape ":" and "." characters when doing contextual CSS selection in browsers that support querySelectorAll. [#559 state:resolved] (fxtentacle, Andrew Dupont)

* Ensure the `target` property on events is never undefined in IE. [#383 state:resolved] (Mathias Karstädt, Diego Perini, Andrew Dupont)

* Ensure Element#descendants always returns an array. [#373 state:resolved] (kangax)
Expand Down
4 changes: 3 additions & 1 deletion src/dom/selector.js
Expand Up @@ -122,9 +122,11 @@ var Selector = Class.create({
// Add an explicit context to the selector if necessary.
if (root !== document) {
var oldId = root.id, id = $(root).identify();
// Escape special characters in the ID.
id = id.replace(/[\.:]/g, "\\$0");
e = "#" + id + " " + e;
}

results = $A(root.querySelectorAll(e)).map(Element.extend);
root.id = oldId;

Expand Down

2 comments on commit 97fc24a

@jdalton
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why support invalid selectors, they should be escaped in the first place….
http://www.w3.org/TR/selectors-api/#queryselectorall

@jdalton
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Escape characters: http://www.w3.org/TR/css3-syntax/#characters

Please sign in to comment.