Skip to content

Fix a Firefox crash from a WebKit-only scrollbar selector - #25

Merged
JedimEmO merged 1 commit into
mainfrom
fix-firefox-crash
Jul 25, 2026
Merged

Fix a Firefox crash from a WebKit-only scrollbar selector#25
JedimEmO merged 1 commit into
mainfrom
fix-firefox-crash

Conversation

@JedimEmO

Copy link
Copy Markdown
Owner

The deployed site renders a blank page in Firefox on every routehttps://jedimemo.github.io/dwind/examples/#/

Cause

slim_scrollbar is applied to the app root (lib.rs:61), and it used [&::-webkit-scrollbar-thumb:hover]:. Firefox tolerates the unknown pseudo-element on its own but rejects it with a pseudo-class appended, so insertRule throws — and dominator panics rather than skipping the rule:

// dominator/src/dom.rs:1691
} else {
    // TODO maybe make this configurable
    panic!("selectors are incorrect:\n  {}", failed.join("\n  "));
}

That kills the app mid-construction. Firefox before the fix:

hasHeader: false, hasMain: false, h1: null, bodyText: "", styleSheets: 12

after:

hasHeader: true,  hasMain: true,  h1: "Styling forged at compile time.", styleSheets: 21

This is a regression from #23. A raw stylesheet drops an unparseable rule silently, so the same selector was harmless in styles.rs. Moving a selector into a class makes an unsupported one fatal — that trade wasn't obvious to me when I made it, and it's the kind of thing only a second engine catches.

Fix

The pseudo-elements aren't needed: Firefox has supported scrollbar-width/scrollbar-color since 64, Chrome since 121. The mixin now uses the standard properties alone.

Bisect

A disposable probe narrowed it precisely — the bare pseudo-element is fine, only the :hover combination throws:

selector Firefox
[&::-webkit-scrollbar]:[width:10px] ok
[&::-webkit-scrollbar-track]:[background:transparent] ok
[&::-webkit-scrollbar-thumb]:[background:#26262C] ok
[&::-webkit-scrollbar-thumb:hover]:[background:#3A3A44] FAIL
[scrollbar-color:#26262C transparent] ok

Guarding against a repeat

Adds browser tests pinning every selector shape the example applies — the spotlight ::before/::after pair with its masks, the reveal cascade's parent-state and :nth-child variants, the marquee's [&:hover > *], and the scrollbar properties. CI runs both Firefox and Chrome, so an engine that rejects any of them now fails the build rather than the page.

Also documents the hazard in the changelog: with variants now able to express selectors a stylesheet used to hold, an unsupported one is fatal instead of ignored.

Verification

  • Reproduced and fixed in real Firefox via geckodriver, across five routes
  • Full wasm suite under both Firefox and Chrome
  • cargo fmt --all -- --check, host tests, clippy

🤖 Generated with Claude Code

The deployed site rendered a blank page in Firefox on every route.

`slim_scrollbar` is applied to the app root, and it used
`[&::-webkit-scrollbar-thumb:hover]:`. Firefox tolerates the unknown
pseudo-element on its own but rejects it with a pseudo-class appended, so
`insertRule` throws — and dominator panics rather than skipping the rule
(dom.rs:1691), killing the app mid-construction. Firefox reported
hasHeader=false, hasMain=false, empty body, 12 stylesheets instead of 21.

This is a regression from moving the scrollbar styling out of styles.rs:
a raw stylesheet drops an unparseable rule silently, so the same selector
was harmless there. Making a selector into a class makes an unsupported
one fatal.

The pseudo-elements are not needed anyway — Firefox has supported
scrollbar-width/scrollbar-color since 64 and Chrome since 121 — so the
mixin now uses the standard properties alone.

Adds browser tests pinning every selector shape the example applies.
Since CI runs both Firefox and Chrome, an engine that rejects any of them
now fails the build instead of the page. Bisected with a disposable probe
first: the bare pseudo-element, the track and the thumb all insert fine;
only the thumb-plus-:hover form throws.

Verified in real Firefox via geckodriver, before and after, across five
routes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@JedimEmO
JedimEmO merged commit f324516 into main Jul 25, 2026
1 check passed
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