-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Description
Basic info:
- Node.js version: 18.12.1
- jsdom version: 20.0.3
Minimal reproduction case
const { JSDOM } = require("jsdom")
const { document } = new JSDOM().window;
const div = document.createElement("div");
div.addEventListener("click", ({ offsetX, offsetY }) => console.log({ offsetX, offsetY }));
div.click();
// { offsetX: undefined, offsetY: undefined }How does similar code behave in browsers?
const div = document.createElement("div");
div.addEventListener("click", ({ offsetX, offsetY }) => console.log({ offsetX, offsetY }));
div.click();
// { offsetX: 0, offsetY: 0 }Details
The issue appears to be that jsdom doesn't support the CSSOM View extensions to MouseEvent (and possibly others). For parity with browsers and to make jsdom more useful, offsetX and offsetY attributes should be set and not return null/undefined. Since layout is out of scope for jsdom, 0 seems like the appropriate value to return (just as browsers do with synthetic click events).
Related Issues
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels