Skip to content

Commit

Permalink
fix tests for IE11
Browse files Browse the repository at this point in the history
  • Loading branch information
cherifGsoul committed Oct 22, 2018
1 parent 9675002 commit a778811
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions can-dom-events-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ unit.test('domEvents.addEventListener works', function (assert) {
assert.ok(true, 'event handler should be called');
};

domEvents.addEventListener(input, eventType, handler, false);
domEvents.addEventListener(input, eventType, handler);
if (typeof Event === "function") {
event = new Event(eventType);
} else {
var qf = document.querySelector('#qunit-fixture');
qf.appendChild(input);
event = document.createEvent('Event');
event.initEvent(eventType, false, true);
event.initEvent(eventType, true, false);
}
input.dispatchEvent(event);

domEvents.removeEventListener(input, eventType, handler);
});

Expand All @@ -36,6 +37,7 @@ unit.test('domEvents.removeEventListener works', function (assert) {
var input = document.createElement('input');
var eventType = 'click';
var event, event2;
var qf = document.querySelector('#qunit-fixture');
var handler = function () {
assert.ok(true, 'event handler should be called');
};
Expand All @@ -45,6 +47,7 @@ unit.test('domEvents.removeEventListener works', function (assert) {
if (typeof Event === "function") {
event = new Event(eventType);
} else {
qf.appendChild(input);
event = document.createEvent('Event');
event.initEvent(eventType, true, true);
}
Expand All @@ -55,6 +58,9 @@ unit.test('domEvents.removeEventListener works', function (assert) {
if (typeof Event === "function") {
event2 = new Event(eventType);
} else {
if (!qf.contains(input)) {
qf.appendChild(input);
}
event2 = document.createEvent('Event');
event2.initEvent(eventType, true, true);
}
Expand All @@ -74,6 +80,11 @@ unit.test('domEvents.dispatch works', function (assert) {

input.addEventListener(eventType, handler);

if (typeof Event !== "function") {
var qf = document.querySelector('#qunit-fixture');
qf.appendChild(input);
}

domEvents.dispatch(input, eventType);

input.removeEventListener(eventType, handler);
Expand Down

0 comments on commit a778811

Please sign in to comment.