Skip to content

Commit d47d672

Browse files
JeanMecheAndrewKushnir
authored andcommitted
fix(devtools): fix profiler support with @defer blocks (angular#61080)
Prior to this change, the devtools profile logged warnings "Unable to find parent node for ...". PR Close angular#61080
1 parent 1bbf750 commit d47d672

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

devtools/projects/ng-devtools-backend/src/lib/hooks/identity-tracker.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,21 @@ const indexTree = <T extends DevToolsNode<DirectiveInstanceType, ComponentInstan
124124
parentPosition: number[] = [],
125125
): IndexedNode => {
126126
const position = parentPosition.concat([idx]);
127+
128+
// Not every node represents a DOM element (ex @defer blocks), we shouldn't account for them
129+
const children: IndexedNode[] = [];
130+
node.children.forEach((n, i) => {
131+
if (n.nativeElement) {
132+
children.push(indexTree(n, i, position));
133+
}
134+
});
135+
127136
return {
128137
position,
129138
element: node.element,
130139
component: node.component,
131140
directives: node.directives.map((d) => ({position, ...d})),
132-
children: node.children.map((n, i) => indexTree(n, i, position)),
141+
children,
133142
nativeElement: node.nativeElement,
134143
hydration: node.hydration,
135144
defer: node.defer,
@@ -138,4 +147,5 @@ const indexTree = <T extends DevToolsNode<DirectiveInstanceType, ComponentInstan
138147

139148
export const indexForest = <T extends DevToolsNode<DirectiveInstanceType, ComponentInstanceType>>(
140149
forest: T[],
141-
): IndexedNode[] => forest.map((n, i) => indexTree(n, i));
150+
// Not every node represents a DOM element (ex @defer blocks), we shouldn't account for them
151+
): IndexedNode[] => forest.filter((n) => n.nativeElement).map((n, i) => indexTree(n, i));

0 commit comments

Comments
 (0)