From 5f85799c3fc93d1131da6c71cc26830b18840385 Mon Sep 17 00:00:00 2001 From: Tobie Langel Date: Fri, 23 Oct 2009 19:29:03 +0200 Subject: [PATCH] Refactor NWMatcher adapter. --- vendor/nwmatcher/selector_engine.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/vendor/nwmatcher/selector_engine.js b/vendor/nwmatcher/selector_engine.js index 9639ae6..2ebeda7 100644 --- a/vendor/nwmatcher/selector_engine.js +++ b/vendor/nwmatcher/selector_engine.js @@ -6,21 +6,17 @@ Prototype.NW = window.NW; window.NW = Prototype._original_nw; delete Prototype._original_nw; -Prototype.Selector = (function(NW) { +Prototype.Selector = (function(NWDom) { function select(selector, scope) { - var results = [], resultsIndex = 0; - NW.select(selector, scope || document, null, function(element) { - results[resultsIndex++] = Element.extend(element); - }); - return results; + return NWDom.select(selector, scope || document, null, Element.extend); } function filter(elements, selector) { - var results = [], resultsIndex = 0, element; - for (var i = 0, length = elements.length; i < length; i++) { - element = elements[i]; - if (NW.match(element, selector)) { - results[resultsIndex++] = Element.extend(element); + var results = [], element, i = 0; + while (element = elements[i++]) { + if (NWDom.match(element, selector)) { + Element.extend(element); + results.push(element); } } return results; @@ -28,7 +24,7 @@ Prototype.Selector = (function(NW) { return { select: select, - match: NW.match, + match: NWDom.match, filter: filter }; })(Prototype.NW.Dom);