PR 2/N: lock in .slidewise-editor CSS scope#6
Merged
karthikmudunuri merged 1 commit intokarthikmudunuri/deck-schema-versioningfrom May 4, 2026
Merged
Conversation
The library is mounted inside host applications that ship their own global stylesheets (Tailwind preflight, normalize.css, app resets). Any rule in our CSS that escapes the .slidewise-editor scope would collide with host styles. Today's CSS already obeys the rule, but nothing prevented a future change from breaking it. Adds a vitest that scans src/SlidewiseEditor.css and rejects any top-level selector that does not start with .slidewise-editor (at-rules like @font-face / @import / @media remain allowed). Verified the test fails on injected violations like `body { … }` and bare `h1` inside a comma-list. Also adds a short header comment to SlidewiseEditor.css pointing at the test so future contributors see the constraint without reading this commit. No production code changes — the lib build (vite build --mode lib) was already excluding the Tailwind plugin and emitting only @font-face plus .slidewise-editor-scoped rules.
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second PR in the integration plan. Stacked on top of #5 — review/merge that first (which itself is stacked on #4).
Summary
The library is mounted inside host applications that ship their own global stylesheets (Tailwind preflight, normalize.css, app resets). Any CSS rule we ship that escapes the
.slidewise-editorscope would collide with host styles either way (we override their resets, or theirs override ours, depending on load order).Today's CSS already obeys the rule and the lib build (
vite build --mode lib) already excludes Tailwind preflight — but nothing prevented a future change from breaking it. This PR adds a regression test.What was audited
src/SlidewiseEditor.cssis nested under.slidewise-editor.tsconfig.lib.json's include list) uses Tailwind utility classes — all styling is via the scoped CSS + inline styles.vite.config.ts:11excludes the Tailwind plugin from the lib build.dist/slidewise.css(afterpnpm build:lib) contains only@font-facerules and.slidewise-editor-scoped rules.What changed
src/lib/__tests__/css-scope.test.ts— vitest that scanssrc/SlidewiseEditor.cssand rejects any top-level selector that doesn't start with.slidewise-editor. At-rules (@font-face,@import,@media,@supports,@keyframes) remain allowed at top level since they don't paint, only register names. Verified the test fails on injected violations likebody { … }and a bareh1inside a comma-list.src/SlidewiseEditor.css— short header comment pointing at the test so future contributors see the constraint inline.Test plan
npx tsc -bcleannpx vitest run— 14/14 (6 roundtrip + 7 migrate + 1 css-scope)pnpm build:libemitsdist/slidewise.cssof 159 kB (font payload) with only.slidewise-editorselectors and@font-faceblocks