From da5fa3571aa98f5022d1e536e650546d7b5dc7d6 Mon Sep 17 00:00:00 2001 From: Sherry Wong Date: Thu, 19 Sep 2024 15:24:02 +0800 Subject: [PATCH] . --- packages/lexical/src/LexicalUtils.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/lexical/src/LexicalUtils.ts b/packages/lexical/src/LexicalUtils.ts index d4b11303222..9d0ab510135 100644 --- a/packages/lexical/src/LexicalUtils.ts +++ b/packages/lexical/src/LexicalUtils.ts @@ -1686,6 +1686,17 @@ export function isHTMLElement(x: Node | EventTarget): x is HTMLElement { return x.nodeType === 1; } +/** + * @param x - The element being testing + * @returns Returns true if x is a document fragment, false otherwise. + */ +export function isDocumentFragment( + x: Node | EventTarget, +): x is DocumentFragment { + // @ts-ignore-next-line - strict check on nodeType here should filter out non-Element EventTarget implementors + return x.nodeType === 11; +} + /** * * @param node - the Dom Node to check