Skip to content

Commit 549231c

Browse files
committed
refactor(core): add dev mode descriptions to foreign view boundaries
Add descriptive text to foreign view head and tail comments in dev mode to assist in debugging.
1 parent d941c13 commit 549231c

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

packages/core/src/render3/foreign_view.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,12 @@ export function createForeignView(lContainer: LContainer, index: number): Foreig
106106
// 5. "Render" the view by creating the head and tail nodes, populating their slots, and marking
107107
// the view as created. This last step is normally handled by `renderView()` for native Angular
108108
// views with template functions.
109-
const headComment = (lView[headTNode.index] = renderer.createComment(''));
110-
const tailComment = (lView[tailTNode.index] = renderer.createComment(''));
109+
const headComment = (lView[headTNode.index] = renderer.createComment(
110+
ngDevMode ? 'foreign-view-head' : '',
111+
));
112+
const tailComment = (lView[tailTNode.index] = renderer.createComment(
113+
ngDevMode ? 'foreign-view-tail' : '',
114+
));
111115
lView[FLAGS] &= ~LViewFlags.CreationMode;
112116

113117
// 6. Insert the view into the container

packages/core/test/render3/foreign_view_spec.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,17 @@ describe('foreign views', () => {
123123
vcr2.insert(viewRef);
124124

125125
expect(fixture.nativeElement.innerHTML).toBe(
126-
'<div></div><!--container--><div></div><!----><span></span><span></span><!----><!--container-->',
126+
'' +
127+
'<div></div>' +
128+
// First <div> container
129+
'<!--container-->' +
130+
'<div></div>' +
131+
// Foreign view
132+
'<!--foreign-view-head-->' +
133+
'<span></span><span></span>' +
134+
'<!--foreign-view-tail-->' +
135+
// Second <div> container
136+
'<!--container-->',
127137
);
128138
});
129139

0 commit comments

Comments
 (0)