UNPKG

mount-style

Version:
8 lines (7 loc) 618 B
/*! * 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. */ this.mountStyle=function(){"use strict";return function(t,e){if(void 0===e&&(e={}),!t)throw new Error("[mountStyle]: css string is required");var n=e.attrs,r=e.props;return new Promise((function(e){var i,o,s=document.createElement("style");if(n)for(i in n)s[i]=n[i];if(r)for(o in r)s[o]=r[o];s.type="text/css";try{s.appendChild(document.createTextNode(t))}catch(e){s.textContent=t}document.getElementsByTagName("head")[0].appendChild(s),e(!0)}))}}();