Skip to content

Commit

Permalink
Ensure view is set by default on generated mouse events (#429)
Browse files Browse the repository at this point in the history
(cherry picked from commit bd21165)
  • Loading branch information
Francesco Novy authored and rwjblue committed Oct 16, 2018
1 parent 03373db commit 3336128
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addon-test-support/@ember/test-helpers/dom/fire-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function buildBasicEvent(type, options = {}) {
// eslint-disable-next-line require-jsdoc
function buildMouseEvent(type, options = {}) {
let event;
let eventOpts = assign({}, DEFAULT_EVENT_OPTIONS, options);
let eventOpts = assign({ view: window }, DEFAULT_EVENT_OPTIONS, options);
if (MOUSE_EVENT_CONSTRUCTOR) {
event = new MouseEvent(type, eventOpts);
} else {
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/dom/click-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@ module('DOM Helper: click', function(hooks) {

assert.verifySteps(['mousedown 13 17 2', 'mouseup 13 17 2', 'click 13 17 2']);
});

test('clicking a div has window set as view by default', async function(assert) {
element = buildInstrumentedElement('div', ['view']);

await setupContext(context);
await click(element);

assert.verifySteps([
'mousedown [object Window]',
'mouseup [object Window]',
'click [object Window]',
]);
});
});

module('focusable element types', function() {
Expand Down

0 comments on commit 3336128

Please sign in to comment.