Repository navigation
fix: patch through main when a page module moved one of its children - #5505
Merged
Merged
Conversation
A revision rebuilds an element whole when a pass has moved or replaced one of its children (`atomic` in dom-children.js); only the patch root is walked through regardless. #5228 made `body` the patch root, so `main` became an ordinary child, and a page module that relocated or replaced a direct child of `main` now made every revision rebuild the whole page: script-written words, highlighted code spans and nodes a module built were lost. The version controller now names `main` as `traversed`, a new patch rule that reads it as the root was read. The behavior restored: a page module's moves and writes under `main` survive a revision that doesn't mention them, as before #5228. Refs #5475
leaf-agent
added a commit
that referenced
this pull request
Nov 5, 2026
#5506) Since #5228, a page whose `main` leads with an `<h1>` lends that title to every element on the page with no name of its own. The `s` hints announce `div: Split` for a wrapper whose words are its two paragraphs, a chosen list is announced by the page title, and a draft's edit button reads `Edit “Draft source”` instead of `Edit the draft`. This restores the pre-#5228 naming. **Cause.** `addressableLabel` (`browser/runtime/addressable-names.js`) names an unnamed element by the nearest enclosing name, climbing "short of the document it stands in (the page's column, or a message's body)". The climb stops at `authoredScope`, which #5228 widened from `main` to `body` so content beside `main` belongs to the page. That moved the stop one level up, so the climb now asks `main` itself, and `main`'s leading heading is the page's title. **Change.** The climb also stops at `main`, the direct child of `body`. Content beside `main`, such as a site header, still climbs to `body`, and a message body is unaffected. The Python side (`gesture_words.element_name`) doesn't climb, so it needs no change. **Tests.** These failed on main and pass with the change: - `tests/browser/test_render_semantic_selection.py::test_a_boxless_target_is_read_where_it_paints` - `tests/browser/test_render_semantic_selection.py::test_dense_selection_hints_stay_short_and_reach_an_atomic_visual` - `tests/browser/test_render_pages.py::test_ship_review_summary_is_addressable_and_baseline_aligned` - `tests/browser/drafts/test_draft_editing.py::test_a_draft_uses_shared_editing_and_saves_exact_markdown_source` A new case in `tests/runtime/addressable-name.test.mjs` puts a leading `<h1>` in `main` and asserts that it names nothing `main` holds. It fails without the fix and passes with it. #5475 lists twelve tests broken by #5228. Together with #5505 (merged, two tests) and the aim test update, this leaves five still under diagnosis there. Refs #5475 — automated triage Co-authored-by: leaf-agent <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since #5228 made
bodythe root of a live revision's patch, a page module that moves or replaces a direct child ofmainmakes every revision rebuild the whole ofmain: words a script wrote, highlighted code spans and nodes a module built are taken back, and focus and open disclosures survive only through carry. This restores the pre-#5228 behavior formain's children, which is what #5228 meant to keep.Cause. The patch rebuilds an element whole when one of its source children's live nodes no longer stands under it (
atomicinbrowser/runtime/dom-children.js). That guards a pass that took an element's interior, such as the tokenizer replacing a code block's text with spans. The patch root is exempt, since it's walked into, never asked. Before #5228 that root wasmain, so a page module relocating#mv-movedinto its own box, or replacing#clonedwith a copy, was patched around. Withbodyas the root,mainis an ordinary child, and either move makes it atomic.Change. A new patch rule,
traversed(element), names a live element the patch walks through as it walks the root. The version controller namesmain(the direct child ofbody);setRenderedChildrennames nothing.dom-children.jsstill knows no document. Everything else undermainkeeps the atomic rule.Tests. These failed on main and pass with the change:
tests/browser/projection/test_revision_patches.py::test_a_revision_leaves_the_page_everything_it_did_not_writetests/browser/startup/test_versions.py::test_the_diff_marks_what_the_author_changed_and_no_word_a_script_wrote[classic]and[module]The rest of
test_revision_patches.pypasses, apart fromtest_a_revision_releases_the_served_markup_it_removes(3 cases), which fails the same way on unmodified main and isn't one of the tests #5475 tracks.pnpm run test:runtime(818 tests) andpnpm run check:frameworkpass.#5475 lists twelve tests broken by #5228. This fixes two of them; the other ten are still being diagnosed under that issue.
Refs #5475 — automated triage