From d94f4661442b732f77633d5801ae13cd57b34588 Mon Sep 17 00:00:00 2001 From: Sherry Date: Thu, 30 May 2024 14:03:40 +0800 Subject: [PATCH] [lexical-code] Refactor: remove unnecessary type casting (#6202) --- packages/lexical-code/src/CodeNode.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/lexical-code/src/CodeNode.ts b/packages/lexical-code/src/CodeNode.ts index 1fb5701a1c2..0578661d35d 100644 --- a/packages/lexical-code/src/CodeNode.ts +++ b/packages/lexical-code/src/CodeNode.ts @@ -144,11 +144,11 @@ export class CodeNode extends ElementNode { } : null; }, - div: (node: Node) => ({ + div: () => ({ conversion: $convertDivElement, priority: 1, }), - pre: (node: Node) => ({ + pre: () => ({ conversion: $convertPreElement, priority: 0, }), @@ -324,11 +324,8 @@ export function $isCodeNode( return node instanceof CodeNode; } -function $convertPreElement(domNode: Node): DOMConversionOutput { - let language; - if (isHTMLElement(domNode)) { - language = domNode.getAttribute(LANGUAGE_DATA_ATTRIBUTE); - } +function $convertPreElement(domNode: HTMLElement): DOMConversionOutput { + const language = domNode.getAttribute(LANGUAGE_DATA_ATTRIBUTE); return {node: $createCodeNode(language)}; }