fix block strategy

If an element was blocked, its child nodes should also be blocked.
The interactions and mutations on the element and its child nodes
also need to be blocked.
This commit is contained in:
Yanzhen Yu
2018-12-30 21:46:23 +08:00
parent e563dc1638
commit 8f24cb78b3
5 changed files with 256 additions and 6 deletions

View File

@@ -112,3 +112,17 @@ export function getWindowWidth(): number {
(document.body && document.body.clientWidth)
);
}
const BLOCK_CLASS = 'rr-block';
export function isBlocked(node: Node | null): boolean {
if (!node) {
return false;
}
if (node.nodeType === node.ELEMENT_NODE) {
return (
(node as HTMLElement).classList.contains(BLOCK_CLASS) ||
isBlocked(node.parentNode)
);
}
return isBlocked(node.parentNode);
}