Skip to content
This repository was archived by the owner on Apr 6, 2021. It is now read-only.

Commit 4ca1c2f

Browse files
authored
Merge pull request #3 from tailwindlabs/bug-fixes
Bug fixes / improvements
2 parents bfecd2e + 7af1dd2 commit 4ca1c2f

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/index.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ let env = {
2626
DEBUG: process.env.DEBUG !== undefined,
2727
}
2828

29+
function sign(bigIntValue) {
30+
return (bigIntValue > 0n) - (bigIntValue < 0n)
31+
}
32+
2933
// ---
3034

3135
// This is used to trigger rebuilds. Just updating the timestamp
@@ -261,9 +265,7 @@ function generateRules(tailwindConfig, candidates, context) {
261265
}
262266

263267
function buildStylesheet(rules, context) {
264-
let sortedRules = rules.sort(([a], [z]) => {
265-
return Math.sign(Number(a - z))
266-
})
268+
let sortedRules = rules.sort(([a], [z]) => sign(a - z))
267269

268270
let returnValue = {
269271
components: new Set(),
@@ -1118,13 +1120,7 @@ module.exports = (pluginOptions = {}) => {
11181120
if (appliedSelector !== apply.parent.selector) {
11191121
siblings.push([
11201122
sort,
1121-
toPostCssNode(
1122-
[
1123-
replaceSelector(apply.parent.selector, selector, applyCandidate),
1124-
rule,
1125-
],
1126-
context.postCssNodeCache
1127-
),
1123+
toPostCssNode([appliedSelector, rule], context.postCssNodeCache),
11281124
])
11291125
continue
11301126
}
@@ -1138,7 +1134,7 @@ module.exports = (pluginOptions = {}) => {
11381134
}
11391135

11401136
// Inject the rules, sorted, correctly
1141-
for (let [sort, sibling] of siblings.sort(([a], [z]) => Math.sign(Number(z - a)))) {
1137+
for (let [sort, sibling] of siblings.sort(([a], [z]) => sign(z - a))) {
11421138
// `apply.parent` is refering to the node at `.abc` in: .abc { @apply mt-2 }
11431139
apply.parent.after(sibling)
11441140
}

0 commit comments

Comments
 (0)