Skip to content

Commit 00dc13d

Browse files
authored
chore: highlight effect in tree (#17835)
Another QoL improvement to `log_effect_tree` — if you pass an array of effects as the second argument, it will highlight them in the tree. It will also italicise any effects that currently have the `INERT` flag.
1 parent 86ec210 commit 00dc13d

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

  • packages/svelte/src/internal/client/dev

packages/svelte/src/internal/client/dev/debug.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,12 @@ function effect_label(effect, append_effect = false) {
6868

6969
return label;
7070
}
71+
7172
/**
72-
*
7373
* @param {Effect} effect
74+
* @param {Effect[]} highlighted
7475
*/
75-
export function log_effect_tree(effect, depth = 0, is_reachable = true) {
76+
export function log_effect_tree(effect, highlighted = [], depth = 0, is_reachable = true) {
7677
const flags = effect.f;
7778
let label = effect_label(effect);
7879

@@ -86,6 +87,14 @@ export function log_effect_tree(effect, depth = 0, is_reachable = true) {
8687
styles.push(`color: red`);
8788
}
8889

90+
if ((flags & INERT) !== 0) {
91+
styles.push('font-style: italic');
92+
}
93+
94+
if (highlighted.includes(effect)) {
95+
styles.push('background-color: yellow');
96+
}
97+
8998
// eslint-disable-next-line no-console
9099
console.group(`%c${label} (${status})`, styles.join('; '));
91100

@@ -131,7 +140,7 @@ export function log_effect_tree(effect, depth = 0, is_reachable = true) {
131140

132141
let child = effect.first;
133142
while (child !== null) {
134-
log_effect_tree(child, depth + 1, child_is_reachable);
143+
log_effect_tree(child, highlighted, depth + 1, child_is_reachable);
135144
child = child.next;
136145
}
137146

0 commit comments

Comments
 (0)