Skip to content

Commit

Permalink
Remove scrollX/Y setting from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jenseng committed Mar 12, 2023
1 parent f183b3d commit 263d7b2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 60 deletions.
6 changes: 1 addition & 5 deletions lib/jsdom/living/events/MouseEvent-impl.js
Expand Up @@ -41,17 +41,13 @@ class MouseEventImpl extends UIEventImpl {
return this.pageY;
}

/** @override */
get target() {
return super.target;
}

/**
* @override
* calculate the event position when the target is set so that it's stable during dispatch
*/
set target(target) {
super.target = target;
// calculate the event position when the target is set so that it's stable during dispatch
if (target) {
const { scrollX = 0, scrollY = 0 } = wrapperForImpl(this.view) ?? {};
this._pageX = this.clientX + scrollX;
Expand Down

This file was deleted.

Expand Up @@ -90,6 +90,31 @@

}, "clicking using click() should produce an event object with the correct MouseEventInit values");

test(() => {
const e = new MouseEvent("click", {
clientX: 1, clientY: 2, view: window
});
assert_equals(e.x, 1);
assert_equals(e.y, 2);
assert_equals(e.pageX, 1);
assert_equals(e.pageY, 2);
assert_equals(e.offsetX, 1);
assert_equals(e.offsetY, 2);
}, "MouseEvent should provide the correct computed values when the dispatch flag is not set");

async_test(t => {
const element = document.querySelector("button");
element.addEventListener("click", t.step_func_done(e => {
assert_equals(e.pageX, 1);
assert_equals(e.pageY, 2);
assert_equals(e.offsetX, 1);
assert_equals(e.offsetY, 2);
}));
element.dispatchEvent(new MouseEvent("click", {
clientX: 1, clientY: 2, view: window
}));
}, "MouseEvent should provide the correct computed values when the dispatch flag is set");

test(() => {
const e = new MouseEvent("click", {
screenX: 1.5, screenY: 2.5, clientX: 3.5, clientY: 4.5
Expand Down

0 comments on commit 263d7b2

Please sign in to comment.