2 lines
1.3 KiB
JavaScript
2 lines
1.3 KiB
JavaScript
|
import e from"postcss-value-parser";var l=new Map([["block,flow","block"],["block,flow-root","flow-root"],["inline,flow","inline"],["inline,flow-root","inline-block"],["run-in,flow","run-in"],["list-item,block,flow","list-item"],["inline,flow,list-item","inline list-item"],["block,flex","flex"],["inline,flex","inline-flex"],["block,grid","grid"],["inline,grid","inline-grid"],["inline,ruby","ruby"],["block,table","table"],["inline,table","inline-table"],["table-cell,flow","table-cell"],["table-caption,flow","table-caption"],["ruby-base,flow","ruby-base"],["ruby-text,flow","ruby-text"]]);function transform(n){const{nodes:o}=e(n);if(1===o.length)return n;const t=o.filter((e=>"word"===e.type)).map((e=>e.value.toLowerCase()));if(t.length<=1)return n;const i=l.get(t.join(","));return i||n}const n=/^display$/i,creator=e=>{const l=!("preserve"in Object(e))||Boolean(null==e?void 0:e.preserve);return{postcssPlugin:"postcss-normalize-display-values",prepare(){const e=new Map;return{Declaration(o){if(!n.test(o.prop))return;const t=o.value;if(!t)return;if(e.has(t))return void(o.value!==e.get(t)&&(o.cloneBefore({value:e.get(t)}),l||o.remove()));const i=transform(t);e.set(t,i),o.value!==i&&(o.cloneBefore({value:i}),l||o.remove())}}}}};creator.postcss=!0;export{creator as default};
|