WebReflection / WebReflection/linkedom
Event `target` not reflected correctly for `defaultView`
Open
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 2.1k
- Forks
- 104
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Use the provided parseHTML reproduction as the first test case; trace how window/defaultView dispatches Event and assigns target. Done when the window listener observes e.target === window while the document behavior remains correct, with a regression test covering both cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100