@@ -102,6 +102,12 @@ export const TViewConstructor = class TView implements ITView {
102102 public firstChild : TNode | null , //
103103 public schemas : SchemaMetadata [ ] | null , //
104104 ) { }
105+
106+ get template_ ( ) : string {
107+ const buf : string [ ] = [ ] ;
108+ processTNodeChildren ( this . firstChild , buf ) ;
109+ return buf . join ( '' ) ;
110+ }
105111} ;
106112
107113export const TNodeConstructor = class TNode implements ITNode {
@@ -161,8 +167,34 @@ export const TNodeConstructor = class TNode implements ITNode {
161167 if ( this . flags & TNodeFlags . isProjected ) flags . push ( 'TNodeFlags.isProjected' ) ;
162168 return flags . join ( '|' ) ;
163169 }
170+
171+ get template_ ( ) : string {
172+ const buf : string [ ] = [ ] ;
173+ buf . push ( '<' , this . tagName || this . type_ ) ;
174+ if ( this . attrs ) {
175+ for ( let i = 0 ; i < this . attrs . length ; ) {
176+ const attrName = this . attrs [ i ++ ] ;
177+ if ( typeof attrName == 'number' ) {
178+ break ;
179+ }
180+ const attrValue = this . attrs [ i ++ ] ;
181+ buf . push ( ' ' , attrName as string , '="' , attrValue as string , '"' ) ;
182+ }
183+ }
184+ buf . push ( '>' ) ;
185+ processTNodeChildren ( this . child , buf ) ;
186+ buf . push ( '</' , this . tagName || this . type_ , '>' ) ;
187+ return buf . join ( '' ) ;
188+ }
164189} ;
165190
191+ function processTNodeChildren ( tNode : TNode | null , buf : string [ ] ) {
192+ while ( tNode ) {
193+ buf . push ( ( tNode as any as { template_ : string } ) . template_ ) ;
194+ tNode = tNode . next ;
195+ }
196+ }
197+
166198const TViewData = ngDevMode && createNamedArrayType ( 'TViewData' ) ;
167199let TVIEWDATA_EMPTY :
168200 unknown [ ] ; // can't initialize here or it will not be tree shaken, because `LView`
@@ -226,8 +258,8 @@ function toHtml(value: any, includeChildren: boolean = false): string|null {
226258 if ( includeChildren || isTextNode ) {
227259 return outerHTML ;
228260 } else {
229- const innerHTML = node . innerHTML ;
230- return outerHTML . split ( innerHTML ) [ 0 ] || null ;
261+ const innerHTML = '>' + node . innerHTML + '<' ;
262+ return ( outerHTML . split ( innerHTML ) [ 0 ] ) + '>' ;
231263 }
232264 } else {
233265 return null ;
@@ -257,6 +289,7 @@ export class LViewDebug {
257289 }
258290 get parent ( ) : LViewDebug | LContainerDebug | null { return toDebug ( this . _raw_lView [ PARENT ] ) ; }
259291 get host ( ) : string | null { return toHtml ( this . _raw_lView [ HOST ] , true ) ; }
292+ get html ( ) : string { return ( this . nodes || [ ] ) . map ( node => toHtml ( node . native , true ) ) . join ( '' ) ; }
260293 get context ( ) : { } | null { return this . _raw_lView [ CONTEXT ] ; }
261294 /**
262295 * The tree of nodes associated with the current `LView`. The nodes have been normalized into a
@@ -267,38 +300,30 @@ export class LViewDebug {
267300 const tNode = lView [ TVIEW ] . firstChild ;
268301 return toDebugNodes ( tNode , lView ) ;
269302 }
270- /**
271- * Additional information which is hidden behind a property. The extra level of indirection is
272- * done so that the debug view would not be cluttered with properties which are only rarely
273- * relevant to the developer.
274- */
275- get __other__ ( ) {
276- return {
277- tView : this . _raw_lView [ TVIEW ] ,
278- cleanup : this . _raw_lView [ CLEANUP ] ,
279- injector : this . _raw_lView [ INJECTOR ] ,
280- rendererFactory : this . _raw_lView [ RENDERER_FACTORY ] ,
281- renderer : this . _raw_lView [ RENDERER ] ,
282- sanitizer : this . _raw_lView [ SANITIZER ] ,
283- childHead : toDebug ( this . _raw_lView [ CHILD_HEAD ] ) ,
284- next : toDebug ( this . _raw_lView [ NEXT ] ) ,
285- childTail : toDebug ( this . _raw_lView [ CHILD_TAIL ] ) ,
286- declarationView : toDebug ( this . _raw_lView [ DECLARATION_VIEW ] ) ,
287- queries : null ,
288- tHost : this . _raw_lView [ T_HOST ] ,
289- bindingIndex : this . _raw_lView [ BINDING_INDEX ] ,
290- } ;
291- }
303+
304+ get tView ( ) { return this . _raw_lView [ TVIEW ] ; }
305+ get cleanup ( ) { return this . _raw_lView [ CLEANUP ] ; }
306+ get injector ( ) { return this . _raw_lView [ INJECTOR ] ; }
307+ get rendererFactory ( ) { return this . _raw_lView [ RENDERER_FACTORY ] ; }
308+ get renderer ( ) { return this . _raw_lView [ RENDERER ] ; }
309+ get sanitizer ( ) { return this . _raw_lView [ SANITIZER ] ; }
310+ get childHead ( ) { return toDebug ( this . _raw_lView [ CHILD_HEAD ] ) ; }
311+ get next ( ) { return toDebug ( this . _raw_lView [ NEXT ] ) ; }
312+ get childTail ( ) { return toDebug ( this . _raw_lView [ CHILD_TAIL ] ) ; }
313+ get declarationView ( ) { return toDebug ( this . _raw_lView [ DECLARATION_VIEW ] ) ; }
314+ get queries ( ) { return this . _raw_lView [ QUERIES ] ; }
315+ get tHost ( ) { return this . _raw_lView [ T_HOST ] ; }
316+ get bindingIndex ( ) { return this . _raw_lView [ BINDING_INDEX ] ; }
292317
293318 /**
294319 * Normalized view of child views (and containers) attached at this location.
295320 */
296321 get childViews ( ) : Array < LViewDebug | LContainerDebug > {
297322 const childViews : Array < LViewDebug | LContainerDebug > = [ ] ;
298- let child = this . __other__ . childHead ;
323+ let child = this . childHead ;
299324 while ( child ) {
300325 childViews . push ( child ) ;
301- child = child . __other__ . next ;
326+ child = child . next ;
302327 }
303328 return childViews ;
304329 }
@@ -359,11 +384,7 @@ export class LContainerDebug {
359384 get movedViews ( ) : LView [ ] | null { return this . _raw_lContainer [ MOVED_VIEWS ] ; }
360385 get host ( ) : RElement | RComment | LView { return this . _raw_lContainer [ HOST ] ; }
361386 get native ( ) : RComment { return this . _raw_lContainer [ NATIVE ] ; }
362- get __other__ ( ) {
363- return {
364- next : toDebug ( this . _raw_lContainer [ NEXT ] ) ,
365- } ;
366- }
387+ get next ( ) { return toDebug ( this . _raw_lContainer [ NEXT ] ) ; }
367388}
368389
369390/**
0 commit comments