@@ -66,7 +66,7 @@ export abstract class Tile {
6666
6767 get domAttrs ( ) : Attrs | null { return null }
6868
69- sync ( ) {
69+ sync ( track ?: { node : Node , written : boolean } ) {
7070 this . flags |= TileFlag . Synced
7171 if ( this . flags & TileFlag . AttrsDirty ) {
7272 this . flags &= ~ TileFlag . AttrsDirty
@@ -154,15 +154,17 @@ export abstract class CompositeTile extends Tile {
154154 child . parent = this
155155 }
156156
157- sync ( ) {
157+ sync ( track ?: { node : Node , written : boolean } ) {
158158 if ( this . flags & TileFlag . Synced ) return
159- super . sync ( )
159+ super . sync ( track )
160160 let parent = this . dom , prev : Node | null = null , next
161+ let tracking = track ?. node == parent ? track : null
161162 let length = 0
162163 for ( let child of this . children ) {
163- child . sync ( )
164+ child . sync ( track )
164165 length += child . length + child . breakAfter
165166 next = prev ? prev . nextSibling : parent . firstChild
167+ if ( tracking && next != child . dom ) tracking . written = true
166168 if ( child . dom ! . parentNode == parent ) {
167169 while ( next && next != child . dom ) next = rm ( next )
168170 } else {
@@ -171,6 +173,7 @@ export abstract class CompositeTile extends Tile {
171173 prev = child . dom !
172174 }
173175 next = prev ? prev . nextSibling : parent . firstChild
176+ if ( tracking && next ) tracking . written = true
174177 while ( next ) next = rm ( next )
175178 this . length = length
176179 }
@@ -383,10 +386,13 @@ export class TextTile extends Tile {
383386 super ( dom , text . length )
384387 }
385388
386- sync ( ) {
389+ sync ( track ?: { node : Node , written : boolean } ) {
387390 if ( this . flags & TileFlag . Synced ) return
388- super . sync ( )
389- if ( this . dom . nodeValue != this . text ) this . dom . nodeValue = this . text
391+ super . sync ( track )
392+ if ( this . dom . nodeValue != this . text ) {
393+ if ( track && track . node == this . dom ) track . written = true
394+ this . dom . nodeValue = this . text
395+ }
390396 }
391397
392398 isText ( ) : this is TextTile { return true }
0 commit comments