Skip to content

Commit

Permalink
fix: hide Node from NodeJS
Browse files Browse the repository at this point in the history
  • Loading branch information
fczbkk committed Mar 17, 2023
1 parent e53457d commit a96ee90
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/utilities-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit a96ee90

Please sign in to comment.