Repository navigation
fix(ui): host CSS without !important still restyles widget text - #243
Conversation
A host's ordinary, non-`!important` CSS still restyled widget text. The
`all: revert` reset in `globals.css` was deliberately (0,0,0) so it would stay
under our own Tailwind utilities (0,1,0) — which bounded it above by our rules
while a host's selector was bounded by nothing. Measured across the WordPress
theme fleet, the widget's typeface was lost on 61 of 72 page checks, to rules as
ordinary as `body h2 { font-family }`.
`r2wc(Widget, { shadow: 'open' })` makes that unreachable rather than merely
harder: a host selector cannot match inside a shadow root at any specificity.
The reset retires with it, and so do its two measured costs — a style recalc at
about 2x over the scope, and `all: revert` rolling SVG 2 geometry to its initial
value.
The stylesheet has to move with the subtree it styles, because a document sheet
cannot reach into a shadow root either. `vite.config.ts` hands each CSS chunk to
a sink on `globalThis` instead of appending a `<style>`, and each entry adopts it
into the root it owns. `@font-face` stays in `document.head`, where a face has to
be to apply at all.
Both return-focus captures move to `deepActiveElement()`. Confirmed in Chromium:
`document.activeElement` reports `sahaj-atlas` for anything focused inside, so
closing the report modal would have dropped a keyboard user on the host element.
`Fallbacks.tsx` keeps reading `document.activeElement` — it asks the opposite
question, and the host element answering for our subtree is the answer it needs.
The published `sahaj-atlas-style` tag is gone with the head injection; no client
keys off it. `sahaj-atlas-fonts` is unchanged.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011KsjmeDNmd47t8j6843oUf
… gone `docs/embedding.md` promised that only `!important` got through, and published `sahaj-atlas-style` as stable "precisely because host sites key off them". The shadow root makes the first claim stronger and the second false, so both are rewritten rather than softened: what a host's CSS can and cannot reach, the two things that still cross and why each is meant to, and the removal of the style tag with a pointer at the open shadow root for anyone who was keying off it. `sahaj-atlas-fonts` is documented as staying in the host's document, with the reason — a face registered inside a shadow root is never applied. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_011KsjmeDNmd47t8j6843oUf
Deploying sahajatlas-design with
|
| Latest commit: |
d458af9
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://db6aa0b1.sahajatlas-design.pages.dev |
| Branch Preview URL: | https://claude-fix-236-shadow-dom.sahajatlas-design.pages.dev |
Deploying sahajatlas with
|
| Latest commit: |
d458af9
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://fcb51e04.sahajatlas.pages.dev |
| Branch Preview URL: | https://claude-fix-236-shadow-dom.sahajatlas.pages.dev |
The two return-focus captures moved to `deepActiveElement()` on the strength of one browser observation, and neither the walk nor the capture had a spec. An observation does not survive the session that made it. `active-element.test.ts` asserts the hazard beside the fix: inside an open root `document.activeElement` names the host, so the first spec would pass against a bare `document.activeElement` in an engine that did not retarget. It also covers a nested root, which the geocoder would have been, and the case where the host itself holds focus — a walk that skipped each root's own `activeElement` would answer with the child instead. `store.report-focus.test.ts` covers the capture that drops a keyboard user at the top of the host page when it fails. The load-bearing line is `isConnected`: a node inside a root reaches the document through it, so the boundary does not make the opener look gone. Were that false, every close would return `null` and focus would go nowhere, with nothing throwing. Each spec was confirmed red against its own defect reintroduced at the real site — the walk collapsed to one hop, the walk removed, and `store.ts` reading `document.activeElement` again — then restored. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DouA7ayFHJuXWxpFbYNbqF
Auditing the two map libraries against the shadow root found one live defect. `@mapbox/search-js-web` inserts its `aria-live` region beside its own input, so inside our root, and then reads it back with `document.body.querySelector`. The boundary puts those two on opposite sides, the read is guarded, and so every suggestion count, "no results", and selected-suggestion message stops reaching a screen reader with nothing thrown and nothing logged. The region moves to where the library looks for it. A live region works anywhere in the document and this one carries its own clipping styles, so it travels intact; the alternative was patching a bundled dependency to change one lookup. A MutationObserver rather than a read after mount, because the region appears when the custom element connects, which is not ordered against this component's effects. Each geocoder seeds its own id, so the region is removed on teardown rather than orphaned in the host's body. The rest of the audit is recorded in `docs/rules/mapbox.md` so nobody re-derives it: mapbox-gl 3.30.0 needs no accommodation at all — no `elementFromPoint` anywhere, pointer position computed against a stored element reference, and the window-level drag listeners never reading `e.target`. The geocoder nests no shadow root either, contrary to the premise in #236: eight custom elements, zero `attachShadow`, styles as `<style>` children, and its suggestion listbox mounted on its own `parentElement`. One narrow consequence is accepted and documented — a suggest response re-focuses the input, which can take focus back from the suggestion list mid-keyboard-navigation. `docs/embedding.md` said "there is no shadow DOM" twenty lines above the paragraph introducing the shadow root. That contradiction is fixed, and both it and `CHANGELOG.md` now record the one hidden node the widget adds to a host's body. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DouA7ayFHJuXWxpFbYNbqF
`closest('[aria-live]')` walks past the scope element to the shadow root, so a
library version that stopped wrapping its description would match one of our own
ancestors instead. Hoisting that would move a chunk of the widget into the host's
body, and teardown would then delete it.
The match now has to be a strict descendant of the scope. Confirmed red against
the unbounded walk.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DouA7ayFHJuXWxpFbYNbqF
…rget The `--sy-sheet-top` loop parks after half a second of stillness and is woken by `pointerdown` and `transitionrun` listeners on the host's document. Both tested `event.target` against the sheet, and the shadow root retargets that to `<sahaj-atlas>` — the sheet's own ancestor. So `sheet.contains(target)` was false for the drag and `target !== sheet` true for the snap, and every wake path except `resize` returned early. The visible cost is a stale offset: `EventView`'s sticky Register bar reads `--sy-sheet-top` live, so after a bottom-sheet drag it sat where the sheet used to start until something resized the window. `FallbackRegion`'s max-height reads it too. The filter moves to `wakesSheetLoop`, a pure sibling like `strip-label`, so it can be driven with real events in jsdom rather than by importing vaul and mapbox-gl into the node lane. It reads `composedPath()`: a non-composed event never reaches a document listener from inside a root at all, so the path can only do better than the target, never worse. `resize` still falls through on its target's type. Confirmed red against the two target reads — the drag and the snap both fail, while the three cases that must stay ignored stay green. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DouA7ayFHJuXWxpFbYNbqF
`sheet.test.ts` pinned the sink key and its seed but not the per-chunk field names, and that drift is the silent one. Renaming `css` to `text` in `vite.config.ts` left every spec green and the CSS gate green — it reads the template literal, never the object — while `replaceSync(undefined)` wrote the string "undefined" into every constructed sheet and shipped the widget with no styles at all. Now pinned on both sides, and confirmed red against that rename. `adoptStyles` had no behavioural coverage, so the reason `listeners` exists could not fail: a chunk arriving after a root has adopted is what `relativeCSSInjection` produces on every lazy route. `sheet.adopt.test.ts` drives it in jsdom and covers that, the preservation of a foreign sheet, and the document path the standalone shell takes. Each was confirmed red against its own defect — the listener dropped, and the foreign filter removed. It is a separate file because its sibling reads itself off disk, which jsdom's `import.meta.url` cannot do. ⚠ jsdom 27 constructs a `CSSStyleSheet` and accepts an `adoptedStyleSheets` assignment but supplies no default empty list, so the fixture seeds one and says why. `adoptStyles` reads the property unguarded, which is right — it is Baseline everywhere the widget ships. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DouA7ayFHJuXWxpFbYNbqF
…ree corrections The branch audited the two Mapbox libraries against the shadow root but not the ones behind every drawer and dialog. `@radix-ui/react-focus-scope` listens for `focusin`/`focusout` on `document` and asks `container.contains(event.target)`, which inside a root is always false — the target is the container's own ancestor. `lastFocusedElementRef` is therefore never set, the yank-back focuses nothing, and the `Tab` handler's comparisons against `document.activeElement` can never match. So a MODAL dialog no longer traps focus: tabbing past its last control leaves for the host page. `aria-hidden`'s `hideOthers` degrades the same way, walking `host.children`, which is empty. That is this ticket's stated go/no-go, and it is only half passed. Recorded in `src/components/AGENTS.md` beside the dialog's other keyboard reasoning, with what still works so nobody re-derives it: the dismissable layer decides "inside" from a React capture handler rather than `event.target`, `react-remove-scroll` resolves shadow parents explicitly, and close-focus is ref-based. Only the trap and `aria-hidden` are inert. No fix here — neither library is ours to patch, and the choice between patching them and the ticket's fallback is the reviewer's. Three corrections: `assert-css-scoped.mjs`'s header still opened "The widget has no shadow boundary", sixty-five lines above its own ⚠ saying there is no style tag to scan for any more. It now says what the gate is actually for: the standalone shell and Ladle, which have no boundary and put the same sheet on `<html class="sy-atlas">`. The audit cited `@mapbox/[email protected]`. That is the version of `search-js-react`, which declares `^1.0.0-beta.24` and resolves to **1.6.0** — the file actually read. Every claim holds against it, but a doc whose authority is "read off the installed version" has to name the right one. `hoistGeocoderLiveRegion`'s docblock claimed a region is "removed rather than orphaned". True of unmount, not of a geocoder remounting inside a living `MapSearch`, which leaves its predecessor in the host's body until `MapSearch` itself unmounts. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DouA7ayFHJuXWxpFbYNbqF
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
|
Decision: patch the libraries. Keep the shadow root. Fix the focus trap and screen-reader hiding with
The WordPress plugin's browser lane reads the widget's DOM directly. I'm updating it to read through the shadow root, in a separate sydevs/SahajAtlasWordpress PR, and will post its results against this PR's preview here. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff is the size of the problem. A one-line mount flip plus exactly the consequences it forces — the sheet's new home, two focus reads, the retired reset, two boundary defects found and fixed. Nothing is smuggled in, and every new module traces to the boundary. On scope this is disciplined work.
Two things stand between it and merge. The acceptance evidence cannot be produced as the ticket specifies it, because the lane that produces it cannot see inside a shadow root (blocker below). And the ticket named Phase 1 item 1 the go/no-go and wrote the fallback in advance; it half-failed, and the PR hands the decision up instead. That is a fair call — but the focus audit the decision rests on stops short, so the cost is still understated.
Contracts: the sahaj-atlas-style break is clean — an org-wide search finds the id in no consumer, only in this repo. The host-children contract is the one that went unrecorded.
Findings
- blocker —
sydevs/SahajAtlasWordpresstests/browser.mjs:338doeselement.querySelector('.sy-atlas'), which does not pierce a root. Som.scopeis false, thefitat:472fails on all 18 cells × 4 viewports, and:474returns before the typeface verdict — the lane reports "no .sy-atlas" 72 times, not 0/72. Worse if onlyscopeis fixed::512countsfont === nullas a pass, so a lane that still cannot probe scores a vacuous 0/72.document.elementFromPointalso answers with the host, soinputHitInScope(:371) fails too. That lane needs updating before it can be acceptance evidence; filing it on the plugin repo is the cheap path. - should-fix —
src/components/AGENTS.md:380: "only the trap andaria-hiddenare inert" missesFocusScope's mount auto-focus, which breaks on the same retargeting. Thread names the mechanism and the one exposed surface (the report modal). - should-fix —
docs/embedding.md:964: a host's own children of<sahaj-atlas>stop rendering at element upgrade, andWeMeditateWeb's whole/maproute family is built on them being replaced. Unrecorded in both contract files. - should-fix —
scripts/assert-css-scoped.mjs:10: the stated reason the scoping pass survives is the weak one; the load-bearing reason is unstated, and a reader who accepts the stated one can retire the pass and unstyle the embed. - consider —
src/components/organisms/Mapbox/aria-live.ts:33: this repo already patches a dependency (patches/[email protected]), so the rejected alternative is house practice rather than a last resort. - consider —
src/components/AGENTS.md:372: thearia-hiddenmechanism named is not what the library does, though the conclusion holds.
What was checked
Ticket #236 against the full diff (origin/main...f9c8c35, 25 files). Read whole: styles/sheet.ts, Widget.tsx, main.tsx, vite.config.ts's styleSink, lib/active-element.ts, DrawerStack/sheet-wake.ts, Mapbox/aria-live.ts, styles/globals.css, scripts/assert-css-scoped.mjs, scripts/postcss-scope-widget.mjs, the five new spec files, and the three doc files.
Installed sources, since every claim in the PR body is about one: @radix-ui/[email protected] (focusFirst, handleFocusIn, getTabbableEdges, the mount effect), @radix-ui/[email protected] (confirmed — "inside" comes from a React onPointerDownCapture, not event.target, so the PR's claim holds), @radix-ui/react-dialog (onOpenAutoFocus not prevented; onCloseAutoFocus is ref-based, so close-focus does work), [email protected] (prevents it when autoFocus is false), [email protected], @r2wc/[email protected] (attachShadow in the constructor).
Consumer sides followed: sydevs/SahajAtlasWordpress — tests/browser.mjs measure() and its verdicts, assets/atlas-page.css (targets only the element's own box; unaffected), the printed element (empty, so no light-DOM concern there). sydevs/WeMeditateWeb — pages/map/+Page.tsx, types/sahaj-atlas.d.ts, lib/atlas-embed.ts. Org-wide code search for sahaj-atlas-style: 4 hits, all in this repo.
Not checked: the branch was not built or run, and no browser was used — every Manual-verification item the PR lists as owed is still owed. Reviewer profile read.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
|
The browser lane approves this preview (
The overlays, stacking, hit tests and the compact card pass inside the shadow root. One finding is left, on Enigma at laptop size: the search input and one link use Mapbox Search JS's own system font stack. That's the library's font, not the theme's. ⚠ "61 of 72 page checks" is wrong, and this PR cites it five times: in |
The reviewer's decision on #236: keep the shadow root and patch the two libraries that cannot see through it, rather than accept the regression or fall back to a per-element baseline. `@radix-ui/react-focus-scope` takes its focusin target from `composedPath()[0]`, resolves every `activeElement` read through the boundary, and exempts a `relatedTarget` that is the container's own shadow host — a focusout between two of our own controls retargets too, and would otherwise read as an escape and yank focus back. That also fixes the mount auto-focus, which walked every tabbable because `focusFirst`'s early exit compared the host with itself. `aria-hidden` keeps the real target instead of rewriting it to the host, crosses the boundary in `keep()` through `ShadowRoot.host`, and descends into a kept shadow root in `deep()`. Descending puts the widget's own live regions in the sweep's reach, so the library's issue-10 exemption is collected from the target's root as well as from the document. `[email protected]` needed nothing: it records `getOutermostShadowParent(target)` and matches document-level events against it, and `handleScroll` bubbles through hosts explicitly. Both libraries become pinned devDependencies so the spec imports the same patched instance Radix resolves. Each behavioural assertion was confirmed RED against its own defect reintroduced in the installed bundle, then restored. The focusout half has no behavioural spec and the file says why: its symptom needs the browser's real ordering, which jsdom does not give, and a vacuous pass is worse than none. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01H9G2b2rcv5SxpLtwpbVSdi
…anism Two review threads. "Only the trap and `aria-hidden` are inert" missed `FocusScope`'s mount auto-focus, which breaks on the same retargeting. And the `aria-hidden` mechanism named was not what the library does: it does not walk `host.children`, it stops because `elementsToStop` holds the host. The conclusion held; the mechanism is what a later author reasons from. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01H9G2b2rcv5SxpLtwpbVSdi
`@r2wc/core` attaches the shadow root in the constructor, so light-DOM children are hidden at element upgrade, before `connectedCallback` can decline. With no `<slot>` they never paint, and the duplicate-element return leaves a blank box where a host's fallback used to stay visible. Neither contract file recorded it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01H9G2b2rcv5SxpLtwpbVSdi
"Repaints the page around it" names no third party on the two builds we own whole, so a reader who accepts it can retire the pass and unstyle the embed. The real reason is the root-selector rewrite: there is no `html` inside the shadow root to match. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01H9G2b2rcv5SxpLtwpbVSdi
The docblock rejected a dependency patch as a matter of principle while this repo carries three. The hoist stays, with the reason stated and the patch that would also cover the `activeElement` comparisons named as the follow-up. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01H9G2b2rcv5SxpLtwpbVSdi
|
Decision implemented — both libraries patched (4e47c39)
Also adopted: host children, the gate's reason. Open: the hoist, argued. The browser lane is yours. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
Answered 1. No commit — the answer was already in the tree, so head stays at e3a0d53.
Two threads stay open and both are yours to settle: that one, and the shadow-DOM library. Generated by Claude Code |
Ardnived asked to raise the browser baseline and delete whatever legacy code that frees. Recording the answer at the loop, because the question has now been asked twice and nothing in the tree answered it. CSS anchor positioning is the only candidate for retiring the --sy-sheet-top mirror, and no build.target raise reaches it. caniuse has Firefox at partial support only, so a Firefox floor cannot buy it at any version. anchor() is invalid in the max-h that Fallbacks reads. And it would cover one of the three --sy-sheet-top consumers, leaving the loop running for the other two. build.target is not set in vite.config.ts at all — it rides Vite 8's baseline-widely-available default, verified as chrome111, edge111, firefox114, safari16.4, ios16.4. Pinning a number to raise it would freeze what currently moves forward on its own. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_011qX6rH5eHD2Rz1o2dTtWTr
|
Rebutted 1, asked 1. 2448e6a. Lean gate green: lint, typecheck, 1659 tests.
Which floor, and to buy what? If it is the published one, #247 owns that table. Also open: the shadow-DOM library. Generated by Claude Code |
The recorded reason was wrong on its first clause. caniuse-lite 1.0.30001810, the copy this repo pins, has css-anchor-positioning at FULL support in Chrome and Edge 125+, Firefox 147+, Safari 27+, iOS Safari 26+ — no partial row for any engine. So "Firefox ships only partial support" cannot carry the verdict. The verdict still holds on the reason that does: anchor() is valid only in inset properties, and Fallbacks' CENTERED_BODY reads --sy-sheet-top in max-height. That consumer keeps the loop running at any build.target. The count was wrong too. Two of the three readers are inset reads — the peek strip's top and DrawerFooter's sticky bottom — so converting them trades one mechanism for two and deletes nothing. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018sN6LaUwMPVPooSDAMchDK
|
Rebutted 2. 06a1205. Lean gate green: lint, typecheck, 1659 tests.
Both threads are yours to settle. Generated by Claude Code |
#247 moved the stylesheet to Tailwind 4 CSS-first config and split the #156 defensive reset out into src/styles/host-reset.css. This branch retires that reset, because the shadow root is the boundary now. Both intents are kept: globals.css takes main's v4 part-imports, @source and @theme wholesale, and #236's retirement lands in host-reset.css, where the reset now lives — the `all: revert` rule is gone, the retirement note and the inherited `.sy-atlas` baseline stay, still unlayered and still ahead of preflight. - package.json: both of this branch's pinned patch targets stay, main's @tailwindcss/postcss stays, and `autoprefixer` goes — v4 prefixes through lightningcss, and postcss.config.js no longer loads it. - pnpm-lock.yaml: regenerated from main's lockfile by `pnpm install`. - scripts/audit-baseline.json: main's side. This branch had booked the braces advisory against tailwindcss 3; #247's v4 upgrade took all six paths to it out of the graph, so the list is empty rather than waived. - scripts/postcss-scope-widget.test.ts: this branch's assertions, aimed at host-reset.css, which is where the reset it pins against moved. - CHANGELOG.md and docs/embedding.md: both sides' entries. The exception list is six now — the live region and the @Property registrations are separate facts a host can observe. Gates: lean gate ✓ (135 files, 1665 tests), build ✓ with assert:css (1176 rules, 3 sheets, 62 @Property allowlisted) and assert:maps ✓, `pnpm size` ✓ (standalone 308.2/318, loader 2.7/3.5, embed 310.0/318 KiB), `pnpm audit:check` ✓ (0 new high or critical). Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0117YshqyPTLWEVcZ65d7DHa
|
Merged The reset. #247 split the #156 reset into The audit baseline. This branch waived the braces advisory against tailwindcss 3. v4 took all six paths to it out of the graph, so the list is empty rather than waived — main's side.
Gates: lean ✓ (1665 tests), build ✓ ( 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
…ile (#268) The Dependency Audit job audited every production dependency in the lockfile, so a new advisory against one already on main failed every open PR. From 2026-09-30 to 10-03 it failed #233, #237, #243 and #248, none of which touched a dependency, and fix-ci rewrote overrides and the baseline on those unrelated PRs. The shared Dependency Review job from sydevs/claude-workflow fails only when a PR adds a high or critical runtime advisory. Advisories already on main are the loop's daily Dependabot check's to fix. audit.yml, the baseline and check-audit.mjs go with the old gate. Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
!importantor not.all: revertreset retires, with its 2× style recalc and its SVG-geometry trap. The inherited baseline on.sy-atlasstays — that half was never about selectors.aria-hidden's hiding across the boundary. Without them a modal would not trap focus and a screen reader would not have the rest of the page hidden from it.sahaj-atlas-styleis gone, and a host's own children of<sahaj-atlas>stop rendering.sahaj-atlas-fontsis unchanged. One hiddenaria-livenode is added to the host's<body>.The decision was made — both libraries are patched
The earlier revision of this body handed up a go/no-go: Radix's dismissable layer survives the boundary, but
@radix-ui/react-focus-scopereadsdocument.activeElementandevent.target, both of which retarget to<sahaj-atlas>inside a root, so the trap went inert andaria-hidden'shideOthershid nothing.That is now fixed rather than documented (92ab070).
patches/@[email protected]resolves those reads through the boundary and exempts arelatedTargetequal to our own host;patches/[email protected]keeps the real target and descends into the kept root.[email protected]needed nothing — it already matches againstgetOutermostShadowParent(target).src/lib/shadow-patches.test.tspins the behaviour. ⚠ The focusout half has no behavioural assertion: jsdom will not reproduce the event ordering its symptom needs, so a drift pin stands in.Phases
docs/embedding.md+CHANGELOG.md.Changes
src/Widget.tsx—r2wc(Widget, { shadow: 'open' }), and the root adopts the sheet before React mounts.src/styles/sheet.ts(new) — the CSS sink andadoptStyles(root).vite.config.tshands each chunk to it instead of appending a<style>.patches/(two new) —@radix-ui/react-focus-scopeandaria-hidden, resolved through the boundary.src/lib/active-element.ts(new) —deepActiveElement(), used by the report modal's and the compact card's return-focus captures.src/views/DrawerStack/sheet-wake.ts(new) — the--sy-sheet-topwake filter, reading the composed path instead of a retargetedevent.target.src/components/organisms/Mapbox/aria-live.ts(new) — re-homes the geocoder's live region so its screen-reader announcements still reach a reader.scripts/assert-css-scoped.mjs— re-aimed at the sink: there is no style tag left to scan for.Preview
Both branch aliases are live and answer 200. They serve an earlier commit until Cloudflare rebuilds this push.
sheet.ts). The embed's shadow path is not reachable here:review:embedis local-only.Contract impact
docs/embedding.mdandCHANGELOG.mdboth change in this PR — the style-tag id is a published host contract, a host's own children of the element stop rendering, and the live region is a new node in the host's document.sydevs/SahajAtlasWordpressowns the browser lane that is the acceptance evidence for this fix. It has been re-run against this branch and reports 0 failures on every cell, with the probe corrected in test(browser): read the widget through its shadow root, and judge a preview SahajAtlasWordpress#56.h2, on six themes — not 61 of 72. All five citations are fixed in 43e2580.WeMeditateWeb/lib/atlas-embed.tsand the WordPress templates were not checked from this session — worth a grep before merge.Test results
lint+typecheck+test:run(134 files, 1659 tests)active-element.test.ts,store.report-focus.test.ts,aria-live.test.ts,sheet-wake.test.ts,sheet.adopt.test.tsandsheet.test.ts, plusshadow-patches.test.tsfor the two patches. Every one was confirmed RED against its own defect reintroduced at the real site, then restored — the deep walk collapsed to one hop and removed;store.tsreadingdocument.activeElementagain; the live-region read made once instead of observed, its teardown dropped, itsclosestwalk unbounded; the sheet-wake filter back onevent.target; the sink's listener dropped and its foreign-sheet filter removed; the chunk field renamed across the seam; and each patched site reverted in the bundle.assert:css(1171 rules, 3 sheets) andassert:maps(23 files);pnpm size✓ (standalone 302.1/308, loader 2.7/3.5, embed 303.9/308 KiB — unchanged)comment-lint: clean, 17 filesManual verification
Measured in real Chromium (Playwright, 1280×720) against the built embed on a host page carrying both the
!importantblock and the non-!importantblock:body h2 { font-family: serif; color: rgb(184,131,131) }lands on the host's ownh2while the widget'sh2computesAtlas Rethink Sans/rgb(32,32,32).letter-spacing: normalagainst6px !important;box-sizing: border-boxagainstcontent-box !important; the link neither red nor underlined; SVGfilter: none. A Tailwind utility still wins.Escapecloses it and returns focus to the Settings button; a click at (5, 5) on the host page dismisses it.document.activeElementhazard is confirmed, not assumed: it reportssahaj-atlasfor anything focused inside. Both return-focus captures now usedeepActiveElement(), pinned by specs rather than by this observation.Still owed, and not doable from a sandbox — Chromium here cannot reach any external HTTPS host (the agent proxy's CA is not in its trust store, so every origin fails
ERR_CERT_AUTHORITY_INVALID). These need an attended run or a deploy:store.report-focus.test.ts; Radix performs the focus.Notes for reviewer
Why the two libraries are patched rather than mocked. Every site the focus-scope patch changes is module-internal — the package exports only
FocusScopeandRoot, sofocusFirst,focusand the three event handlers cannot be reached from our code. Two of the changes are new branches rather than substituted reads (therelatedTarget === hostexemption, andaria-hidden's descent into the kept root), which no value-level shim can express at all. The only mock that reaches the reads is overridingDocument.prototype.activeElementandEvent.prototype.target— configurable getters, so it is possible, but they live in the host's realm and would change what every host script sees. A patch is also the loud option: a dependency bump fails the install withERR_PNPM_PATCH_NOT_APPLIED, where a monkey-patch would drift in silence.The review lenses ran, and they earned their keep — four real defects, three fixed.
/security-review: no HIGH or MEDIUM findings, with reasoning rather than mere absence — the CSS sink is a mutable global any script in the host origin can pre-seed, but onmainthat same actor could already append a<style>todocument.headand style every widget element, so the capability delta is zero;shadow: 'open'exposes nothingclosedwould withhold, since onmainthe whole tree sat in the host document; the hoisted live region cannot be made to move a host node, and the library writes it withtextContent, notinnerHTML. A correctness pass over the whole branch found the rest.Fixed, each in its own commit:
--sy-sheet-topwake loop was dead inside the embed. Both listeners sit ondocumentand testedevent.target, so after a bottom-sheet drag the sticky Register bar kept the offset from before the drag until something resized the window. Now readscomposedPath().sheet.test.tsdid not pin the chunk field names. Renamingcsstotextin the sink left every spec and the CSS gate green while shipping the widget completely unstyled. Now pinned, andadoptStyleshas behavioural coverage it had none of.closestwalk was unbounded, so a library version that stopped wrapping its description would have moved a chunk of the widget into the host's body and then deleted it.assert-css-scoped.mjsstill opened "The widget has no shadow boundary"; the audit cited[email protected]when the installed and actually-read version is 1.6.0 (that issearch-js-react's version — the claims all hold, the citation did not); andhoistGeocoderLiveRegion's docblock overstated its own teardown.Not fixed, deliberately: the CSS sink is unversioned. Two different
embed.jsbuilds on one page would cross-feed chunks into one sink, andadoptStylesregisters a listener with no unsubscribe, so a host SPA that re-creates<sahaj-atlas>N times keeps N detached roots alive. Both are bounded — the widget already refuses a second<sahaj-atlas>and a second script is a no-op — and both want the three-literal seam changed or a teardown threaded intodisconnectedCallback. Worth a follow-up, not worth widening this PR unreviewed.Also open: the geocoder's live region is hoisted rather than patched. Now that three patches ship, one patch of
@mapbox/search-js-webwould replace the 65-line hoist and cover the threeactiveElementcomparisonsdocs/rules/mapbox.mdrecords. The hoist is the shipped, spec'd half, so it stays here and the patch is the follow-up — the thread is left open for you.The scoping pass stays rather than retiring, which is the ticket's "retire or re-aim" answered as re-aim. The embed's sheet is behind a boundary now, but the standalone build and Ladle still put it on
<html class="sy-atlas">, so the pass is what keeps those two honest. Retiring the 1,146 lines is a separate, reviewable change, and it would reduce the benefit the ticket counted — worth disagreeing with if you do.src/components/molecules/Fallbacks/Fallbacks.tsxdeliberately does not resolve through the boundary. It readsnode.ownerDocument.activeElementand asks the opposite question — "has the host page got focus somewhere?" — before moving focus to a boot failure. Checked in both directions: inside a root that read answers<sahaj-atlas>for our own elements, which is notbody, so it does not steal focus from a visitor typing in our own search field; and a detached focused node still resets focus tobody, so the steal still fires when it should.Detail
What the library audit found, first-hand. The ticket listed two Mapbox risks as spike questions. Both were folklore older than the installed code.
elementFromPoint: zero occurrences across every dist bundle.document.body,ownerDocument,getRootNode,document.activeElement: zero. Pointer position ismousePos(el, e)→el.getBoundingClientRect()against a stored element reference, and the window-level drag listeners pass the event into it rather than readinge.target, so retargeting cannot reach them. Its only twodocument.fullscreenElementreads belong toFullscreenControl, which this app does not render.@mapbox/[email protected]nests no shadow root. EightcustomElements.definecalls, zeroattachShadow. So the ticket's "the geocoder is itself a shadow-DOM custom element, so it would nest" is false. It styles itself with<style>children of each element, and its onlydocument.headinjection is the autofill-detection sheet, reached fromAddressAutofillandAddressMinimap— neither of which we render. The Geocoder mounts its suggestion listbox on its ownparentElement, inside our root, so our adopted sheet reaches it and host CSS cannot.createAriaLiveElementinserts the live region beside the Geocoder's<input>(inside our root) whilesetLiveRegionMessagereads it back withdocument.body.querySelector. The boundary puts those on opposite sides and the read is guarded, so every suggestion count, "no results", and selected-suggestion message stopped reaching a screen reader with nothing thrown and nothing logged.document.activeElementcomparisons in the geocoder can never be true inside a root. The reachable one: a suggest response findsGeocoder.contains(document.activeElement)false and re-focuses the input, taking focus back from the suggestion list if a response lands while a keyboard user is already arrowing through it. Only fixable by patching the dependency; recorded indocs/rules/mapbox.md.⚠ The fixture in
aria-live.test.tscopies the library, so it was checked against the library. The id suffix, the[aria-live]wrapper, the insertion before the input, and thedocument.body.querySelectorlookup it asserts against were all read off@mapbox/[email protected]'sdist/index-esm.js. The spec uses that file's lookup expression verbatim, so it fails if the fix stops satisfying the real reader rather than a paraphrase of it.docs/embedding.mdcontradicted itself. "The stylesheet is injected into your document — there is no shadow DOM" sat twenty lines above the paragraph introducing the shadow root. Fixed, and the exception list grew the fifth entry it needed for the live region.Why the stylesheet had to move at all. The boundary cuts both ways: a sheet in the host's
<head>cannot reach into a shadow root either. Sovite.config.ts'sinjectCodeFunctionparks each chunk onglobalThisand each entry adopts the sink into the root it owns — the shadow root for the embed, the document for the standalone shell. Ladle is untouched:.ladle/vite.config.tsalready skips the injector and importsglobals.cssdirectly.Three literals span a seam no import crosses.
injectCodeFunctionis stringified into the bundle, so it cannot import the key it writes to, andassert-css-scoped.mjsis a build script that cannot import the TS module either.src/styles/sheet.test.tsreads all three files and fails on drift — thesrc/loader/literals.tspattern, for the same reason #153 needed it. It now pins the chunk field names too, which was the half whose drift was silent.The gate counts injection sites by
data-vite-dev-id, not by the sink key. The key appears insheet.tstoo, as the reader, so a chunk carrying that module counted one site more than it held. That was a real failure on the first build here: 4 sites against 3 stylesheets.HMR would otherwise stack sheets. Vite re-sends a module's CSS on edit, so the sink keys a chunk on
data-vite-dev-idand replaces in place. A build sends each chunk once and carries no id, where position is identity — sound because the sink only appends.@font-facestays indocument.head, and that is not a workaround. A face registered inside a shadow root is never applied.src/styles/fonts.tsalready appended its own tag there and needed no change, which also keeps the'Atlas Rethink Sans'family-name hack load-bearing for exactly the reason it was introduced.⚠ jsdom 27 constructs a
CSSStyleSheetand accepts anadoptedStyleSheetsassignment but supplies no default empty list on a root, sosheet.adopt.test.tsseeds one and says why.adoptStylesreads the property unguarded, which is right — it is Baseline everywhere the widget ships.Measured and unaffected (earlier session, real Chromium):
display: contentson the theme root still computescontents; the fixed layer resolves against the viewport (a shadow root creates no containing block);document.fontscarriesAtlas Rethink Sansand the widget resolves it; 838 rules adopted into the root;adoptedStyleSheetsis empty on the document, so nothing is parsed twice.Also observed, not explained (earlier session): 5 of the 8
<path>nodes present reported a non-zerogetBBox(). The three that did not were not traced to a cause, and the reset's SVG exclusion is moot now that there is no reset — but it was not compared against amainbuild, so it is an observation rather than a clean bill.One tool check did not run.
comment-rule-sync.mjsexpects the five repos as siblings and exits oncanonical rule not found: ../claude-workflow/docs/code-comments.md, which this checkout's layout does not provide. No comment-rule file is in this diff, so nothing was owed to it.Closes #236
🤖 Written by the sydevs autonomous loop — see what this is
🤖 Generated with Claude Code
https://claude.ai/code/session_01DZugACuG6BXhEzkWdpy5W8