Skip to content

Event target not reflected correctly for defaultView #298

Description

@jed

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions