Skip to content
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 conditional style ordering #893

Merged
merged 7 commits into from
Nov 16, 2022
Merged

Fix conditional style ordering #893

merged 7 commits into from
Nov 16, 2022

Conversation

mattcompiles
Copy link
Contributor

This PR resolves an issue where our conditional style sort algorithm was not implementing the Array.sort spec correctly. It didn't handle conditions that don't have direct relationships to each other.

I have refactored conditionalRulesets to instead store rulesets as a Map (which is ideal for lookups) and then return a correctly sorted ruleset array when requested.

Fixes #874

@changeset-bot
Copy link

changeset-bot bot commented Oct 31, 2022

🦋 Changeset detected

Latest commit: 3d09c6b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@vanilla-extract/css Patch
@fixtures/features Patch
@fixtures/low-level Patch
@fixtures/recipes Patch
@fixtures/sprinkles Patch
@fixtures/themed Patch
@fixtures/unused-modules Patch
vanilla-extract-example-webpack-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mattcompiles mattcompiles enabled auto-merge (squash) November 16, 2022 04:03
const matchingCondition = this.ruleset.find(
(cond) => cond.query === query,
);
for (const { query, rules, children } of incomingRuleset.ruleset.values()) {
Copy link
Contributor

@askoufis askoufis Nov 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment on the line above should now be Merge rulesets into one map, or you could shorten it to Merge rulesets to make it data structure agnostic. Wait nevermind it's still constructing an array.

@mattcompiles mattcompiles merged commit 8ed77c2 into master Nov 16, 2022
@mattcompiles mattcompiles deleted the fix-condition-sorting branch November 16, 2022 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CSS Media Queries are not ordered reliably
2 participants