All files / app/common/dom appendStylesheet.ts

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16150x 4x   4x   4x 4x   4x 8x       4x    
export default function appendStylesheet(rules: string[]): HTMLStyleElement {
    const style = document.createElement('style');
 
    document.head.appendChild(style);
 
    Eif (style.sheet instanceof CSSStyleSheet) {
        const { sheet } = style;
 
        rules.forEach((rule, index) => {
            sheet.insertRule(rule, index);
        });
    }
 
    return style;
}