Skip to content

Commit

Permalink
[lexical-code] Refactor: remove unnecessary type casting (#6202)
Browse files Browse the repository at this point in the history
  • Loading branch information
potatowagon authored May 30, 2024
1 parent 81f8152 commit d94f466
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions packages/lexical-code/src/CodeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
Expand Down Expand Up @@ -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)};
}

Expand Down

0 comments on commit d94f466

Please sign in to comment.