Ensure selectors of the form "[href]" (attribute token with no preceding tag name) work properly. Closes #8870. [chao, kangax, Andrew Dupont]

This commit is contained in:
Andrew Dupont 2007-11-05 17:11:41 +00:00
parent e457edbcf4
commit 8cd85d12a2
3 changed files with 12 additions and 0 deletions

View File

@ -1,5 +1,7 @@
*SVN*
* Ensure selectors of the form "[href]" (attribute token with no preceding tag name) work properly. Closes #8870. [chao, kangax, Andrew Dupont]
* Performance optimizations for Element#descendantOf. Costliness should no longer be dependent on the difference in depth between the parent and the child. [Andrew Dupont]
* Apply the workaround for the Firefox "blinking element" opacity=1 bug only to Firefox 1.5. [Thomas Fuchs]

View File

@ -436,6 +436,7 @@ Object.extend(Selector, {
},
attrPresence: function(nodes, root, attr) {
if (!nodes) nodes = root.getElementsByTagName("*");
var results = [];
for (var i = 0, node; node = nodes[i]; i++)
if (Element.hasAttribute(node, attr)) results.push(node);

View File

@ -173,6 +173,15 @@
assertEnumEqual($('link_1', 'link_2'), $$('a[class~=internal]'));
}},
testSelectorWithAttributeAndNoTagName: function() {with(this) {
assertEnumEqual($(document.body).select('a[href]'), $(document.body).select('[href]'));
assertEnumEqual($$('a[class~="internal"]'), $$('[class~=internal]'));
assertEnumEqual($$('*[id]'), $$('[id]'));
assertEnumEqual($('checked_radio', 'unchecked_radio'), $$('[type=radio]'));
assertEnumEqual($$('*[type=checkbox]'), $$('[type=checkbox]'));
assertEnumEqual($('with_title', 'commaParent'), $$('[title]'));
}},
testSelectorWithUniversalAndHyphenTokenizedAttributeValue: function() {with(this) {
assertEnumEqual([$('item_3')], $$('*[xml:lang|="es"]'));
assertEnumEqual([$('item_3')], $$('*[xml:lang|="ES"]'));