mount-style
Version:
A simple function for mounting css style codes
8 lines (7 loc) • 590 B
JavaScript
/*!
* mount-style v1.2.0
* A simple function for mounting css style codes
* (c) 2021-2023 saqqdy<https://github.com/saqqdy>
* Released under the MIT License.
*/
function e(e,t){if(void 0===t&&(t={}),!e)throw new Error("[mountStyle]: css string is required");var n=t.attrs,r=t.props;return new Promise((function(t){var o,i,a=document.createElement("style");if(n)for(o in n)a[o]=n[o];if(r)for(i in r)a[i]=r[i];a.type="text/css";try{a.appendChild(document.createTextNode(e))}catch(t){a.textContent=e}document.getElementsByTagName("head")[0].appendChild(a),t(!0)}))}export{e as default};