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

`linkElement.getAttribute("href")` works, but `linkElement.href` returns undefined #165

Closed ooker777 closed 5 months ago

ooker777 commented 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

b-fuze commented 5 months ago

Duplicate issue of #72