Repository navigation
Commit 23451a3
fix(toc): break the activeHeading self-cycle in TableOfContentsV2
The effect read `activeHeading` inside the `if (next !== activeHeading)`
guard *and* wrote it unconditionally to `''` at the top of every run.
Reading + writing the same state inside a single effect makes Svelte 5
schedule a re-run that hits the same path — i.e. infinite recursion
flagged as `effect_update_depth_exceeded`. Consumer pages crashed on
hydration once headings populated.
Wrap both the unconditional reset and the guarded write in `untrack`
so the effect doesn't subscribe to its own writes. Template consumers
of `activeHeading` still update because `untrack` only suppresses the
reactive dependency tracking — the assignment itself still notifies
downstream readers.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 70ad2be commit 23451a3
1 file changed
Lines changed: 17 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
40 | 47 | | |
41 | 48 | | |
42 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
43 | 52 | | |
44 | 53 | | |
45 | 54 | | |
| |||
59 | 68 | | |
60 | 69 | | |
61 | 70 | | |
62 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
63 | 77 | | |
64 | 78 | | |
65 | 79 | | |
| |||
0 commit comments