From 3e2e8d48b58061a993d1c1323c50c13554027cde Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Fri, 10 Oct 2008 13:42:27 -0500 Subject: [PATCH 1/4] Work around an issue with assigning a variable within a "return" statement in V8/Google Chrome. [#325 state:resolved] --- CHANGELOG | 2 ++ src/event.js | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 466bb4a70..6b51e78dc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* 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) { From b065eed3b8d7352b383dd007952ff065f8aca56d Mon Sep 17 00:00:00 2001 From: savetheclocktower Date: Fri, 10 Oct 2008 14:19:51 -0500 Subject: [PATCH 2/4] Selector.patterns should be represented as an ordered structure. [#315 state:resolved] --- CHANGELOG | 2 ++ src/selector.js | 67 ++++++++++++++++++++++++++----------------------- 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6b51e78dc..06ca72a48 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* 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) diff --git a/src/selector.js b/src/selector.js index 9a8ff3fab..fda072e01 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: { From 7dfd91ae48a8487e200229d899570c3e7f803286 Mon Sep 17 00:00:00 2001 From: savetheclocktower Date: Fri, 10 Oct 2008 14:24:22 -0500 Subject: [PATCH 3/4] Style cleanup. --- src/selector.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/selector.js b/src/selector.js index fda072e01..1561b3919 100644 --- a/src/selector.js +++ b/src/selector.js @@ -66,7 +66,7 @@ var Selector = Class.create({ while (e && le != e && (/\S/).test(e)) { le = e; - for (var i=0; i Date: Mon, 20 Oct 2008 10:53:11 -0500 Subject: [PATCH 4/4] Tests for ticket #397. --- test/unit/base_test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) 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() {