Skip to content

Import shadow-tree helpers from shadow-tree.js, and drop shadow.js's re-exports of them - #6366

Merged
leaf-agent merged 5 commits into
mainfrom
nightly/shadow-tree-imports
Nov 18, 2026
Merged

leaf-agent merged 5 commits into
mainfrom
nightly/shadow-tree-imports

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

browser/runtime/shadow.js re-exported sixteen helpers that browser/runtime/shadow-tree.js owns (under, upFrom, renderedUnder, renderedOrder, renderedOrdering, byRenderedOrder, hostIn, composedParentNode, renderedParent, shadowHost, excludedByInert, overIn, SAID, UI_MARKS, uiInside, inUi). This PR deletes those re-exports and points every import of them in browser/ and tests/runtime/ at shadow-tree.js, including widget-api.js's public under. Now shadow.js keeps only its own exports.

Why: browser/AGENTS.md ("One answer for each question") names shadow-tree.js as the owner of these helpers, but callers were split between the two import paths (for example, 23 imported under through shadow.js and 7 imported it directly). Importing through shadow.js also pulled registry.js and arrivals.js into modules that need neither. No package imports shadow.js.

Verification: pnpm run check passes; it includes test:runtime, 1050/1050 on the head merged with current main. Pre-commit passes on the changed files, including eslint, prettier, dependency-cruiser and knip (unused exports and import cycles). A grep finds no import from shadow.js that names a shadow-tree helper. Behavior is unchanged, so no new test.

Open PRs #6008, #5981 and #5979 touch some of these files; each overlap is a one-line import change.

…re-exports of them

shadow.js re-exported sixteen helpers shadow-tree.js owns (under, upFrom,
renderedUnder, renderedOrder, hostIn, SAID, UI_MARKS and others), so callers
were split between two import paths for one owner, and importing through
shadow.js pulled registry.js and arrivals.js into modules that need neither.
Every import now names shadow-tree.js, and shadow.js keeps only its own exports.
No behavior changes.
@leaf-agent
leaf-agent marked this pull request as draft November 18, 2026 07:05
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Holding this as a draft: it is a mechanical import move, and merged now it would make two approved PRs conflict that merge cleanly with main today, #6346 and #6337 (checked with git merge-tree against each head). Once those land, the next run should rebase this onto main, recheck pnpm run check, and mark it ready. Its own diff has no other pending work.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three comments still say that helpers this PR moves to shadow-tree.js live in shadow.js. That sends readers to the owner browser/AGENTS.md ("One answer for each question") says not to use:

  • browser/runtime/passages.js: "and upFrom, under (shadow.js)," in the header that describes how text nodes are walked
  • browser/runtime/passages.js: "UI_MARKS and SAID (shadow.js, uiInside)" above the marker selectors
  • browser/runtime/resolved-target.js: "by the page's rendered order (shadow.js, renderedOrder, or the renderedOrdering …"

pageShadowRoots (shadow.js) and refuseShadowRoot, shadow.js in passages.js are still correct. These lines fall outside the diff, so there are no inline suggestions. Please fix them in the rebase that comes before marking this ready.

leaf-agent and others added 3 commits November 18, 2026 09:24
…shadow-tree-imports

# Conflicts:
#	browser/runtime/current-target.js
#	browser/runtime/obligations/view.js
# Conflicts:
#	browser/runtime/passages.js
#	browser/runtime/queue-walk.js
@leaf-agent
leaf-agent marked this pull request as ready for review November 18, 2026 22:04
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Ready for review. #6346 and #6337, the two PRs this draft waited on, have both merged. The red test on e4b5c73 was the browser type check failing in browser/runtime/anchor-placement.js (savedAt named placement and reads, which don't exist). This PR doesn't touch that file. Main broke it in #6413 and fixed it in #6420. I merged main into the branch as 931888c. On that head pnpm run check exits 0, with test:runtime passing 1050/1050. No import added on main names a shadow-tree helper through shadow.js, so the diff needed no change.

@leaf-agent
leaf-agent merged commit 941f455 into main Nov 18, 2026
5 checks passed
@leaf-agent
leaf-agent deleted the nightly/shadow-tree-imports branch November 18, 2026 23:09
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.

1 participant