Fix canonicalization resulting in empty list#19812
Conversation
When we canonicalized a set of classes into a new class, then we marked the existing classes as "droppable", meaning they should be removed in favor of the replacement. However, if the replacement is part of the existing class list, it means that we would get rid of everything since the replacement is now marked for removal. Example: ``` w-[calc(1rem+0.25rem)] h-[calc(1rem+0.25rem)] size-5 ``` The w-* and h-* would be collapsed into `w-5 h-5`. Then the result of this would look like: ``` w-5 h-5 size-5 ``` Now the `w-5 h-5` will be collapsed into `size-5`, and `size-5` itself also can be replaced by itself. But this means that `size-5` is marked for removal and the entire class list becomes empty. This fixes that.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
WalkthroughThe change adds new tests to 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📝 Coding Plan
Comment Tip CodeRabbit can use oxc to improve the quality of JavaScript and TypeScript code reviews.Add a configuration file to your project to customize how CodeRabbit runs oxc. |
This PR fixes a bug in the canonicalization process where if a few utilities collapse into a smaller one, and the smaller one is part of the original list, then it results in an empty list.
It will be more clear with an example. Let's say you have this setup:
The first step is that this will result in:
Then the
w-5 h-5can turn intosize-5. But the existingsize-5, can also be replaced by thesize-5.Internally, when we have a replacement, then we mark all the classes that can be replaced as "droppable", so they would be dropped from the list. But in this scenario we also marked
size-5as droppable, resulting in an empty list.If an additional class existed:
The result would be
Instead of the expected:
Test plan