Skip to content

Commit 3c49a82

Browse files
committed
Skip '@Keyframes' rules when parsing selectors #3
1 parent 2c27a10 commit 3c49a82

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ module.exports = function (options) {
88
if (!/\s+$/.test(prefix)) prefix += ' '
99
return function (root) {
1010
root.walkRules(function (rule) {
11+
if (rule.parent && rule.parent.name == 'keyframes') {
12+
return
13+
}
14+
1115
rule.selectors = rule.selectors.map(function (selector) {
1216
if (options.exclude && ~options.exclude.indexOf(selector)) {
13-
return selector;
17+
return selector
1418
}
1519
return prefix + selector
1620
})

test/test.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ it('should avoid prefixing excluded selectors', function () {
3131
assert(~out.indexOf('.hello .a'))
3232
assert(~out.indexOf('.hello .b'))
3333
assert(~out.indexOf('.hello .c'))
34-
assert(out.indexOf('.hello body'))
35-
assert(out.indexOf('.hello .a *:not(.b)'))
34+
assert(!~out.indexOf('.hello body'))
35+
assert(!~out.indexOf('.hello .a *:not(.b)'))
36+
})
37+
38+
it('should skip @keyframes selectors', function () {
39+
var out = postcss().use(prefix({
40+
prefix: '.hello '
41+
})).process('@keyframes anim {from {} to {}}').css
42+
43+
assert(!~out.indexOf('.hello from'))
44+
assert(!~out.indexOf('.hello to'))
3645
})

0 commit comments

Comments
 (0)