b-fuze / deno-dom

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

`cloneNode()` produces `null` body on HTMLDocument #157

Closed tai2 closed 9 months ago

tai2 commented 10 months ago
import { DOMParser, Element, HTMLDocument, Node } from "../../deno-dom-wasm.ts";
import {
  assert,
  assertEquals,
} from "https://deno.land/std@0.85.0/testing/asserts.ts";

Deno.test("cloneNode", () => {
  const doc = new DOMParser().parseFromString(
    `
    a
    <p>b</p>
    <ul><li>c</li></ul>
    <!-- d -->
    <a id="e">e</a>
  `,
    "text/html"
  )!;

  const doc2 = doc.cloneNode(true) as HTMLDocument;
  assert(doc2.body !== null); // This is supposed to be true but gets false really
});
b-fuze commented 9 months ago

Thanks