Skip to content

Commit 0afbd22

Browse files
authored
Move plugin to visitor API (#93)
1 parent a6a846c commit 0afbd22

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

index.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,24 @@ module.exports = function postcssPrefixSelector(options) {
66
? [].concat(options.includeFiles)
77
: [];
88

9-
return function (root) {
10-
if (
11-
ignoreFiles.length &&
12-
root.source.input.file &&
13-
isFileInArray(root.source.input.file, ignoreFiles)
14-
) {
15-
return;
16-
}
17-
if (
18-
includeFiles.length &&
19-
root.source.input.file &&
20-
!isFileInArray(root.source.input.file, includeFiles)
21-
) {
22-
return;
23-
}
9+
return {
10+
postcssPlugin: 'postcss-prefix-selector',
11+
Rule(rule) {
12+
if (
13+
ignoreFiles.length &&
14+
rule.source.input.file &&
15+
isFileInArray(rule.source.input.file, ignoreFiles)
16+
) {
17+
return;
18+
}
19+
if (
20+
includeFiles.length &&
21+
rule.source.input.file &&
22+
!isFileInArray(rule.source.input.file, includeFiles)
23+
) {
24+
return;
25+
}
2426

25-
root.walkRules((rule) => {
2627
const keyframeRules = [
2728
'keyframes',
2829
'-webkit-keyframes',
@@ -49,7 +50,7 @@ module.exports = function postcssPrefixSelector(options) {
4950

5051
return prefixWithSpace + selector;
5152
});
52-
});
53+
},
5354
};
5455
};
5556

0 commit comments

Comments
 (0)