@@ -7,7 +7,7 @@ import type {
77 SerializedElementNode ,
88 Spread ,
99} from 'lexical' ;
10- import { updateDomProps } from '../helpers' ;
10+ import { shallowEqual , updateDomProps } from '../helpers' ;
1111import { BaseElementNode , type BaseElementProps } from './base' ;
1212
1313/**
@@ -52,7 +52,7 @@ export class DivNode extends BaseElementNode<DivNodeProps> {
5252 updateDOM ( prevNode : DivNode , dom : HTMLElement ) : boolean {
5353 const prevProps = prevNode . __props ;
5454 const currentProps = this . __props ;
55- const propsChanged = ! this . shallowEqual ( prevProps , currentProps ) ;
55+ const propsChanged = ! shallowEqual ( prevProps , currentProps ) ;
5656 if ( propsChanged ) {
5757 updateDomProps ( dom , this . getUnderlyingProps ( currentProps ) ) ;
5858 }
@@ -97,10 +97,7 @@ export class DivNode extends BaseElementNode<DivNodeProps> {
9797 ) ;
9898 }
9999
100- getPropValue < K extends keyof DivNodeProps > ( key : K ) : DivNodeProps [ K ] | undefined {
101- return this . __props ?. [ key ] ;
102- }
103- setProps ( props : DivNodeProps ) : void {
100+ updateProps ( props : DivNodeProps ) : void {
104101 const writable = this . getWritable ( ) ;
105102 writable . __props = {
106103 ...writable . __props ,
@@ -111,29 +108,6 @@ export class DivNode extends BaseElementNode<DivNodeProps> {
111108 } ,
112109 } ;
113110 }
114-
115- // eslint-disable-next-line @typescript-eslint/no-explicit-any
116- private shallowEqual ( obj1 : any , obj2 : any ) : boolean {
117- if ( obj1 === obj2 ) return true ;
118- if ( ! obj1 || ! obj2 ) return false ;
119-
120- const keys1 = Object . keys ( obj1 ) ;
121- const keys2 = Object . keys ( obj2 ) ;
122-
123- if ( keys1 . length !== keys2 . length ) return false ;
124-
125- for ( const key of keys1 ) {
126- if ( key === 'style' ) {
127- // - EN: Special handling for style objects.
128- // - CN: 特殊处理 style 对象。
129- if ( ! this . shallowEqual ( obj1 [ key ] , obj2 [ key ] ) ) return false ;
130- } else if ( obj1 [ key ] !== obj2 [ key ] ) {
131- return false ;
132- }
133- }
134-
135- return true ;
136- }
137111}
138112/**
139113 * - EN: Convert a DOM node to a DivNode during import.
0 commit comments