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

Document fragment content loss during parsing #135

Closed timreichen closed 1 year ago

timreichen commented 1 year ago

There is a bug when parsing html with templates, where the document fragment content gets lost.

How to reproduce Run the following code in the browser and deno (uncomment import).

// import { DOMParser } from "https://deno.land/x/deno_dom@v0.1.37/deno-dom-wasm.ts";
const source = `<head></head><body><template><p>Hello world</p></template></body>`
const element = new DOMParser().parseFromString(source,"text/html").documentElement
const html = element.innerHTML
console.assert(source === html)

// html in browser: <head></head><body><template><p>Hello world</p></template></body>
// html in deno-dom:  <head></head><body><template></template></body>

received result The assertion will pass in the browser but not with deno_dom@v0.1.37/deno-dom-wasm.ts.

expected result deno-dom-wasm should behave the same as in the browser.

b-fuze commented 1 year ago

Thanks