From c488384f9021e7017d23c4e04c7498ce3ec30cb3 Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Tue, 7 Aug 2007 20:33:53 +0000 Subject: [PATCH] prototype: Add support for brackets in quoted attribute value selectors. Closes #9157. --- CHANGELOG | 4 ++++ src/selector.js | 2 +- test/unit/selector.html | 12 ++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 13bce6e..26baf73 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,9 @@ *SVN* +* Add support for brackets in quoted attribute value selectors. Closes #9157. [Ken Snyder] + +* Add some missing semicolons to the source tree. Closes #9140. [jdalton] + * Fix event extensions and custom events firing for Safari 2.0. [Thomas Fuchs] * Add RegExp.escape for escaping regular expression strings. Closes #9094. [Ken Snyder] diff --git a/src/selector.js b/src/selector.js index 3eeeed0..f5ca759 100644 --- a/src/selector.js +++ b/src/selector.js @@ -252,7 +252,7 @@ Object.extend(Selector, { className: /^\.([\w\-\*]+)(\b|$)/, pseudo: /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|\s|(?=:))/, attrPresence: /^\[([\w]+)\]/, - attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\]]*?)\4|([^'"][^\]]*?)))?\]/ + attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/ }, // for Selector.match and Element#match diff --git a/test/unit/selector.html b/test/unit/selector.html index 90a33b6..d3a9911 100644 --- a/test/unit/selector.html +++ b/test/unit/selector.html @@ -47,6 +47,11 @@ +
+ + +
+
@@ -176,6 +181,13 @@ testSelectorWithTagNameAndNegatedAttributeValue: function() {with(this) { assertEnumEqual([], $$('a[href!=#]')); }}, + + testSelectorWithBracketAttributeValue: function() {with(this) { + assertEnumEqual($('chk_1', 'chk_2'), $$('#troubleForm2 input[name="brackets[5][]"]')); + assertEnumEqual([$('chk_1')], $$('#troubleForm2 input[name="brackets[5][]"]:checked')); + assertEnumEqual([$('chk_2')], $$('#troubleForm2 input[name="brackets[5][]"][value=2]')); + assertEnumEqual([], $$('#troubleForm2 input[name=brackets[5][]]')); + }}, test$$WithNestedAttributeSelectors: function() {with(this) { assertEnumEqual([$('strong')], $$('div[style] p[id] strong'));