Skip to content

fix(site-plan): treat an omitted stylesheet type as text/css when placing shared chrome - #3842

Merged
chubes4 merged 1 commit into
trunkfrom
fix/shared-chrome-css-type-condition
Oct 31, 2026
Merged

chubes4 merged 1 commit into
trunkfrom
fix/shared-chrome-css-type-condition

Conversation

@chubes4

@chubes4 chubes4 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Shared-chrome projections (rules lifted out of authored stylesheets to style the shared header and footer) get one slot per document per condition. The slot follows the last contributing stylesheet instance with that media/type/device condition (#3572).

The condition key compared type literally. A source that links some stylesheets with type="text/css" and others (or <style> blocks) without a type therefore got two unconditional slots for the same shared-chrome file. The file was enqueued twice under two handles on every page. An omitted type means text/css, so these are one condition.

On a real sports federation site, the shared-chrome stylesheet is 1.1 MB, and every page loaded it twice.

What changed: when placing projections, the slot key normalizes text/css to an omitted type. The placed instance keeps the winning origin's own type attribute. As before, the slot follows the last contributing instance, so nothing changes in the cascade: the earlier copy was always overridden by the later identical one.

Evidence

  • tests/unit/shared-chrome-projection-media-instances.php: a later chrome stylesheet linked with type="text/css" is added.
    • Trunk: two unconditional instances per document (fails).
    • Branch: one per condition, placed after the condition's last contributing link.
  • composer test:canonical, test:parity (352 fixtures), test:packaging, phpcs on the changed files, phpstan: all pass.

AI assistance

The diagnosis, the fix and the test were done by Claude Opus (Pi via Roadie), with Chris's review and approval.

@chubes4
chubes4 merged commit 6145af6 into trunk Oct 31, 2026
15 checks passed
@chubes4
chubes4 deleted the fix/shared-chrome-css-type-condition branch October 31, 2026 01:31
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