Repository navigation
Stop the keyboard climb looping on a page that names an element "host" - #1398
Merged
Merged
Conversation
A page holding `<form name="host">` (or an img, iframe, embed or object by that name) hung its tab when the thread panel opened: the document names that element as `document.host`, and `above` in keyboard/dispatch.js stepped `up.parentNode ?? up.host`, so past the document it walked back into the page and round again. The shortcut bar asks that climb for the Escape line as soon as the panel's step stands outside the focused toggle. #1376 already gave the runtime `shadowHost` and routed the passage and focus climbs through it, which fixed the detached-`<a>` crash from the Leaves tray (a detached link's root is the link, and its `host` is its URL's). This finishes that cut-over, so every climb asks one primitive whether a root is a shadow root: - `above` steps with `shadowHost`, the same step `under` takes. - `shadowHost` tests the node type rather than `instanceof ShadowRoot`, whose class belongs to one window: an iframe's runtime climbs its parent document's elements in `frameBand`. - The `instanceof ShadowRoot ? root.host` copies in anchor-controls, anchor-paint, composing/surface, margin-layout, margin-projection and target-references call `shadowHost`; arrivals' stage check asks `stages` membership, which already implies a shadow root. - `documentFocused` and margin-layout's `anchorElement` climbed to the outermost host by hand; both are `hostIn(node, document)`. Tests: test_render_navigation opens and closes the panel on a page with `<form name="host">` (hangs with main's dispatch.js); the runtime passage tests add a detached `<a href>` to `upFrom`, `closestAcross` and the reading watcher (they throw on the runtime before #1376). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Sep 28, 2026
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.
A page holding
<form name="host">(or an img, iframe, embed or object by that name) hung its tab when the thread panel opened. The document exposes that element asdocument.host, andaboveinkeyboard/dispatch.jsclimbed withup.parentNode ?? up.host. Past the document it walked back into the page and round again, forever.#1376 added
shadowHostand routed the passage and focus climbs through it. This finishes that cut-over, so every climb asks one primitive whether a root is a shadow root:abovesteps withshadowHost, the same stepundertakes.shadowHosttests the node type rather thaninstanceof ShadowRoot, whose class belongs to one window. An iframe's runtime climbs its parent document's elements inframeBand.instanceof ShadowRoot ? root.hostcopies callshadowHost. They were in anchor-controls, anchor-paint, composing/surface, margin-layout, margin-projection and target-references.documentFocusedand margin-layout'sanchorElementclimbed to the outermost host by hand. Both are nowhostIn(node, document), and both only receive connected nodes.Tests:
test_a_page_element_named_host_leaves_the_keyboard_climb_at_the_document: opens and closes the panel on a page with<form name="host">. With main'sdispatch.jsit hangs rather than fails, because the page's main thread is stuck.<a href>toupFrom,closestAcrossand the reading watcher.🤖 Generated with Claude Code