From 88f8d3b9af1297b966afdec66827865d1357b54f Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Tue, 16 Oct 2007 02:21:24 +0000 Subject: [PATCH] * Changed Selector pattern match so that descendant combinators after pseudoclass tokens are properly handled. Fixes #9696. [wiktor, kangax, Andrew Dupont] --- CHANGELOG | 2 ++ src/selector.js | 2 +- test/unit/selector.html | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 02ab5c1..9dde224 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Changed Selector pattern match so that descendant combinators after pseudoclass tokens are properly handled. [wiktor, kangax, Andrew Dupont] + * Make sure $w always returns an array. [Andrew Dupont, Tobie Langel] * Add more tests to Hash. [Mislav Marohnić] diff --git a/src/selector.js b/src/selector.js index 5a6a495..bfb150e 100644 --- a/src/selector.js +++ b/src/selector.js @@ -250,7 +250,7 @@ Object.extend(Selector, { tagName: /^\s*(\*|[\w\-]+)(\b|$)?/, id: /^#([\w\-\*]+)(\b|$)/, className: /^\.([\w\-\*]+)(\b|$)/, - pseudo: /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|\s|(?=:))/, + 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]*?)\4|([^'"][^\]]*?)))?\]/ }, diff --git a/test/unit/selector.html b/test/unit/selector.html index d3a9911..b42b4f5 100644 --- a/test/unit/selector.html +++ b/test/unit/selector.html @@ -358,6 +358,7 @@ assertEnumEqual([$('link_2')], $$('#p a:not(a[rel$=nofollow])'), 'attribute 3'); assertEnumEqual([$('em')], $$('#p a:not(a[rel$="nofollow"]) > em'), 'attribute 4') assertEnumEqual([$('item_2')], $$('#list li:not(#item_1):not(#item_3)'), 'adjacent :not clauses'); + assertEnumEqual([$('son')], $$('#grandfather > div:not(#uncle) #son')); }}, testSelectorWithEnabledDisabledChecked: function() {with(this) {