Event `target` not reflected correctly for `defaultView`
Running this (in nodejs v20.18.1):
import { parseHTML } from "linkedom";
const { document, window } = parseHTML();
for (let name of ["document", "window"]) {
window[name].addEventListener("test", (e) =>
console.assert(e.target === window[name], `${name} preserves target`)
);
window[name].dispatchEvent(new window.Event("test"));
}
logs this:
Assertion failed: window preserves target
It seems that the target set for events dispatched from defaultView ends up being globalThis, not defaultView.
will have a look but just FYI it's not part of this project to always be specs compliant ... it's really a case by case choice but, most importantly, I really have little time to spend over this project these days so MRs might land faster than me.
to me it's less of a spec thing, target is the most important property of Event, and without it there's no way to tell from the event the node from which it was dispatched. i'll take a look and see if i can implement it, but the code around it is pretty abstract (proxies returned from getters, et al).
proxies returned from getters, et al
that's howDOMStrings or CSS in DOM works ... you should not be afraid by those because not on this path of the equation ;-)
i guess i'm not sure how this works... seems like you're setting the event target to a new EventTarget instead of the window, but I don't understand why.
The window is just a proxy for globalThis so maybe the callbacks shoukd be bound to window.get(this) instead? Can’t remember why I have to redefine the event target but I’ll have a look … hardly before Monday as I have relatives visiting and my 3yo birthday this WE
awesome. linkedom is such a great project, thank you for your work on it!