Skip to content

Commit 4816bf7

Browse files
authored
[LexicalTextNode] Refactor: remove unnecessary type casting (#6201)
1 parent 41f5738 commit 4816bf7

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/lexical/src/nodes/LexicalTextNode.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,9 +1088,9 @@ export class TextNode extends LexicalNode {
10881088
}
10891089
}
10901090

1091-
function convertSpanElement(domNode: Node): DOMConversionOutput {
1091+
function convertSpanElement(domNode: HTMLSpanElement): DOMConversionOutput {
10921092
// domNode is a <span> since we matched it by nodeName
1093-
const span = domNode as HTMLSpanElement;
1093+
const span = domNode;
10941094
const style = span.style;
10951095

10961096
return {
@@ -1099,9 +1099,11 @@ function convertSpanElement(domNode: Node): DOMConversionOutput {
10991099
};
11001100
}
11011101

1102-
function convertBringAttentionToElement(domNode: Node): DOMConversionOutput {
1102+
function convertBringAttentionToElement(
1103+
domNode: HTMLElement,
1104+
): DOMConversionOutput {
11031105
// domNode is a <b> since we matched it by nodeName
1104-
const b = domNode as HTMLElement;
1106+
const b = domNode;
11051107
// Google Docs wraps all copied HTML in a <b> with font-weight normal
11061108
const hasNormalFontWeight = b.style.fontWeight === 'normal';
11071109

@@ -1271,13 +1273,13 @@ const nodeNameToTextFormat: Record<string, TextFormatType> = {
12711273
u: 'underline',
12721274
};
12731275

1274-
function convertTextFormatElement(domNode: Node): DOMConversionOutput {
1276+
function convertTextFormatElement(domNode: HTMLElement): DOMConversionOutput {
12751277
const format = nodeNameToTextFormat[domNode.nodeName.toLowerCase()];
12761278
if (format === undefined) {
12771279
return {node: null};
12781280
}
12791281
return {
1280-
forChild: applyTextFormatFromStyle((domNode as HTMLElement).style, format),
1282+
forChild: applyTextFormatFromStyle(domNode.style, format),
12811283
node: null,
12821284
};
12831285
}

0 commit comments

Comments
 (0)