diff --git a/CHANGELOG b/CHANGELOG index fa2cd55..58d511a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ *SVN* -* Optimize Element#up/down/next/previous. [Dylan Bruzenak, Nick Stackenburg, Andrew Dupont] +* Fix the way Selector handles [pseudoclass + combinator] with no space in between. Closes #9696. [kangax, fearphage, Andrew Dupont] + +* Optimize Element#up/down/next/previous. Closes #10353. [Dylan Bruzenak, Nick Stackenburg, Andrew Dupont] * Handle case-sensitivity in Selector tag names better. Closes #5052. [mexx, Andrew Dupont] diff --git a/src/selector.js b/src/selector.js index b5814d6..d487b57 100644 --- a/src/selector.js +++ b/src/selector.js @@ -271,7 +271,8 @@ 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 6c01bbe..36af5e4 100644 --- a/test/unit/selector.html +++ b/test/unit/selector.html @@ -100,7 +100,7 @@ // Added by TDD - 2007.02.20 $RunBenchmarks = false; - + new Test.Unit.Runner({ testSelectorWithTagName: function() {with(this) { @@ -372,6 +372,8 @@ 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')); + assertEnumEqual([$('em')], $$('#p a:not(a[rel$="nofollow"]) em'), 'attribute 4 + all descendants'); + assertEnumEqual([$('em')], $$('#p a:not(a[rel$="nofollow"])>em'), 'attribute 4 (without whitespace)'); }}, testSelectorWithEnabledDisabledChecked: function() {with(this) { @@ -398,6 +400,8 @@ assertEnumEqual($$('ul > li:last-child'), $$('ul > li:nth-last-child(1)')); assertEnumEqual($$('#troubleForm *:enabled'), $$('#troubleForm *:not(:disabled)')); assertEnumEqual($$('ul > li:nth-child(n-999)'), $$('ul > li')); + assertEnumEqual($$('ul>li'), $$('ul > li')); + assertEnumEqual($$('#p a:not(a[rel$="nofollow"])>em'), $$('#p a:not(a[rel$="nofollow"]) > em')) }}, testSelectorsThatShouldReturnNothing: function() {with(this) {