-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (28 loc) · 1021 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var postcss = require("postcss");
module.exports = postcss.plugin("postcss-test-plugin", function() {
return function(root) {
root.walkRules(function(rule) {
var hasOverflowHidden = false;
var hasBorderRadius = false;
rule.walkDecls(/^overflow-?/, function(decl) {
if (decl.value === "hidden") {
hasOverflowHidden = true;
}
});
rule.walkDecls(/border-radius/, function(decl) {
hasBorderRadius = true;
});
if (hasOverflowHidden && hasBorderRadius) {
var maskImage = rule.some(function(i) {
return i.prop === "-webkit-mask-image";
});
if (!maskImage) {
rule.append({
prop: "-webkit-mask-image",
value: "-webkit-radial-gradient(white, black)"
});
}
}
});
};
});