unnestcss
Version:
A library for un-nesting CSS
3 lines (2 loc) • 678 B
JavaScript
import{RULESET as e,COLON as t,LEFT_SQUARE_BRACKET as n,RIGHT_SQUARE_BRACKET as r,PLUS as i,TILDE as a,GREATER_THAN as o,SPACE as s}from"./stylis/enum.js";import{Tokenizer as c}from"./stylis/tokenizer.js";const l=`host`,u=u=>{u.type===e&&u.parent?.value.startsWith(t+l)&&(u.props=u.props.map(e=>{let u=new c(e).tokenize(),d,f=u.length,p=!1;for(let e=0;e<u.length;e++){let c=u[e];switch(c){case t:if(u.length>e+2&&u[e+1]===l){let i=u[e+2];(i===t||i.startsWith(n)&&i.endsWith(r))&&(d=e+2,p=!0)}break;case s:case o:case a:case i:p&&(f=e);break}}return p?`:${l}(${u.slice(d,f).join(``)})${u.slice(f).join(``)}`:e}))};export{u as default,u as host};
//# sourceMappingURL=host.js.map