Closed timonson closed 1 year ago
That TypeScript error can be resolved like this:
import { ..., HTMLTemplateElement } from "https://deno.land/x/deno_dom/deno-dom-wasm.ts";
// ...
const template = doc.createElement("template") as HTMLTemplateElement;
as for the Javascript error that occurs when you run .content.cloneNode(...)
I just pushed a fix for it in bbb4f93
Thank you!
Importing from master seems to work, but importing the module from the url with the commit throws this:
export {
DOMParser,
Element,
type HTMLDocument,
HTMLTemplateElement,
} from "https://raw.githubusercontent.com/b-fuze/deno-dom/bbb4f93727e22d7686076c0887aba920d9085e7e/deno-dom-wasm.ts";
error: Module not found "https://raw.githubusercontent.com/b-fuze/deno-dom/bbb4f93727e22d7686076c0887aba920d9085e7e/src/dom/selectors/sizzle.js". at https://raw.githubusercontent.com/b-fuze/deno-dom/bbb4f93727e22d7686076c0887aba920d9085e7e/src/dom/selectors/sizzle-types.ts:1:20
@timonson it's in the latest published version v0.1.40
import {
DOMParser,
Element,
type HTMLDocument,
HTMLTemplateElement,
} from "https://deno.land/x/deno_dom@v0.1.40/deno-dom-wasm.ts";
const doc = new DOMParser().parseFromString("<template>foo bar</template>", "text/html")!;
const frag = doc.querySelector("template")! as HTMLTemplateElement;
console.log(frag.content.cloneNode().nodeName);
you don't need to use Github
Closing this as the relevant bug in Deno DOM was fixed in v0.1.40
Hello,
I would like to clone the HTMLTemplateElement contents and get the following error although it is valid JavaScript.
Why is this happening and is there a workaround?
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template#javascript
Thank you!