b-fuze / deno-dom

Browser DOM & HTML parser in Deno
https://jsr.io/@b-fuze/deno-dom
MIT License
425 stars 47 forks source link

Method `closest` is missing on Element #99

Closed sebastienfilion closed 1 year ago

sebastienfilion commented 2 years ago

Seems like the method closest is missing on Element; I've noticed that there seem to be an implementation -- though I truly don't know what I'm reading 😓

https://github.com/b-fuze/deno-dom/blob/29c9e1f1fbf4ad3c1c6bb317cec65f70de9312a1/src/dom/selectors/nwsapi.js#L1592

Reproducing steps

const document = new DOMParser().parseFromString(`<button data-target="#fuga"><span>Fuga</span></button>`, 'text/html');
const $e = document.querySelector("button span");
const $b = $e?.closest("button");
// TypeError: $e?.closest is not a function

I see that it's not on the Element class; so I'll just watch this issue. https://github.com/b-fuze/deno-dom/blob/787d41ef0db93f6b9dddb11add5c10fd7f6c43b4/src/dom/element.ts#L121

Thank you for your hard work.