-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix non-deterministic variant sorting #14835
Conversation
We were using `peer-*/parent-name:*` instead of `peer-*/sibling-name:*`
if (aValue === null) return -1 | ||
if (zValue === null) return 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here — none of the tests in variants.test.ts
fail without this code so I don't think this path is actually tested at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this won't ever happen in pratice because:
- In core all our functional variants return null if given no value
matchVariant
— which does support a "default" value has a dedicated compare function
Verifying this did reveal that sorting broken there though so I'm fixing that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed and added a note explaining why this isn't actually necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing these do result in failure of the postcss tests. I think we should figure out why they are failing there and add them to the variants.test.ts
if possible.
Maybe as a dedicated sorting test at the bottom of that file?
let aValue = options?.values?.[a.value.value] ?? a.value.value | ||
let zValue = options?.values?.[z.value.value] ?? z.value.value | ||
let aValueKey = a.value ? a.value.value : 'DEFAULT' | ||
let zValueKey = z.value ? z.value.value : 'DEFAULT' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RobinMalfait I'm not 100% sold that this is the "right" fix. Thoughts?
The |
Fixed the changelog conflict, which in turn triggered the tests again |
) | ||
} | ||
|
||
let classLists = permute(['is-data:flex', 'is-data-foo:flex', 'is-data-bar:flex']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a couple of arbitrary values here as well?
Right now our variant sorting is sensitive to the authoring order of classes or the order in which we scan files because we weren't comparing variant values when sorting.
This PR addresses this by: