Don't generate CSS for less specific utilities when a more specific utility matches#14445
Closed
adamwathan wants to merge 1 commit into
Closed
Don't generate CSS for less specific utilities when a more specific utility matches#14445adamwathan wants to merge 1 commit into
adamwathan wants to merge 1 commit into
Conversation
Member
Author
|
Get the fuck outta here PR. |
adamwathan
added a commit
that referenced
this pull request
Sep 18, 2024
…nset` handler (#14447) Resolves #14440. This PR fixes an issue where registering a custom `inset-shadow-*` utility value in your theme like this: ```css @theme { --inset-shadow-potato: inset 0px 2px 6px #7a4724; } ``` …mistakenly generates both an `inset-shadow-*` and `inset-*` utility with that value: ```css .inset-shadow-potato { inset: inset 0px 2px 6px #7a4724; } .inset-shadow-potato { box-shadow: inset 0px 2px 6px #7a4724; } ``` This replaces #14445 which turns out to not be the ideal solution. Now we just explicitly ignore variables like `--inset-shadow-*` and `--inset-ring-*` in the `inset` handler. Kind of a gross patch but I can live with it because the whole existence of the `--inset-*` key is kind of a backwards compatibility thing anyways. --------- Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com> Co-authored-by: Philipp Spiess <hello@philippspiess.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolves #14440.
This PR fixes an issue where registering a custom
inset-shadow-*utility value in your theme like this:…mistakenly generates both an
inset-shadow-*andinset-*utility with that value:We do this by making sure that when parsing a candidate name like
inset-shadow-potato, we stop trying to find less specific matches as soon as we find any match. So onceinset-shadowmatches as a root withpotatoas a value, we don't try to matchinsetas a root withshadow-potatoas a value.This reverts some of the things we changed in #14231
that we can't for the life of us remember why we changed 🧠Remembered why we didn't want to do this — if we only accept the most specific match it's possible for someone to completely override a core utility without really doing it on purpose.
For example, say for some cursed reason someone wants to change the color of all bold text by doing this:
That will actually remove the
font-weight: bolddeclaration from that utility in this case, because we don't explicitly registerfont-bold. We registerfontand handleboldas a value, so the user-definedfont-boldwill match as more specific, and our handler forfont-*withboldas a value will never run.No one should ever do this, but it does expose this other weird thing where we could refactor internals to use a static utility for a previously functional utility (or vice versa) and change the behavior of user-land code which just doesn't feel right.
Replacing this PR with #14447.