From 83826829a7732c710f47c77ac45d887a72044224 Mon Sep 17 00:00:00 2001 From: Tobie Langel Date: Sat, 24 Oct 2009 16:12:38 +0200 Subject: [PATCH] Add Prototype.Selector.engine which simply holds a reference to the actual selector engine used. --- vendor/legacy/selector_engine.js | 13 +++++++------ vendor/nwmatcher/selector_engine.js | 25 ++++++++++++------------- vendor/sizzle/selector_engine.js | 27 +++++++++++++-------------- 3 files changed, 32 insertions(+), 33 deletions(-) diff --git a/vendor/legacy/selector_engine.js b/vendor/legacy/selector_engine.js index cff9dab..21d5c6b 100644 --- a/vendor/legacy/selector_engine.js +++ b/vendor/legacy/selector_engine.js @@ -1,17 +1,18 @@ //= require "repository/legacy" -Prototype.Selector = (function(Legacy) { +Prototype.Selector = (function(engine) { function select(selector, scope) { - return Legacy.findChildElements(scope || document, [selector]); + return engine.findChildElements(scope || document, [selector]); } function match(element, selector) { - return !!Legacy.findElement([element], selector); + return !!engine.findElement([element], selector); } return { - select: select, - match: match, - filter: Legacy.matchElements + engine: engine, + select: select, + match: match, + filter: engine.matchElements }; })(Prototype.Legacy); diff --git a/vendor/nwmatcher/selector_engine.js b/vendor/nwmatcher/selector_engine.js index 2ebeda7..5bc8ac4 100644 --- a/vendor/nwmatcher/selector_engine.js +++ b/vendor/nwmatcher/selector_engine.js @@ -1,20 +1,15 @@ -Prototype._original_nw = window.NW; +Prototype._original_property = window.NW; //= require "repository/src/nwmatcher" -Prototype.NW = window.NW; -// Restore globals. -window.NW = Prototype._original_nw; -delete Prototype._original_nw; - -Prototype.Selector = (function(NWDom) { +Prototype.Selector = (function(engine) { function select(selector, scope) { - return NWDom.select(selector, scope || document, null, Element.extend); + return engine.select(selector, scope || document, null, Element.extend); } function filter(elements, selector) { var results = [], element, i = 0; while (element = elements[i++]) { - if (NWDom.match(element, selector)) { + if (engine.match(element, selector)) { Element.extend(element); results.push(element); } @@ -23,9 +18,13 @@ Prototype.Selector = (function(NWDom) { } return { - select: select, - match: NWDom.match, - filter: filter + engine: engine, + select: select, + match: engine.match, + filter: filter }; -})(Prototype.NW.Dom); +})(NW.Dom); +// Restore globals. +window.NW = Prototype._original_property; +delete Prototype._original_property; \ No newline at end of file diff --git a/vendor/sizzle/selector_engine.js b/vendor/sizzle/selector_engine.js index bed246f..6980631 100644 --- a/vendor/sizzle/selector_engine.js +++ b/vendor/sizzle/selector_engine.js @@ -1,12 +1,7 @@ -Prototype._original_sizzle = window.Sizzle; +Prototype._original_property = window.Sizzle; //= require "repository/sizzle" -Prototype.Sizzle = window.Sizzle; -// Restore globals. -window.Sizzle = Prototype._original_sizzle; -delete Prototype._original_sizzle; - -Prototype.Selector = (function(Sizzle) { +Prototype.Selector = (function(engine) { function extend(elements) { for (var i = 0, length = elements.length; i < length; i++) elements[i] = Element.extend(elements[i]); @@ -14,21 +9,25 @@ Prototype.Selector = (function(Sizzle) { } function select(selector, scope) { - return extend(Sizzle(selector, scope || document)); + return extend(engine(selector, scope || document)); } function match(element, selector) { - return Sizzle.matches(selector, [element]).length == 1; + return engine.matches(selector, [element]).length == 1; } function filter(elements, selector) { - return extend(Sizzle.matches(selector, elements)); + return extend(engine.matches(selector, elements)); } return { - select: select, - match: match, - filter: filter + engine: engine, + select: select, + match: match, + filter: filter }; -})(Prototype.Sizzle); +})(Sizzle); +// Restore globals. +window.Sizzle = Prototype._original_property; +delete Prototype._original_property;