Skip to content

fix(w3c/style): always add the dark stylesheet link so the theme toggle appears - #5408

Merged
marcoscaceres merged 2 commits into
mainfrom
fix/5200-firefox-theme-toggle
Aug 19, 2026
Merged

fix(w3c/style): always add the dark stylesheet link so the theme toggle appears#5408
marcoscaceres merged 2 commits into
mainfrom
fix/5200-firefox-theme-toggle

Conversation

@marcoscaceres

@marcoscaceres marcoscaceres commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Closes #5200

W3C's fixup.js only injects the light/dark/auto theme toggle when it finds a dark stylesheet link, since it drives that link's disabled property. Light-only specs never got the link, so the whole block was skipped and no toggle appeared. The link is now always added, disabled when the spec has not opted into dark mode.

Intended consequence worth calling out: a light-only spec now gets a working toggle, so a reader can switch it to dark and the dark stylesheet will apply, on a document that never declared color-scheme. That is deliberate. Readers get the same control they have on every other TR document, and spec authors should not be deciding this on their behalf.

Two implementation notes for review. The link is disabled after insertion rather than before, because per HTML the disabled setter is a no-op while the link's style sheet is still null. And the test asserts only that the link exists, not that it is disabled, since disabled depends on the sheet loading from www.w3.org and would make the test network-dependent; the rel="stylesheet" filter in the selector matters, because a preload hint for the same href is also present.

Verified in Firefox 153, the browser in the bug report: without the fix the sidebar has no dark stylesheet link, no toggle and no radio inputs; with it, the toggle and all three options appear.

Written with AI: this change was generated by Claude. Per AI_POLICY.md.

@marcoscaceres marcoscaceres added the AI Contains AI-generated logic; see AI_POLICY.md label Aug 19, 2026
@marcoscaceres
marcoscaceres requested a lite review from Copilot August 19, 2026 06:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the W3C styling pipeline so a dark.css stylesheet link is always present, ensuring W3C’s fixup.js injects the light/dark/auto theme toggle even for “light-only” specs (closing #5200).

Changes:

  • Always add the W3C dark.css stylesheet link; keep it disabled when the spec hasn’t opted into dark mode via meta[name="color-scheme"].
  • Add a regression test asserting that a rel="stylesheet" dark stylesheet link exists for light-only specs (without asserting disabled to avoid network dependence).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/w3c/style.js Always injects a dark stylesheet link (disabled for light-only specs) so W3C fixup can render the theme toggle.
tests/spec/w3c/style-spec.js Adds a test to ensure light-only specs still get a dark stylesheet link[rel="stylesheet"] so the toggle can appear.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/w3c/style.js Outdated
Comment thread tests/spec/w3c/style-spec.js Outdated
@marcoscaceres
marcoscaceres force-pushed the fix/5200-firefox-theme-toggle branch from e179656 to a711868 Compare August 19, 2026 07:09
@marcoscaceres

Copy link
Copy Markdown
Contributor Author

Confirmed visually. After fix:

Screenshot 2026-08-19 at 5 09 38 PM

@marcoscaceres
marcoscaceres force-pushed the fix/5200-firefox-theme-toggle branch from a711868 to 7c64e2c Compare August 19, 2026 07:24
@marcoscaceres
marcoscaceres marked this pull request as ready for review August 19, 2026 07:27
@marcoscaceres

Copy link
Copy Markdown
Contributor Author

Approving. Reviewed locally fully together with Claude and had copilot check it.

@marcoscaceres
marcoscaceres merged commit 68ac41e into main Aug 19, 2026
9 checks passed
@marcoscaceres
marcoscaceres deleted the fix/5200-firefox-theme-toggle branch August 19, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Contains AI-generated logic; see AI_POLICY.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Theme toggle fails to inject in FireFox

2 participants