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

Commit a899135

Browse files
committed
Don’t rewrite selections in keyframe at rules
I think this logic is too specific but it seems to work for now
1 parent 3c4d972 commit a899135

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

src/lib/expandApplyAtRules.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,13 @@ function expandApplyAtRules(context) {
117117

118118
for (let [meta, node] of rules) {
119119
let root = postcss.root({ nodes: [node.clone()] })
120+
let canRewriteSelector = node.type !== 'atrule' || (node.type === 'atrule' && node.name !== 'keyframes');
120121

121122
root.walkRules((rule) => {
122-
rule.selector = replaceSelector(apply.parent.selector, rule.selector, applyCandidate)
123+
if (canRewriteSelector) {
124+
rule.selector = replaceSelector(apply.parent.selector, rule.selector, applyCandidate)
125+
}
126+
123127
rule.walkDecls((d) => {
124128
d.important = important
125129
})

tests/10-apply.test.css

+8
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,11 @@
265265
color: green;
266266
font-weight: 700;
267267
}
268+
@keyframes spin {
269+
to {
270+
transform: rotate(360deg);
271+
}
272+
}
273+
.foo {
274+
animation: spin 1s linear infinite;
275+
}

tests/10-apply.test.html

+1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@
3232
<div class="recursive-apply-c"></div>
3333
<div class="use-with-other-properties-base use-with-other-properties-component"></div>
3434
<div class="a b"></div>
35+
<div class="foo"></div>
3536
</body>
3637
</html>

tests/10-apply.test.js

+4
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ test('@apply', () => {
105105
.custom-util {
106106
custom: stuff;
107107
}
108+
109+
.foo {
110+
@apply animate-spin;
111+
}
108112
}
109113
`
110114

0 commit comments

Comments
 (0)