Skip to content

Commit

Permalink
Remove sorting altogether
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Jan 17, 2024
1 parent 140e9ae commit 0d06770
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ describe("free style", () => {
const keyframes2 = Style.registerStyle({
$global: true,
"@keyframes &": {
to: { color: "blue" },
from: { color: "red" },
to: { color: "blue" },
},
});

Expand Down
10 changes: 1 addition & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,6 @@ export interface Compiled {
*/
type Tuple<T> = [string, T];

/**
* Sort tuples by key, assuming unique keys (due to the nature of object keys).
*/
function tupleSort<T>(a: Tuple<T>, b: Tuple<T>) {
return a[0] > b[0] ? 1 : -1;
}

/**
* Transform a style string to a CSS string.
*/
Expand Down Expand Up @@ -204,7 +197,6 @@ function stylize(

const isUnique = !!styles.$unique;
const parent = styles.$global ? "" : parentClassName;
const nested = parent ? nestedStyles : nestedStyles.sort(tupleSort);
const style = properties.map(tupleToStyle).join(";");
let pid = style;
let selector = parent;
Expand Down Expand Up @@ -235,7 +227,7 @@ function stylize(
}
}

for (const [name, value] of nested) {
for (const [name, value] of nestedStyles) {
pid += `|${name}#${stylize(
childRules,
childStyles,
Expand Down

0 comments on commit 0d06770

Please sign in to comment.