Skip to content

Commit

Permalink
Fix Selector to match elements with attributes containing hyphens. [#285
Browse files Browse the repository at this point in the history
 state:resolved] (leiyou, jddalton, kangax)
  • Loading branch information
savetheclocktower committed Feb 22, 2009
1 parent dc9d274 commit 8fe5187
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,3 +1,5 @@
* Fix Selector to match elements with attributes containing hyphens. [#285 state:resolved] (leiyou, jddalton, kangax)

* Make sure Form.reset always returns a reference to the receiver element. [#309 state:resolved] (Phil, kangax)

* Escape ":" and "." characters when doing contextual CSS selection in browsers that support querySelectorAll. [#559 state:resolved] (fxtentacle, Andrew Dupont)
Expand Down
2 changes: 1 addition & 1 deletion src/dom/selector.js
Expand Up @@ -340,7 +340,7 @@ Object.extend(Selector, {
{ name: 'id', re: /^#([\w\-\*]+)(\b|$)/ },
{ name: 'className', re: /^\.([\w\-\*]+)(\b|$)/ },
{ name: 'pseudo', re: /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/ },
{ name: 'attrPresence', re: /^\[((?:[\w]+:)?[\w]+)\]/ },
{ name: 'attrPresence', re: /^\[((?:[\w-]+:)?[\w]+)\]/ },
{ name: 'attr', re: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/ }
],

Expand Down
2 changes: 2 additions & 0 deletions test/unit/fixtures/selector.html
Expand Up @@ -66,4 +66,6 @@ <h1 class="title">Some title <span>here</span></h1>
<input type="hidden" id="commaTwo" name="foo2" value="oops" />
</form>
<div id="counted_container"><div class="is_counted"></div></div>

<div foo-bar="baz" id="attr_with_dash">blah</div>
</div>
4 changes: 4 additions & 0 deletions test/unit/selector_test.js
Expand Up @@ -87,6 +87,10 @@ new Test.Unit.Runner({
this.assertEnumEqual($$('#troubleForm *[type]'), $$('#troubleForm [type]'));
},

testSelectorWithAttributeContainingDash: function() {
this.assertEnumEqual([$('attr_with_dash')], $$('[foo-bar]'));
},

testSelectorWithUniversalAndHyphenTokenizedAttributeValue: function() {
this.assertEnumEqual([$('item_3')], $$('*[xml:lang|="es"]'));
this.assertEnumEqual([$('item_3')], $$('*[xml:lang|="ES"]'));
Expand Down

0 comments on commit 8fe5187

Please sign in to comment.