atlassian-labs / compiled

A familiar and performant compile time CSS-in-JS library for React.
https://compiledcssinjs.com
Apache License 2.0
1.99k stars 67 forks source link

Fix shorthand sorting buggy #1730

Closed dddlr closed 1 week ago

dddlr commented 1 week ago

What is this change?

Fix the shorthand property sorting being buggy when not using runtime mode (e.g. when using stylesheet extraction).

Why are we making this change?

@kylorhall-atlassian and I noticed that sortShorthand wasn't actually sorting the properties as it should.

It turns out that a lot of the time in the sorting algorithm, the two properties being compared are

As a result, there are cases where the stylesheet would not be sorted at all, simply because the wrong nodes were being compared and so the sortNodes function returns 0 every time.

How are we making this change?

Fix and simplify the sortNodes function:


PR checklist

Don't delete me!

I have...

changeset-bot[bot] commented 1 week ago

🦋 Changeset detected

Latest commit: 8b6edba726e3733b36a0c286bd74f0eb31539f50

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

This PR includes changesets to release 5 packages | Name | Type | | ------------------------------------ | ----- | | @compiled/css | Minor | | @compiled/babel-plugin-strip-runtime | Patch | | @compiled/babel-plugin | Patch | | @compiled/parcel-optimizer | Patch | | @compiled/webpack-loader | 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

netlify[bot] commented 1 week ago

Deploy Preview for compiled-css-in-js canceled.

Name Link
Latest commit 8b6edba726e3733b36a0c286bd74f0eb31539f50
Latest deploy log https://app.netlify.com/sites/compiled-css-in-js/deploys/67183ef7ea580e000836a4d3