Skip to content

Stop the keyboard climb looping on a page that names an element "host" - #1398

Merged
max-sixty merged 2 commits into
mainfrom
host-named-element-climb
Sep 28, 2026
Merged

max-sixty merged 2 commits into
mainfrom
host-named-element-climb

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

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 as document.host, and above in keyboard/dispatch.js climbed with up.parentNode ?? up.host. Past the document it walked back into the page and round again, forever.

#1376 added shadowHost and 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:

  • 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 call shadowHost. They were in anchor-controls, anchor-paint, composing/surface, margin-layout, margin-projection and target-references.
  • documentFocused and margin-layout's anchorElement climbed to the outermost host by hand. Both are now hostIn(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's dispatch.js it hangs rather than fails, because the page's main thread is stuck.
  • Runtime passage tests: add a detached <a href> to upFrom, closestAcross and the reading watcher.

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

🤖 Generated with Claude Code

max-sixty and others added 2 commits September 27, 2026 23:34
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]>
@max-sixty
max-sixty merged commit 058ae4b into main Sep 28, 2026
5 checks passed
@max-sixty
max-sixty deleted the host-named-element-climb branch September 28, 2026 16:37
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