@cycle/dom
Version:
The standard DOM Driver for Cycle.js, based on Snabbdom
35 lines • 1.4 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var ScopeChecker = /** @class */ (function () {
function ScopeChecker(namespace, isolateModule) {
this.namespace = namespace;
this.isolateModule = isolateModule;
this._namespace = namespace.filter(function (n) { return n.type !== 'selector'; });
}
/**
* Checks whether the given element is *directly* in the scope of this
* scope checker. Being contained *indirectly* through other scopes
* is not valid. This is crucial for implementing parent-child isolation,
* so that the parent selectors don't search inside a child scope.
*/
ScopeChecker.prototype.isDirectlyInScope = function (leaf) {
var namespace = this.isolateModule.getNamespace(leaf);
if (!namespace) {
return false;
}
if (this._namespace.length > namespace.length ||
!utils_1.isEqualNamespace(this._namespace, namespace.slice(0, this._namespace.length))) {
return false;
}
for (var i = this._namespace.length; i < namespace.length; i++) {
if (namespace[i].type === 'total') {
return false;
}
}
return true;
};
return ScopeChecker;
}());
exports.ScopeChecker = ScopeChecker;
//# sourceMappingURL=ScopeChecker.js.map
;