-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add way to set documentURI
on Document
#111
Comments
Deno allows setting the |
I'm thinking of doing something like import { denoDom, DOMParser } from "https://deno.land/x/deno_dom/deno-dom-wasm.ts";
const doc = new DOMParser().parseFromString("<h1>foo</h1>", "text/html");
denoDom.setDocumentMetadata(doc, {
uri: "https://example.org/example.html",
referrer: "https://example.com/",
});
console.log(doc.documentURI); // prints "https://example.org/example.html"
console.log(doc.referrer); // prints "https://example.com/" I'd like to avoid extending the actual DOM interface if possible |
Yes, that looks good. Wonder if you might want to include options parameter in const doc = new DOMParser().parseFromString("<h1>foo</h1>", {
encoding: "text/html",
uri: "https://example.org/example.html",
referrer: "https://example.com/",
}); Great work, appreciate your responsiveness :-) |
Yeah, I'd rather avoid extending the actual DOM API. What I think we can do to make it nicer is return the document from import { denoDom, DOMParser } from "https://deno.land/x/deno_dom/deno-dom-wasm.ts";
const doc = denoDom.setDocumentMetadata(
new DOMParser().parseFromString("<h1>foo</h1>", "text/html"),
{
uri: "https://example.org/example.html",
referrer: "https://example.com/",
},
);
console.log(doc.documentURI); // prints "https://example.org/example.html"
console.log(doc.referrer); // prints "https://example.com/" |
I want to take a shot at fixing this. Can anyone point me where to look? |
The document implementation is here and you can another file for that import { setDocumentMetadata } from "jsr:@b-fuze/deno-dom/util"; |
Referencing #68, there currently is no way to set the
documentURI
onDocument
(MDN Docs), which is required by modules such as@mozilla/readability
.JSDOM does this via an
url
parameter, passed into the constructor with the options:The text was updated successfully, but these errors were encountered: