forked from lcoder/postcss-delete-text-decoration-skip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (28 loc) · 749 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
var postcss = require('postcss')
var PROPTDSI = 'text-decoration-skip-ink' ,
TDSIAUTO = 'auto'
/**
* Main function
*/
module.exports = postcss.plugin('postcss-delete-text-decoration-skip', function () {
return function (css) {
css.walkRules(function (rule) {
rule.walkDecls(/^text-decoration-skip$/, function (decl) {
var rule = decl.parent ,
nodes = rule.nodes ,
hasSkipInk = false
nodes.forEach(function (node) {
if ( node.prop === PROPTDSI && node.value === TDSIAUTO ) {
hasSkipInk = true
}
});
if ( decl.value === 'ink' ) {
if ( hasSkipInk === false ) {
rule.insertAfter( decl , { prop: PROPTDSI , value: TDSIAUTO });
}
rule.removeChild( decl )
}
});
});
};
});