Add Prototype.Selector.engine which simply holds a reference to the actual selector engine used.
This commit is contained in:
parent
5f85799c3f
commit
83826829a7
13
vendor/legacy/selector_engine.js
vendored
13
vendor/legacy/selector_engine.js
vendored
@ -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);
|
||||
|
25
vendor/nwmatcher/selector_engine.js
vendored
25
vendor/nwmatcher/selector_engine.js
vendored
@ -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;
|
27
vendor/sizzle/selector_engine.js
vendored
27
vendor/sizzle/selector_engine.js
vendored
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user