diff --git a/CHANGELOG b/CHANGELOG index 466bb4a70..06ca72a48 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +* Selector.patterns should be represented as an ordered structure. (ADO, kangax) + +* Work around an issue with assigning a variable within a "return" statement in V8/Google Chrome. (Chris Lear, Oleg K, Maikel Punie, Andrew Dupont) + *1.6.0.3* (September 29, 2008) * Add support for the Chrome browser in jstest.rb. (Andrew Dupont) diff --git a/src/event.js b/src/event.js index 20657a9e9..6cb97368d 100644 --- a/src/event.js +++ b/src/event.js @@ -160,7 +160,8 @@ Object.extend(Event, (function() { } function getCacheForID(id) { - return cache[id] = cache[id] || { }; + cache[id] = cache[id] || { }; + return cache[id]; } function getWrappersForEventName(id, eventName) { diff --git a/src/selector.js b/src/selector.js index 9a8ff3fab..1561b3919 100644 --- a/src/selector.js +++ b/src/selector.js @@ -54,7 +54,7 @@ var Selector = Class.create({ compileMatcher: function() { var e = this.expression, ps = Selector.patterns, h = Selector.handlers, - c = Selector.criteria, le, p, m; + c = Selector.criteria, le, p, m, len = ps.length, name; if (Selector._cache[e]) { this.matcher = Selector._cache[e]; @@ -66,11 +66,12 @@ var Selector = Class.create({ while (e && le != e && (/\S/).test(e)) { le = e; - for (var i in ps) { - p = ps[i]; + for (var i = 0; i\s*/, - adjacent: /^\s*\+\s*/, - descendant: /^\s/, + { name: 'laterSibling', re: /^\s*~\s*/ }, + { name: 'child', re: /^\s*>\s*/ }, + { name: 'adjacent', re: /^\s*\+\s*/ }, + { name: 'descendant', re: /^\s/ }, // selectors follow - 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|[:+~>]))/, - attrPresence: /^\[((?:[\w]+:)?[\w]+)\]/, - attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/ - }, + { name: 'tagName', re: /^\s*(\*|[\w\-]+)(\b|$)?/ }, + { name: 'id', re: /^#([\w\-\*]+)(\b|$)/ }, + { name: 'className', re: /^\.([\w\-\*]+)(\b|$)/ }, + { name: 'pseudo', re: /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/ }, + { name: 'attrPresence', re: /^\[((?:[\w]+:)?[\w]+)\]/ }, + { name: 'attr', re: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/ } + ], // for Selector.match and Element#match assertions: { diff --git a/test/unit/base_test.js b/test/unit/base_test.js index 25e163afb..c9957937d 100644 --- a/test/unit/base_test.js +++ b/test/unit/base_test.js @@ -13,6 +13,16 @@ new Test.Unit.Runner({ this.assertEnumEqual(["one"], named2.argumentNames()); function named3(one, two, three) {}; this.assertEnumEqual(["one", "two", "three"], named3.argumentNames()); + function named4(/*foo*/ foo, /* bar */ bar, /*****/ baz) {} + this.assertEnumEqual($w("foo bar baz"), named4.argumentNames()); + + function named5( + /*foo*/ foo, + /**/bar, + /* baz */ /* baz */ baz, + // Skip a line just to screw with the regex... + /* thud */ thud) {} + this.assertEnumEqual($w("foo bar baz thud"), named5.argumentNames()); }, testFunctionBind: function() {