From a96ee9066e0f97435ccdb289a2a2b7b784c60dfe Mon Sep 17 00:00:00 2001 From: Riki Fridrich Date: Fri, 17 Mar 2023 08:11:57 +0100 Subject: [PATCH] fix: hide Node from NodeJS --- src/utilities-options.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/utilities-options.ts b/src/utilities-options.ts index 9eb0bb696..2c0220f79 100644 --- a/src/utilities-options.ts +++ b/src/utilities-options.ts @@ -70,20 +70,17 @@ export function isNode(input: unknown): input is Node { return input instanceof Node; } -const validParentNodeTypes: number[] = [ - Node.DOCUMENT_NODE, - Node.DOCUMENT_FRAGMENT_NODE, // this includes Shadow DOM root - Node.ELEMENT_NODE, -]; - /** * Checks whether provided value is valid ParentNode. */ export function isParentNode(input: unknown): input is ParentNode { - if (!isNode(input)) { - return false - } - return validParentNodeTypes.includes(input.nodeType); + const validParentNodeTypes: number[] = [ + Node.DOCUMENT_NODE, + Node.DOCUMENT_FRAGMENT_NODE, // this includes Shadow DOM root + Node.ELEMENT_NODE, + ]; + + return isNode(input) && validParentNodeTypes.includes(input.nodeType); } /**