@@ -31,27 +31,31 @@ export class UsfmElementNode extends ElementNode {
3131 return this . getLatest ( ) . __attributes ;
3232 }
3333
34- setAttributes ( attributes : Attributes ) {
34+ setAttributes ( attributes : Attributes ) : this {
3535 const writable = this . getWritable ( ) ;
3636 writable . __attributes = attributes ;
37+ return writable ;
3738 }
3839
3940 getAttribute ( key : string ) : string | undefined {
4041 return this . getLatest ( ) . __attributes [ key ] ;
4142 }
4243
43- setAttribute ( key : string , value : string ) {
44+ setAttribute ( key : string , value : string ) : this {
45+ if ( this . __attributes [ key ] === value ) return this ;
46+
4447 const writable = this . getWritable ( ) ;
4548 writable . __attributes [ key ] = value ;
49+ return writable ;
4650 }
4751
4852 removeAttribute ( key : string ) {
4953 const writable = this . getWritable ( ) ;
5054 delete writable . __attributes [ key ] ;
5155 }
5256
53- setUIAttribute ( key : string , value : string ) {
54- this . setAttribute ( `data-ui-${ key } ` , value ) ;
57+ setUIAttribute ( key : string , value : string ) : this {
58+ return this . setAttribute ( `data-ui-${ key } ` , value ) ;
5559 }
5660
5761 getUIAttribute ( key : string ) : string | undefined {
@@ -79,9 +83,12 @@ export class UsfmElementNode extends ElementNode {
7983 return this . getLatest ( ) . __tag ;
8084 }
8185
82- setTag ( tag : string | undefined ) {
86+ setTag ( tag : string | undefined ) : this {
87+ if ( this . __tag === tag ) return this ;
88+
8389 const writable = this . getWritable ( ) ;
8490 writable . __tag = tag ;
91+ return writable ;
8592 }
8693
8794 exportJSON ( ) : SerializedUsfmElementNode {
0 commit comments