Discard invalid classes such as bg-red-[#000]
#13970
Merged
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.
This PR improves the candidate parser by making sure that invalid candidates are discarded earlier.
When using a utility such as
bg-red-500
, then we have to find the actual plugin by finding theroot
. In this case we will try:bg-red-500
, value: null <- No match yetbg-red
, value:500
<- No match yetbg
, value:red-500
<- Bingo,bg
is a known rootHowever, if you are using arbitrary values such as
bg-[#000]
, then we know that everything before the-[#000]
will be the root of the plugin. In this case we can do a direct lookup forbg
.Before this change, this wasn't the case (in v4), which means that we could write
bg-red-[#000]
and it parsed just fine.This PR also adds a test for a case that wasn't covered by any tests, which is when you use a candidate such as
bg-
. This parsed as a root of"bg"
and a value of""
.