index.es.mjs
1.63 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import postcss from 'postcss';
function _toArray(arr) {
return _arrayWithHoles(arr) || _iterableToArray(arr) || _nonIterableRest();
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
const space = postcss.list.space; // overflow shorthand property matcher
const overflowPropertyRegExp = /^overflow$/i;
var index = postcss.plugin('postcss-overflow-shorthand', opts => {
const preserve = 'preserve' in Object(opts) ? Boolean(opts.preserve) : true;
return root => {
// for each overflow declaration
root.walkDecls(overflowPropertyRegExp, decl => {
// split the declaration values
const _space = space(decl.value),
_space2 = _toArray(_space),
overflowX = _space2[0],
overflowY = _space2[1],
invalidatingValues = _space2.slice(2); // if there are two values, but no invalidating values
if (overflowY && !invalidatingValues.length) {
// insert the overflow-* longhand declarations
decl.cloneBefore({
prop: `${decl.prop}-x`,
value: overflowX
});
decl.cloneBefore({
prop: `${decl.prop}-y`,
value: overflowY
}); // conditionally remove the original declaration
if (!preserve) {
decl.remove();
}
}
});
};
});
export default index;
//# sourceMappingURL=index.es.mjs.map