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