Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CSS custom property precedence issue #6907

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

m-akinc
Copy link
Contributor

@m-akinc m-akinc commented Feb 6, 2024

Pull Request

πŸ“– Description

Overriding a design token's value in a stylesheet does not always work. A stylesheet containing custom properties for design tokens is added to adoptedStyleSheets alongside other client-defined stylesheets. If a client attempts to override a design token value for an element in CSS, in most cases the order of stylesheets in adoptedStyleSheets won't matter because of specificity-based precedence. But if the client stylesheet overrides the token property using the selector :host, then whichever stylesheet appears later in adoptedStyleSheets will be the one that wins. It seems that the client CSS's override should always take precedence.

This change causes the special stylesheet for design token CSS properties to always be prepended to adoptedStyleSheets so that client stylesheets take precedence when order matters.

🎫 Issues

N/A

πŸ‘©β€πŸ’» Reviewer Notes

This change was conceived as a workaround to a Chromium bug that affected archives/fast-element-1. See PR #6906 into that branch.

πŸ“‘ Test Plan

One test case added.

βœ… Checklist

General

  • I have included a change request file using $ yarn change
  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

@rajsite
Copy link

rajsite commented Feb 16, 2024

@chrisdholt while we are waiting for reviewers (not sure how long to expect), could the workflows be run to pre-emptively catch any issues?

@rajsite
Copy link

rajsite commented Mar 1, 2024

Of the reviewers who have merged PRs recently @chrisdholt @scomea @radium-v would someone be willing to run the workflow so we can see if the tests pass so we can make progress on this PR?

image

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.

None yet

3 participants