From 7942a9e5c94d28a09421b19e263f5d09cf1a23f3 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 23 Jan 2008 20:05:17 +0000 Subject: [PATCH] Fixed issue where Element#match failed on attribute selectors with single or double quotes. Closes #10067. [Cezary Okupski, Andrew Dupont] --- CHANGELOG | 2 ++ src/selector.js | 2 +- test/unit/selector.html | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 5f0c3e9..d95b16a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed issue where Element#match failed on attribute selectors with single or double quotes. Closes #10067. [Cezary Okupski, Andrew Dupont] + * Add tests for Element#match. [Tobie Langel] * Fix Element#writeAttribute to work with 'cellspacing' and 'cellpadding' attributes in IE. Closes #9983. [/dev/urandom, Tobie Langel] diff --git a/src/selector.js b/src/selector.js index 65a52d8..de5d590 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 nodeValue && Selector.operators[matches[2]](nodeValue, matches[3]); + return nodeValue && Selector.operators[matches[2]](nodeValue, matches[5] || matches[6]); } }, diff --git a/test/unit/selector.html b/test/unit/selector.html index f4e93f9..1d57c1c 100644 --- a/test/unit/selector.html +++ b/test/unit/selector.html @@ -249,6 +249,8 @@ assert(!$('link_2').match('a[rel^=external]')); assert($('link_1').match('a[rel^=external]')); + assert($('link_1').match('a[rel^="external"]')); + assert($('link_1').match("a[rel^='external']")); assert(span.match({ match: function(element) { return true }}), 'custom selector'); assert(!span.match({ match: function(element) { return false }}), 'custom selector');