From 371ad098d55058ffc2672aa083ade830c53a281b Mon Sep 17 00:00:00 2001 From: AleksanderBodurri Date: Sun, 25 Aug 2024 20:09:43 -0400 Subject: [PATCH] fix(devtools): ignore DOM Nodes from other frames when performing render tree detection (#57518) Previously, if an application had DOM Nodes injected into it from other frames, DevTools would fail to parse component trees with the render tree strategy properly because of an instanceof Node check that the framework performs. Now we check for instanceof Node before even calling framework debug APIs on DOM nodes so that we can skip nodes that come from other frames entirely. PR Close #57518 --- .../src/lib/directive-forest/render-tree.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/devtools/projects/ng-devtools-backend/src/lib/directive-forest/render-tree.ts b/devtools/projects/ng-devtools-backend/src/lib/directive-forest/render-tree.ts index 754c2c321e7..5f5c84ae171 100644 --- a/devtools/projects/ng-devtools-backend/src/lib/directive-forest/render-tree.ts +++ b/devtools/projects/ng-devtools-backend/src/lib/directive-forest/render-tree.ts @@ -19,6 +19,11 @@ const extractViewTree = ( getComponent: (element: Element) => {} | null, getDirectives: (node: Node) => {}[], ): ComponentTreeNode[] => { + // Ignore DOM Node if it came from a different frame. Use instanceof Node to check this. + if (!(domNode instanceof Node)) { + return result; + } + const directives = getDirectives(domNode); if (!directives.length && !(domNode instanceof Element)) { return result;