zss-engine
Version:
Zero-runtime StyleSheet Engine
16 lines (15 loc) • 585 B
JavaScript
import { isServer } from '../index.js';
export function injectClientGlobalCSS(sheet) {
if (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);
}