Fix CSS custom property precedence issue #6907
Open
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.
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 inadoptedStyleSheets
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 inadoptedStyleSheets
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
$ yarn change