From 365a6bd0b933b252d8e6536a81447daf3aa03466 Mon Sep 17 00:00:00 2001 From: Trem Date: Sat, 31 Jul 2021 14:25:18 +0100 Subject: [PATCH] refactor: use helper to check node type --- src/utils/register.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/register.ts b/src/utils/register.ts index 90859c3..036f777 100644 --- a/src/utils/register.ts +++ b/src/utils/register.ts @@ -1,5 +1,6 @@ import { scheduler } from "./scheduler"; import { documentEvents } from './events'; +import { isDocument } from "./element"; /** * Global count of all observed elements. @@ -42,7 +43,7 @@ const mo = new MutationObserver(handleEvent); */ const getDocument = (node: Node): Document | ShadowRoot | null => { const root = node.getRootNode ? node.getRootNode({ composed: node.nodeType === 11 }) : node.ownerDocument; - if (root && root !== node && !(/9|11/).test(root.nodeType.toString())) { + if (root && root !== node && !isDocument(root)) { return getDocument(root); } return root as Document | ShadowRoot | null;