Skip to content

Commit 3c4d972

Browse files
committed
Fix order of applied properties
These are now in the order of the apply declaration but still obey the cascade order so pt-/pb- still wins over py- and py still wins over p-
1 parent dfbc228 commit 3c4d972

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/lib/expandApplyAtRules.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ function expandApplyAtRules(context) {
130130
}
131131

132132
// Inject the rules, sorted, correctly
133-
for (let [, sibling] of siblings.sort(([a], [z]) => bigSign(z.sort - a.sort))) {
134-
// `apply.parent` is referring to the node at `.abc` in: .abc { @apply mt-2 }
135-
apply.parent.after(sibling)
136-
}
133+
const nodes = siblings.sort(([a], [z]) => bigSign(a.sort - z.sort)).map(s => s[1])
134+
135+
// `apply.parent` is referring to the node at `.abc` in: .abc { @apply mt-2 }
136+
apply.parent.after(nodes)
137137

138138
// If there are left-over declarations, just remove the @apply
139139
if (apply.parent.nodes.length > 1) {

tests/00-kitchen-sink.test.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ div {
243243
--tw-numeric-fraction: var(--tw-empty, /*!*/ /*!*/);
244244
font-variant-numeric: var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure)
245245
var(--tw-numeric-spacing) var(--tw-numeric-fraction);
246-
--tw-numeric-spacing: tabular-nums;
247246
--tw-ordinal: ordinal;
247+
--tw-numeric-spacing: tabular-nums;
248248
}
249249
.custom-component {
250250
background: #123456;

tests/10-apply.test.css

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111
border-radius: 0.375rem;
1212
--tw-bg-opacity: 1;
1313
background-color: rgba(59, 130, 246, var(--tw-bg-opacity));
14-
padding-top: 0.5rem;
15-
padding-bottom: 0.5rem;
1614
padding-left: 1rem;
1715
padding-right: 1rem;
16+
padding-top: 0.5rem;
17+
padding-bottom: 0.5rem;
1818
}
1919
.class-order {
2020
padding: 2rem;
21-
padding-top: 1.75rem;
22-
padding-bottom: 1.75rem;
2321
padding-left: 0.75rem;
2422
padding-right: 0.75rem;
25-
padding-right: 0.25rem;
23+
padding-top: 1.75rem;
24+
padding-bottom: 1.75rem;
2625
padding-top: 1rem;
26+
padding-right: 0.25rem;
2727
}
2828
.with-additional-properties {
2929
font-weight: 500;
@@ -104,10 +104,10 @@
104104
border-radius: 0.375rem;
105105
--tw-bg-opacity: 1;
106106
background-color: rgba(59, 130, 246, var(--tw-bg-opacity));
107-
padding-top: 0.5rem;
108-
padding-bottom: 0.5rem;
109107
padding-left: 1rem;
110108
padding-right: 1rem;
109+
padding-top: 0.5rem;
110+
padding-bottom: 0.5rem;
111111
}
112112
.multiple-variants:hover,
113113
.selectors-variants:hover {
@@ -149,8 +149,8 @@
149149
--tw-numeric-fraction: var(--tw-empty, /*!*/ /*!*/);
150150
font-variant-numeric: var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure)
151151
var(--tw-numeric-spacing) var(--tw-numeric-fraction);
152-
--tw-numeric-spacing: tabular-nums;
153152
--tw-ordinal: ordinal;
153+
--tw-numeric-spacing: tabular-nums;
154154
--tw-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
155155
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000),
156156
var(--tw-shadow);
@@ -187,18 +187,18 @@
187187
}
188188
.btn {
189189
border-radius: 0.25rem;
190-
padding-left: 1rem;
191-
padding-right: 1rem;
192190
padding-top: 0.5rem;
193191
padding-bottom: 0.5rem;
192+
padding-left: 1rem;
193+
padding-right: 1rem;
194194
font-weight: 700;
195195
}
196196
.btn-blue {
197197
border-radius: 0.25rem;
198-
padding-left: 1rem;
199-
padding-right: 1rem;
200198
padding-top: 0.5rem;
201199
padding-bottom: 0.5rem;
200+
padding-left: 1rem;
201+
padding-right: 1rem;
202202
font-weight: 700;
203203
--tw-bg-opacity: 1;
204204
background-color: rgba(59, 130, 246, var(--tw-bg-opacity));

0 commit comments

Comments
 (0)