diff --git a/CHANGELOG b/CHANGELOG index 7a4ac79..37ac38e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ *SVN* -* Fix "function $A" declaration inside of a conditional (confuses IE). Fixes #10882. [Jacco, Andrew Dupont] +* Test for attribute existence before applying more complex CSS3 selectors. Closes #10870. [arty, Tobie Langel] + +* Fix "function $A" declaration inside of a conditional (confuses IE). Closes #10882. [Jacco, Andrew Dupont] * Fixed selector parsing so that "#foo [bar=baz]" is treated the same way as "#foo *[bar=baz]". Closes #10734. [jlukas, kangax, Andrew Dupont] diff --git a/src/selector.js b/src/selector.js index fd7da25..65a52d8 100644 --- a/src/selector.js +++ b/src/selector.js @@ -297,7 +297,7 @@ Object.extend(Selector, { attr: function(element, matches) { var nodeValue = Element.readAttribute(element, matches[1]); - return Selector.operators[matches[2]](nodeValue, matches[3]); + return nodeValue && Selector.operators[matches[2]](nodeValue, matches[3]); } }, diff --git a/test/unit/selector.html b/test/unit/selector.html index 6939e77..6ccb819 100644 --- a/test/unit/selector.html +++ b/test/unit/selector.html @@ -245,6 +245,9 @@ assert(!span.match('span span'), 'different ancestry'); assert(!span.match('span > span'), 'different parent'); assert(!span.match('span:nth-child(5)'), 'different pseudoclass'); + + assert(!$('link_2').match('a[rel^=external]')); + assert($('link_1').match('a[rel^=external]')); }}, testSelectorWithSpaceInAttributeValue: function() {with(this) {