Don't generate CSS for less specific utilities when a more specific utility matches #14445
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.