Closed ooker777 closed 5 months ago
import { DOMParser } from "jsr:@b-fuze/deno-dom"; const html = '<link rel="canonical" href="example"/>' const document = new DOMParser().parseFromString(html, "text/html"); const linkElement = document.querySelector("link[rel='canonical']") as HTMLLinkElement | null console.log(linkElement?.getAttribute("href")) // "example" console.log(linkElement?.href); // undefined
The last one should works. See HTMLLinkElement - Web APIs | MDN and MDN playground
Duplicate issue of #72
The last one should works. See HTMLLinkElement - Web APIs | MDN and MDN playground