UNPKG

@suid/css

Version:

CSS render in JS.

24 lines (23 loc) 703 B
import setStyleElementText from "./setStyleElementText"; function setAttributes(element, attributes) { for (const name in attributes) { const value = attributes[name]; if (value !== undefined) { if (value === null) { element.removeAttribute(name); } else { element.setAttribute(name, value); } } } } function createStyleElement(css, attributes) { const element = document.createElement("style"); element.type = "text/css"; if (attributes) setAttributes(element, attributes); setStyleElementText(element, css); return element; } export default createStyleElement;