Skip to content

Commit 1ebbd04

Browse files
ajoslinahdinosaur
authored andcommitted
Ignore keyframes when prefixing (#7)
Before, keyframe rules would be prefixed, and become invalid css: ``` @Keyframes animation { .prefix from { } .prefix to { } } ``` Now, keyframes are ignored when prefixing.
1 parent 65b90a7 commit 1ebbd04

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ function postcssPrefix (prefix, options) {
88

99
return function (root) {
1010
root.walkRules(function (rule) {
11+
if (rule.parent && rule.parent.type === 'atrule' &&
12+
rule.parent.name.indexOf('keyframes') !== -1) {
13+
return
14+
}
15+
1116
const selector = Selector(
1217
transformSelectors
1318
).process(rule.selector).result

test/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ test('postcss-prefix', function (t) {
1212
.process(css)
1313
.toString()
1414

15-
t.equal(expected, out, 'output is as expected')
15+
t.equal(out, expected, 'output is as expected')
16+
t.end()
17+
})
18+
19+
test('postcss-prefix: keyframes ignored', function (t) {
20+
const css = fs.readFileSync(path.join(__dirname, 'keyframe.css'), 'utf8')
21+
const out = postcss()
22+
.use(prefix('#key'))
23+
.process(css)
24+
.toString()
25+
26+
t.equal(out, css, 'keyframes are not prefixed')
1627
t.end()
1728
})

test/keyframe.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@keyframes fade {
2+
from {
3+
opacity: 0;
4+
}
5+
to {
6+
opacity: 1;
7+
}
8+
}
9+
10+
@-webkit-keyframes fade {
11+
from {
12+
opacity: 0;
13+
}
14+
to {
15+
opacity: 1;
16+
}
17+
}

0 commit comments

Comments
 (0)