zss-engine
Version:
Zero-runtime StyleSheet Engine
19 lines (18 loc) • 724 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.injectClientGlobalCSS = injectClientGlobalCSS;
const index_js_1 = require("../index.js");
function injectClientGlobalCSS(sheet) {
if (index_js_1.isServer)
return;
const existingStyleElement = document.querySelector(`[data-scope="global"]`);
if (existingStyleElement instanceof HTMLStyleElement) {
existingStyleElement.textContent += sheet;
return;
}
const styleElement = document.createElement('style');
styleElement.setAttribute('data-scope', 'global');
styleElement.setAttribute('type', 'text/css');
styleElement.textContent = sheet;
document.head.appendChild(styleElement);
}