create-script.ts

28 lines | 785 B Blame History Raw Download
import { executeDrawQueue } from "../outputframe-app/injects/dom-helpers";

export function createScript(value: string, appendToBody: boolean = true): HTMLScriptElement {
    var script: HTMLScriptElement = document.createElement("script");
    script.setAttribute("async", "");
    script.innerHTML = value;

    if (appendToBody) {
        document.body.appendChild(script);
        executeDrawQueue();
    }

    return script;
}

export function createHtml(value: string) {
    var div: HTMLDivElement = document.createElement("div");
    div.innerHTML = value;

    document.body.appendChild(div);
}

export function createCss(value: string) {
    var style: HTMLStyleElement = document.createElement("style");
    style.innerHTML = value;

    document.body.appendChild(style);
}