UNPKG

@visulima/packem

Version:

A fast and modern bundler for Node.js and TypeScript.

2 lines (1 loc) 937 B
var y=Object.defineProperty;var u=(r,t)=>y(r,"name",{value:t,configurable:!0});var m=Object.defineProperty,i=u((r,t)=>m(r,"name",{value:t,configurable:!0}),"d");const l=[],s=[],h=i((r,t)=>{if(!r||typeof document>"u")return;const c=t.prepend===!0?"prepend":"append",d=t.singleTag===!0,o=typeof t.container=="string"?document.querySelector(t.container):document.querySelectorAll("head")[0];if(!o)throw new Error("Unable to find container element");const a=i(()=>{const e=document.createElement("style");e.setAttribute("type","text/css"),t.attributes&&Object.entries(t.attributes).forEach(([f,b])=>{e.setAttribute(f,b)});const p=c==="prepend"?"afterbegin":"beforeend";return o.insertAdjacentElement(p,e),e},"createStyleTag");let n;if(d){let e=l.indexOf(o);e===-1&&(e=l.push(o)-1,s[e]={}),s[e][c]||(s[e][c]=a()),n=s[e][c]}else n=a();n.styleSheet?n.styleSheet.cssText+=r:n.append(document.createTextNode(r))},"default");export{h as default};