b-fuze / deno-dom

Browser DOM & HTML parser in Deno
https://jsr.io/@b-fuze/deno-dom
MIT License
426 stars 46 forks source link

Maximum call stack size exceeded on accessing outerHTML #130

Closed Sembiance closed 1 year ago

Sembiance commented 1 year ago

When running deno_dom@v0.1.36-alpha/deno-dom-wasm.ts with deno 1.28.1 and loading the attached test.html.zip file and then attempting to access the .outerHTML property of the <html> tag with with this code:

import { DOMParser, Element } from "https://deno.land/x/deno_dom@v0.1.36-alpha/deno-dom-wasm.ts";

const doc = new DOMParser().parseFromString(await Deno.readTextFile("test.html"), "text/html");
const outerHTML = doc.querySelector("html").outerHTML;

causes this error:

error: Uncaught (in promise) RangeError: Maximum call stack size exceeded
  [getNamedNodeMapAttrNamesSym](): string[] {
                               ^
    at NamedNodeMap.<anonymous> (https://deno.land/x/deno_dom@v0.1.36-alpha/src/dom/element.ts:371:32)
    at Element.getAttributeNames (https://deno.land/x/deno_dom@v0.1.36-alpha/src/dom/element.ts:651:56)
    at getElementAttributesString (https://deno.land/x/deno_dom@v0.1.36-alpha/src/dom/utils.ts:91:35)
    at Element.get outerHTML (https://deno.land/x/deno_dom@v0.1.36-alpha/src/dom/element.ts:570:12)
    at getInnerHtmlFromNodes (https://deno.land/x/deno_dom@v0.1.36-alpha/src/dom/utils.ts:47:35)
    at Element.get innerHTML (https://deno.land/x/deno_dom@v0.1.36-alpha/src/dom/element.ts:604:12)
    at Element.get outerHTML (https://deno.land/x/deno_dom@v0.1.36-alpha/src/dom/element.ts:592:27)
    at getInnerHtmlFromNodes (https://deno.land/x/deno_dom@v0.1.36-alpha/src/dom/utils.ts:47:35)
    at Element.get innerHTML (https://deno.land/x/deno_dom@v0.1.36-alpha/src/dom/element.ts:604:12)
    at Element.get outerHTML (https://deno.land/x/deno_dom@v0.1.36-alpha/src/dom/element.ts:592:27)
b-fuze commented 1 year ago

Well, this is interesting lol

b-fuze commented 1 year ago

Thanks