Skip to content

Clear a shadow host's light children in shadowStage - #3885

Merged
max-sixty merged 7 commits into
mainfrom
grind/f-shadow-stage-clear
Oct 27, 2026
Merged

max-sixty merged 7 commits into
mainfrom
grind/f-shadow-stage-clear

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

shadowStage now clears the host's light children itself, child by child. Three widgets cleared their own host with replaceChildren(); in WebKit that unloads every iframe in the host's shadow tree (#3852 fixed only lf-diff). The replaceChildren() calls in lf-diff.js, lf-file-editor.js and lf-file-tree.js are gone, along with #3852's local workaround in lf-diff, so a widget has nothing to remember. notes/browser-support.md now names shadowStage as the one place a host is cleared. dist/kernel is rebuilt for shadow-stage.js.

Call (reversible): the clear is unconditional (option a). An x-shadow widget slots none of its authored children, and sparing slotted ones depended on a slot existing at stage time, which the documented stage-a-container-then-render pattern breaks. skills/leaf/references/module-authoring.md ("Shadow stages and styles") now says the stage removes authored children, so a widget reads them first. Every in-tree caller already does: the three widgets above, the runtime's failure box for a staged widget (widget-upgrade.js), and the feature gallery's lf-conversation-workspace, which authors no children.

Tests: the two passage-boundaries tests that slot content now add it after staging, and the first asserts the words exist so its doesNotMatch is not vacuous.

Ran after merging main: pnpm run check (runtime 668 pass), tests/browser/widgets/test_diffs.py -k line_thread_where_it_stands (Chromium and WebKit), and the file-editor, file-tree and diff-revision selections of test_render_files.py, test_render_diff_controls.py and test_diffs.py. Not run: a WebKit test for lf-file-editor or lf-file-tree frames.

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 6 commits October 24, 2026 20:32
Each revision of a diff unloaded any iframe in its line threads in WebKit:
the frame stayed connected with a null contentWindow. `show()` cleared the
host's light DOM with `this.replaceChildren()` on every rendering, and
WebKit's `replaceChildren()` on a shadow host unloads every frame in its
shadow tree, even with no child to remove. Removing each child with
`remove()` keeps them, as Chromium and Firefox do in every form.

The TODO blamed this on lf-diff moving outlets beside redrawn rows. A
MutationObserver over the diff's shadow root showed the outlet of a
surviving datum keeps its node and parent through a redrawn own line, an
added line and a file inserted before it; outlets move only when their
datum disappears. So lf-diff leaves that TODO item's list, and the
WebKit gap is recorded in notes/browser-support.md.

test_a_diff_revision_leaves_a_line_thread_where_it_stands runs in
Chromium and WebKit; WebKit fails it with the old clear.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…idget

WebKit's replaceChildren() and textContent = "" on a shadow host unload every
iframe in its shadow tree. #3852 worked around it in lf-diff alone; lf-file-editor
and lf-file-tree still called this.replaceChildren(). shadowStage now removes the
host's light children child by child (sparing those a slot takes, which render), so
a widget no longer clears its own host and the rule cannot be forgotten.

The runtime test for a slotted line break states the assignedSlot happy-dom lacks.
The WebKit gap note points at shadowStage.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
An x-shadow widget slots none of its authored children, and a slot that renders after
the stage (the documented container pattern) would have lost them anyway, so sparing
slotted children was a rule that depended on call order. shadowStage removes them all;
module-authoring.md says to read them first. The two passage-boundaries tests that
slot content now add it after staging, and one asserts the words exist so the
doesNotMatch cannot pass vacuously.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Takes main's TODO.md, whose backlog moved to GitHub issues in #4090.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Rebuilds dist/kernel for shadow-stage.js.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@max-sixty
max-sixty marked this pull request as ready for review October 27, 2026 05:20
Base automatically changed from grind/s-diff-rows to main October 27, 2026 05:28
Resolves lf-diff.js and notes/browser-support.md against #3852's squashed copy by
keeping this branch's side: shadowStage clears the host, so lf-diff's local
child-by-child clear goes. Rebuilds dist/kernel from main's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@max-sixty
max-sixty merged commit 1b8e30e into main Oct 27, 2026
3 of 4 checks passed
@max-sixty
max-sixty deleted the grind/f-shadow-stage-clear branch October 27, 2026 05:51
leaf-agent added a commit that referenced this pull request Oct 27, 2026
The keyed slotted-editor fixture appended its input before
`shadowStage`, so the host cleanup introduced by #3885 removed it before
the test could type. Stage the shadow row first, then append the
generated slotted editor, matching the setup order already used by the
slot passage tests.

This preserves #3885's centralized host cleanup and restores the
existing coverage for handing a draft, focus, and backward caret
selection to a replacement keyed row. No product behavior or assertions
change.

Verified
`tests/browser/test_render_application_boundary.py::test_keyed_shadow_row_restores_replaced_slotted_editor_and_caret
-q -n0`: failed on main at the initial `editor.fill` after 120 seconds;
passed with the fixture correction (6.55 seconds). Earlier CI JUnit
results show the same test passing in run 40452531123 and failing at
that initial fill in run 40459654718; #3885 changed `shadowStage`
between those runs.

Closes #4384 — automated triage

Co-authored-by: leaf-agent <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants