Skip to content

Commit ac0eb23

Browse files
AleksanderBodurrimmalerba
authored andcommitted
fix(devtools): fix incorrect styling of nodes between renders (angular#63979)
Previously, the router tree would not properly clean up css classes placed on nodes which would lead to some nodes being incorrectly visualized after each update. PR Close angular#63979
1 parent 858e37c commit ac0eb23

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

devtools/projects/ng-devtools/src/lib/devtools-tabs/router-tree/router-tree.component.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,19 @@ export class RouterTreeComponent {
163163

164164
private d3NodeModifier(d3Node: SvgD3Node<RouterTreeNode>) {
165165
d3Node.attr('class', (node: RouterTreeD3Node) => {
166-
// Since `node-faded` could pre-exist, drop it if the node is a match.
167-
const classNames = d3Node.attr('class').replace('node-faded', '');
168-
const nodeClasses = [classNames];
166+
// Drop all class labels and recompute them.
167+
const classesToRemove = new Set([
168+
'node-faded',
169+
'node-element',
170+
'node-lazy',
171+
'node-search',
172+
'node-environment',
173+
]);
174+
175+
const nodeClasses = d3Node
176+
.attr('class')
177+
.split(' ')
178+
.filter((cls) => !classesToRemove.has(cls));
169179

170180
if (node.data.isActive) {
171181
nodeClasses.push('node-element');

0 commit comments

Comments
 (0)