UNPKG

1.4 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var utils_1 = require("./utils");
4var ScopeChecker = /** @class */ (function () {
5 function ScopeChecker(namespace, isolateModule) {
6 this.namespace = namespace;
7 this.isolateModule = isolateModule;
8 this._namespace = namespace.filter(function (n) { return n.type !== 'selector'; });
9 }
10 /**
11 * Checks whether the given element is *directly* in the scope of this
12 * scope checker. Being contained *indirectly* through other scopes
13 * is not valid. This is crucial for implementing parent-child isolation,
14 * so that the parent selectors don't search inside a child scope.
15 */
16 ScopeChecker.prototype.isDirectlyInScope = function (leaf) {
17 var namespace = this.isolateModule.getNamespace(leaf);
18 if (!namespace) {
19 return false;
20 }
21 if (this._namespace.length > namespace.length ||
22 !utils_1.isEqualNamespace(this._namespace, namespace.slice(0, this._namespace.length))) {
23 return false;
24 }
25 for (var i = this._namespace.length; i < namespace.length; i++) {
26 if (namespace[i].type === 'total') {
27 return false;
28 }
29 }
30 return true;
31 };
32 return ScopeChecker;
33}());
34exports.ScopeChecker = ScopeChecker;
35//# sourceMappingURL=ScopeChecker.js.map
\No newline at end of file