Commit 4adc5bd
committed
fix(docs): correct chart asset paths; reuse ResizeObserver and destroy old uPlot
Per Gemini review on PR #24.
1. `docs/benchmarks.md` and `docs/assets/bench-charts.js`: `./assets/`
resolves to `/<version>/benchmarks/assets/` under mkdocs
`use_directory_urls` (default true), which 404s — assets actually
live at `/<version>/assets/`. Switch to `../assets/` so the chart
page reaches them via one level up.
2. `.github/workflows/docs.yml` mike-asset verifier: same path bug —
was probing `/dev/benchmarks/assets/bench-results/latest.json` which
would have returned 404 once the snapshot landed (the verify step
only runs on devel push, so the bug wouldn't surface until then).
Aligned with the page's `../assets/` path.
3. `bench-charts.js` ResizeObserver leak on log-scale toggle:
`attachResizeObserver` was called from inside `rebuild()` which
fires on every toggle. Each click left a stranded observer + a
stale `plot` reference its setSize closure was still firing on.
Refactored to a single observer attached after the first build,
which resolves `plot` lazily through a getter — toggle just swaps
the underlying instance.
4. `bench-charts.js` orphaned uPlot DOM/listeners: `rebuild()` mounted
a new uPlot without destroying the previous one. Added
`if (plot) plot.destroy()` at the top of `rebuild()`. Combined with
the observer fix above, the toggle is now state-clean across
arbitrarily many flips.
Syntax-checked bench-charts.js with `node --check`.1 parent 5d1d7e3 commit 4adc5bd
3 files changed
Lines changed: 29 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
30 | | - | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
269 | 271 | | |
270 | 272 | | |
271 | 273 | | |
272 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
273 | 281 | | |
274 | 282 | | |
275 | | - | |
| 283 | + | |
| 284 | + | |
276 | 285 | | |
277 | 286 | | |
278 | 287 | | |
| |||
331 | 340 | | |
332 | 341 | | |
333 | 342 | | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
334 | 348 | | |
335 | 349 | | |
336 | 350 | | |
337 | 351 | | |
338 | 352 | | |
339 | 353 | | |
340 | | - | |
341 | 354 | | |
342 | 355 | | |
343 | 356 | | |
| |||
356 | 369 | | |
357 | 370 | | |
358 | 371 | | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
359 | 378 | | |
360 | 379 | | |
361 | 380 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | | - | |
| 70 | + | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
0 commit comments