UNPKG

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