Repository navigation
Description
Summary
Evaluate moving the widget into a shadow root, and decide it with evidence rather than
instinct. #156 shipped a defensive CSS reset that blocks host styles reaching into the widget —
but it has one measured, irreducible gap, and shadow DOM is the only thing that closes it.
The gap the reset cannot close
:where(.sy-atlas) :where(*) { all: revert } blocks non-!important host CSS completely.
Verified in a browser against a deliberately hostile stylesheet: a global button { … },
a { color }, letter-spacing, line-height and font-family are all stopped.
A host rule carrying !important still wins, because an important author declaration beats a
non-important one whatever its specificity. The only way to outrank it from a stylesheet would be
all: revert !important, which would equally beat every rule of ours and render the widget
unstyled — strictly worse than the problem.
Inside a shadow root the question does not arise: host selectors do not match shadow descendants at
all, !important or not. Only inherited properties cross, and those are already handled by the
baseline the reset ships.
What the evaluation must cover
Each of these is a known obstacle, not a hypothetical — they are why the widget is shadow-free
today, and each needs an answer before adopting:
@font-facecannot be registered inside a shadow root in current engines. The widget declares three (src/styles/fonts.ts). Verify current Chrome/Safari behaviour rather than trusting the folklore, and decide where they live if the rest moves.- Every portal target changes.
overlayContainer()(src/lib/overlay.ts) can point at a shadow root, but Radix's dismissible-layer and focus machinery use document-level listeners anddocument.activeElement, which returns the host element across a shadow boundary. Focus trapping, click-outside andEscall route through that. vite-plugin-css-injected-by-jsappends todocument.head, not a shadow root. Changing that has its own gate implications:pnpm assert:cssreads the CSS back out of the emitted bundle, andpostcss-scope-widget.mjsrewrites every selector to:where(.sy-atlas)— which becomes unnecessary inside a shadow root, so the pass and its gate are in scope too.- Mapbox GL has known shadow-root issues with
document.elementFromPoint; the geocoder is itself a shadow-DOM custom element. - ⚠ It does NOT fix vaul's window-height arithmetic, which is the thing map mode actually needs. Adopting shadow DOM would not make map mode containable — that is a separate problem and should not be used to justify this one.
What would justify it
Not "isolation is nicer". One of:
- A host we actually need to support ships
!importantglobal CSS that breaks the widget, and cannot or will not change it. - The reset's measured cost becomes a problem. Today a forced style recalc over 3,200 nodes inside the scope costs ~2× one outside it (41ms vs 20ms across five recalcs, Chrome 151) — accepted because full recalcs are rare and the results list is bounded by
MAX_REVEAL. If that ceiling rises, re-measure.
Absent either, the reset is the right trade and this ticket stays open as the recorded alternative.
Acceptance criteria
- A written decision, with the
@font-faceand Radix-focus questions answered from observed behaviour in current engines rather than from documentation or memory. - If adopted: the scoping pass and
assert:cssare reconciled (either retired or re-aimed), and focus/dismiss/Escare verified in a browser across the boundary. - If declined:
docs/embedding.md's note about!importantstays accurate, and this ticket records what would reopen it.
References
- feat(widget): de-brand the widget and keep host CSS out of it #156 — the reset, its browser verification, and its measured cost
src/styles/globals.css— the reset, and the@layer/contain/transformtraps around it.claude/rules/components.md— the measuredcontain: layout/transformre-parenting table
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Hold Until
Activity
feat(ui): de-brand the widget and keep host CSS out of it (#158)
Ardnived commentedon Aug 29, 2026
@sydevs-bot Investigate this issue, analyze actual performance and maintainability and provide a reasoned verdict on whether we should go ahead with a shadow DOM or close this ticket.
sydevs-bot commentedon Aug 29, 2026
I haven't started this — the ticket carries no
approvedlabel, and that gate covers investigations too. An "evaluate and decide" ticket ends in a written verdict rather than a PR, but it is still work with a real cost, so it queues like anything else. I'm not going to read the request as the gate, and I won't apply the label myself.Flagging that explicitly rather than quietly doing it, because a comment asking for work reads a lot like permission to start, and it isn't. Add
approvedand the next run picks this up.What it would cost, so the label is an informed decision rather than a blank cheque:
This is a browser-verification ticket, not a reading ticket. Your own acceptance criteria are what make it expensive — they require the
@font-faceand Radix-focus answers to come from observed behaviour in current engines rather than from documentation, and that judgement is right: both are areas where the folklore is stale and confidently wrong, and this repo has been bitten by exactly that twice (container-typenot establishing a containing block; mapbox-gl's.d.tscontradicting its own source onfollowUserLocation). So the work is a Playwright session against a real shadow-root prototype, not a survey.Concretely, four things get measured:
@font-faceinside a shadow root — whether current Chrome/Safari still refuse it, and if so whether the three faces insrc/styles/fonts.tscan stay in the host document while everything else moves.document.activeElementreturns the host element from outside a shadow root, and dismissible-layer, focus-trap andEscall route through document-level listeners. This is the one most likely to sink it, and it cannot be answered by reading Radix's source alone.document.elementFromPoint, plus the geocoder, which is itself a shadow-DOM custom element being nested inside another.postcss-scope-widget.mjsandassert:cssexist to prove every rule is confined to.sy-atlas. Inside a shadow root that is structural, so the pass and its gate are either retired or re-aimed. That is a real chunk of the work and it lands whichever way the verdict goes.One question that might settle this far more cheaply, and it's yours to answer rather than mine to measure. The ticket already sets the bar in "What would justify it", and condition (1) is the live one: a host we actually need to support ships
!importantglobal CSS that breaks the widget, and cannot or will not change it.Do we have one? If yes, that is the decision — the reset provably cannot beat an important author declaration without
all: revert !important, which would flatten our own styles too, so shadow DOM is the only remaining answer and the evaluation becomes an implementation plan. If no, condition (2) is the fallback, and it currently reads as "not yet": the measured cost is ~2× a recalc outside the scope (41ms vs 20ms over 3,200 nodes, Chrome 151), accepted because full recalcs are rare and the list is bounded byMAX_REVEAL— and that ceiling has not moved.With no host in category (1) and
MAX_REVEALunchanged, the honest verdict is likely "declined, reset stands, ticket stays open as the recorded alternative" — which is the outcome your own acceptance criteria already anticipate. Worth knowing that before spending a browser session to reach it.I have left the body alone: it is already precise about scope, obstacles and what would justify adoption, and there is nothing in your comment that changes it. It needs the label, not a rewrite.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
Ardnived commentedon Aug 29, 2026
We do not have any known clients that ship
!important, but I don't want to keep this ticket open. We can close it if we don't want to implement.