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

innerHTML trims `<th>` element #146

Closed tai2 closed 1 year ago

tai2 commented 1 year ago

This is the test case. According to browser implementation, DOM should satisfy it but deno-dom doesn't.

Interestingly, other elements like <p>, <div>, etc work as expected.

Deno.test(
  "setting th to Element.innerHTML keeps the shape of the child",
  () => {
    const doc = new DOMParser().parseFromString(
      `<table><tr id=parent></tr></table>`,
      "text/html"
    )!;

    const parent = doc.querySelector("#parent")!;
    parent.innerHTML = "<th>This is a header</th>";
    // `innerHTML === "This is a header"` somehow 🤔 

    assertEquals(
      parent.innerHTML,
      "<th>table header</th>",
      "innerHTML keeps the shape of the child"
    );
  }
);

I'm not familiar with Rust so it's difficult for me to fix it 🙇

b-fuze commented 1 year ago

Thanks