1 line
755 B
JavaScript
1 line
755 B
JavaScript
"use strict";var e=require("postcss-value-parser");const creator=r=>{const o=Object.assign({preserve:!0},r);return{postcssPlugin:"postcss-overflow-shorthand",Declaration:(r,{result:s})=>{if("overflow"!==r.prop.toLowerCase())return;let t="",a="";const l=r.value;try{const r=e(l).nodes.slice().filter((e=>"comment"!==e.type&&"space"!==e.type));if(r.length<2)return;t=e.stringify(r[0]),a=e.stringify(r[1])}catch(e){return void r.warn(s,`Failed to parse value '${l}' as a shorthand for "overflow". Leaving the original value intact.`)}t&&a&&(t.toLowerCase()===a.toLowerCase()?r.cloneBefore({value:t}):(r.cloneBefore({prop:"overflow-x",value:t}),r.cloneBefore({prop:"overflow-y",value:a})),o.preserve||r.remove())}}};creator.postcss=!0,module.exports=creator;
|