1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var ScopeChecker_1 = require("./ScopeChecker");
|
4 | var utils_1 = require("./utils");
|
5 | function toElArray(input) {
|
6 | return Array.prototype.slice.call(input);
|
7 | }
|
8 | var ElementFinder = (function () {
|
9 | function ElementFinder(namespace, isolateModule) {
|
10 | this.namespace = namespace;
|
11 | this.isolateModule = isolateModule;
|
12 | }
|
13 | ElementFinder.prototype.call = function () {
|
14 | var namespace = this.namespace;
|
15 | var selector = utils_1.getSelectors(namespace);
|
16 | var scopeChecker = new ScopeChecker_1.ScopeChecker(namespace, this.isolateModule);
|
17 | var topNode = this.isolateModule.getElement(namespace.filter(function (n) { return n.type !== 'selector'; }));
|
18 | if (topNode === undefined) {
|
19 | return [];
|
20 | }
|
21 | if (selector === '') {
|
22 | return [topNode];
|
23 | }
|
24 | return toElArray(topNode.querySelectorAll(selector))
|
25 | .filter(scopeChecker.isDirectlyInScope, scopeChecker)
|
26 | .concat(topNode.matches(selector) ? [topNode] : []);
|
27 | };
|
28 | return ElementFinder;
|
29 | }());
|
30 | exports.ElementFinder = ElementFinder;
|
31 |
|
\ | No newline at end of file |