green_copper_runtime::modules

Module htmldom

source
Expand description

HTML Dom module

make html parsing available compatible with web based dom mutation

e.g.

 async function test(){
    let htmlMod = await import("greco://htmldom"); // or if you use ts: "https://raw.githubusercontent.com/HiRoFa/GreenCopperRuntime/main/modules/dom/htmldom.ts"
    let parser = new htmlMod.DOMParser();
    let html = '<html data-foo="abc"><head></head><body><p>hello world</p></body></html>';
    let doc = parser.parseFromString(html);
    let res = "";
    console.log("attr = %s", doc.documentElement.getAttribute("data-foo"));
    console.log("outerHTML = %s", doc.documentElement.outerHTML);
};
test()