Skip to content

docs(comments): five more comments still say the stylesheet lands in the host's <head> #270

Closed

Description

@sydevs-bot

Summary

#264 fixed the two headers explaining the CSS scoping pass. Grepping the rest of the tree for the
same retired premise — that the sheet is appended to the host document's <head> — turns up five
more sites, plus one claim that needs a decision rather than a rewording.

The pattern is the one #264 described: the stated reason is gone, the conclusion is usually
still right, and a maintainer who checks the reason and finds it false could reasonably delete the
code it defends.

Found incidentally while implementing #264.

Approach

Comments only, in five files. The ground truth is src/styles/sheet.ts and
scripts/assert-css-scoped.mjs, which are both already correct.

The mechanism is simply stale — rewrite the clause, keep the conclusion

src/styles/fonts.ts:18

The stylesheet is injected as a string into the host's <head>
(vite-plugin-css-injected-by-js), and a CSS url() resolves against the DOCUMENT's base URL

The conclusion survives and is the whole point of the file: a relative url() in a constructed
stylesheet still resolves against the document base URL, not against our chunk. Only the
"injected into the host's <head>" clause is wrong. Note sheet.ts:21-24 says @font-face is
deliberately not in the adopted sheet and that fonts.ts really does put its own tag in
document.head — so this file is the one place the old mechanism partly still applies. Say which
half is which.

docs/architecture.md:102

CSS is injected by JS (vite-plugin-css-injected-by-js), so the widget styles itself when
embedded.

Imprecise rather than false. The plugin is still in the chain, but with an injectCodeFunction
that parks chunks on globalThis for src/styles/sheet.ts instead of appending a <style>.

The reason is gone and the code may not need defending any more

src/components/molecules/List/List.tsx:50 and its spec List.test.tsx:7

The widget's CSS injects into HOST documents, where a host typography rule on bare ul or li,
such as li { list-style: disc }, beats preflight's inherited reset and paints bullets next to
every card.

A host's li selector cannot match our <li> inside the shadow root at all, so the stated
failure is unreachable for the embed. Decide whether the explicit list-none/m-0/p-0 resets
still earn their place — an inherited list-style-type set on an ancestor of <sahaj-atlas> does
still cross the boundary, which may be a narrower but real reason to keep them — then write
whichever answer is true. List.test.tsx asserts those classes, so its rationale moves with the
decision.

src/styles/base.css:31

This stylesheet is injected into the HOST document, and Swiper is a popular library, so
.swiper roots routinely exist on host pages: theming that selector reaches straight into their
carousels.

Same shape. Keying on .sy-carousel is still the right call for the standalone shell and Ladle,
but the host-carousel hazard it is justified by is gone for the embed.

Needs a decision, not a rewrite

The keyframe-namespacing rationale says a bare @keyframes fadeIn "would hijack any host
animation of that name". It appears three times: scripts/postcss-scope-widget.mjs (the
namespaceKeyframes region), src/styles/globals.css:563, and verbatim in
scripts/assert-css-scoped.mjs. Keyframe names in a sheet adopted into a shadow root are
tree-scoped, so for the embed there is no host collision left to prevent, and the standalone shell
has no host. The namespacing is still required — the shell, Ladle, and the gate that enforces it —
so the work is re-deriving the reason once and writing the same wording to all three, rather
than three divergent rewrites.

scripts/assert-css-scoped.mjs is in scope here even though #264 treated it as the reference: it
is correct about the scoping pass and carries this one stale claim.

Acceptance criteria

  • No comment in src/, scripts/ or docs/ claims the built stylesheet is appended or
    injected into the host document's <head>, except where it is true of
    src/styles/fonts.ts's own <style> tag.
  • src/styles/fonts.ts's header distinguishes its own document.head tag, which is real,
    from the adopted sheet, which is not appended anywhere.
  • List.tsx, List.test.tsx and base.css each state a reason that is true post-fix(ui): host CSS without !important still restyles widget text #236, or
    the code they defend is removed with the reason.
  • The keyframe-collision rationale reads the same in all three files and is true of the embed.
  • Every ⚠ line, #NNN breadcrumb and tool directive in the touched files survives.

Verification checklist

  • grep -rn "injected into the HOST\|HOST document's <head>\|into the host's <head>" src/ scripts/ docs/
    returns only the fonts.ts case, correctly qualified.
  • comment-fingerprint.mjs --base main reports the code hash identical, unless the List
    decision removes code — then say so in the PR body.
  • pnpm build passes, including assert:css.
  • pnpm lint && pnpm typecheck && pnpm test:run pass.

Notes

Unrelated staleness noticed in the same file, worth folding in while there:
scripts/postcss-scope-widget.mjs:65 says :host appears in "Tailwind 3.4's Preflight", and
package.json pins tailwindcss at 4.3.3.

Related, same root cause: #236 is the change that retired the premise, and
#261, #262, #263 and
#264 are the four tickets filed for it so far. This is the fifth, and it is
the in-code comment surface none of them covered.

🤖 Written by the sydevs autonomous loop — see what this is

Activity

  1. added theissue type on Oct 10, 2026
  2. added
    proposal
    on Oct 10, 2026
  3. sydevs-bot commented on Oct 10, 2026

    @sydevs-bot
    ContributorAuthor

    Two more sites for this sweep, found reviewing #269.

    src/AGENTS.md:17 — "The stylesheet lands in a host page, and a host that sets html { font-size: 62.5% } rescales every rem". #269 corrects the twin of this sentence in globals.css's @theme block. None of this ticket's grep terms match "lands in a host page", so it escaped the census. It loads in every session that touches src/.

    The weaker half names a protection the pass cannot give. assert-css-scoped.mjs:8-15 says an unscoped selector in the boundary-less builds "repaints the page around it", implying the pass stops it. The scope class sits on document.documentElement there (index.html:9, .ladle/components.tsx:35), so :where(.sy-atlas) :is(main) matches what main matched. The prefix confines nothing. What the pass does there is collapse the root selectors and namespace the keyframes. Same three files as the keyframe item, so re-derive both in one pass.

    🤖 Written by the sydevs autonomous loop — see what this is


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposal

    Type

    Fields

    Priority

    None yet

    Hold Until

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions