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