You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
802 B

2 years ago
import e from"postcss-selector-parser";const s=()=>({postcssPlugin:"postcss-selector-not",Rule:(s,{result:o})=>{if(s.selector&&s.selector.indexOf(":not(")>-1)try{const o=e().astSync(s.selector);o.walkPseudos((s=>{if(":not"!==s.value)return;if(!s.nodes||s.nodes.length<2)return;const o=[];s.nodes.forEach((s=>{!function(e){e.spaces&&(e.spaces.after="",e.spaces.before=""),e.nodes&&e.nodes.length>0&&(e.nodes[0]&&e.nodes[0].spaces&&(e.nodes[0].spaces.before=""),e.nodes[e.nodes.length-1]&&e.nodes[e.nodes.length-1].spaces&&(e.nodes[e.nodes.length-1].spaces.after=""))}(s);const t=e.pseudo({value:":not",nodes:[s]});o.push(t)})),s.replaceWith(...o)}));const t=o.toString();t!==s.selector&&(s.selector=t)}catch(e){s.warn(o,`Failed to parse selector "${s.selector}"`)}}});s.postcss=!0;export{s as default};