@@ -104,6 +104,7 @@ export class NewElementBuilder implements ElementBuilder {
104
104
this . env = env ;
105
105
this . dom = env . getAppendOperations ( ) ;
106
106
this . updateOperations = env . getDOM ( ) ;
107
+ this . htmlElementsState = [ ] ;
107
108
}
108
109
109
110
protected initialize ( ) : this {
@@ -205,6 +206,14 @@ export class NewElementBuilder implements ElementBuilder {
205
206
}
206
207
207
208
closeElement ( ) : Nullable < ModifierInstance [ ] > {
209
+ const htmlState = this . htmlElementsState . pop ( ) ;
210
+ if ( htmlState . shouldAddHtmlElement ) {
211
+ this . env . debugRenderTree ?. didRender ( htmlState , {
212
+ parentElement : ( ) => element . parentElement ,
213
+ firstNode : ( ) => element ,
214
+ lastNode : ( ) => element ,
215
+ } ) ;
216
+ }
208
217
this . willCloseElement ( ) ;
209
218
this . popElement ( ) ;
210
219
return this . popModifiers ( ) ;
@@ -247,17 +256,22 @@ export class NewElementBuilder implements ElementBuilder {
247
256
248
257
private pushModifiers ( modifiers : Nullable < ModifierInstance [ ] > ) : void {
249
258
this . modifierStack . push ( modifiers ) ;
250
- if ( ! modifiers && this . env . debugRenderTree ) {
259
+ if ( modifiers && this . env . debugRenderTree ) {
251
260
const htmlState = { } ;
252
- this . env . debugRenderTree ?. create ( htmlState , {
253
- type : 'htmlTag' ,
254
- name : this . element . localName ,
255
- args : {
256
- named : this . element . attrs ,
257
- positional : [ ]
258
- } ,
259
- instance : delegate
260
- } ) ;
261
+ this . htmlElementsState . push ( htmlState ) ;
262
+ const shouldAddHtmlElement = modifiers . length || globalThis . ENV_DEBUG_RENDER_TREE_ALL_ELEMENTS
263
+ htmlState . shouldAddHtmlElement = shouldAddHtmlElement ;
264
+ if ( shouldAddHtmlElement ) {
265
+ this . env . debugRenderTree ?. create ( htmlState , {
266
+ type : 'html-element' ,
267
+ name : this . element . localName ,
268
+ args : {
269
+ named : this . element . attrs ,
270
+ positional : [ ]
271
+ } ,
272
+ instance : delegate
273
+ } ) ;
274
+ }
261
275
for ( const modifier of modifiers ) {
262
276
const state = { } ;
263
277
const name = modifier . definition . resolvedName ;
@@ -275,11 +289,6 @@ export class NewElementBuilder implements ElementBuilder {
275
289
lastNode : ( ) => element ,
276
290
} ) ;
277
291
}
278
- this . env . debugRenderTree ?. didRender ( htmlState , {
279
- parentElement : ( ) => element . parentElement ,
280
- firstNode : ( ) => element ,
281
- lastNode : ( ) => element ,
282
- } ) ;
283
292
}
284
293
}
285
294
0 commit comments