Repository navigation
fix(sdk): a delete is kept hidden when any script lookup could reach it, not only an id - #6165
Conversation
There was a problem hiding this comment.
Verdict: REQUEST CHANGES · 1 blocker · 1 important · 0 nits · head 936e27d9
The class/tag/selector widening is right, but an argument that starts with a literal and continues with an expression is neither "literal" nor "dynamic" here, so the most common generated lookup shape still loses its node. ↓ inline
Scope
Read scriptLookups.ts and the test diff end to end. Ran src/engine/ (229 tests, green) and probed scriptLooksUp directly against a node <div id="word-3" class="item-3 w">:
| script | kept |
|---|---|
getElementById('word-' + i) |
false |
querySelector('#word-' + i) |
false |
getElementsByClassName(\item-${i}`)` |
false |
querySelector(\#word-${i}`)/getElementById(`word-${i}`)` |
true |
querySelectorAll('.w') |
true |
getElementById('nope') |
false |
Mergeability: GitHub reports DIRTY — a test-only append conflict in apply-patches.scriptTargets.test.ts with #6163, so no Actions run exists for this head. Needs a rebase before CI can gate it.
936e27d to
ae5830a
Compare
|
Head ae5830a, rebased on main (#6163 landed), one line per point:
|
Edit accuracy: accurate 271 (base branch 271), smooth 143 of thoseThe gate passes. Quarantined, measured but not gated (0) Unstable (1)
|
What
#6143 keeps a deleted node as a hidden copy when an inline script looks it up, so the script does not throw before its timeline registers. It only recognised a literal
getElementById('x')orquerySelector('#x'). A script that looks the node up by class (.halftone-svg), by tag or attribute selector, or through a variable (document.querySelector(path)over a list of selectors,getElementById(id)in a helper) still lost the node, threw, and the render failed.scriptLooksUpnow keeps the delete hidden when any lookup in the page's inline scripts could reach the node or something inside it:matches/querySelector);Cost: a page with such a script keeps hidden copies of nodes the person deleted. The copies are
display: noneand carry no media sources (separate change), so the render does not paint or fetch them.Why standalone and under the size floor: it touches only the lookup scan and is independent of the media-source change.
Evidence
31 renders of stored compositions with their draft overrides, from one week of failures that a literal id scan did not explain. Each was replayed with the SDK, then loaded in a real browser and its page errors counted.
12 distinct compositions from that set rendered with the CLI after the change, all exit 0, 6 to 44 s.
Tests
apply-patches.scriptTargets.test.ts: a delete is hidden when the script looks it up by class (querySelectorandgetElementsByClassName) or through a variable (selector list, id variable); a delete no lookup can reach is still removed. The first two fail on main. Full SDK suite 667 tests green three runs in a row.