Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ie11 compat #56

Merged
merged 6 commits into from
Oct 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions can-dom-events-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,22 @@ unit.test('domEvents.addEventListener works', function (assert) {

var input = document.createElement('input');
var eventType = 'click';
var event;
var qf = document.querySelector('#qunit-fixture');
qf.appendChild(input);

var handler = function () {
assert.ok(true, 'event handler should be called');
};

domEvents.addEventListener(input, eventType, handler);

var event = new Event(eventType);
if (typeof Event === "function") {
event = new Event(eventType);
} else {
event = document.createEvent('Event');
event.initEvent(eventType, true, false);
}
input.dispatchEvent(event);

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

Expand All @@ -29,18 +36,31 @@ unit.test('domEvents.removeEventListener works', function (assert) {

var input = document.createElement('input');
var eventType = 'click';
var event, event2;
var qf = document.querySelector('#qunit-fixture');
qf.appendChild(input);
var handler = function () {
assert.ok(true, 'event handler should be called');
};

domEvents.addEventListener(input, eventType, handler);

var event = new Event(eventType);
if (typeof Event === "function") {
event = new Event(eventType);
} else {
event = document.createEvent('Event');
event.initEvent(eventType, true, true);
}
input.dispatchEvent(event);

domEvents.removeEventListener(input, eventType, handler);

var event2 = new Event(eventType);
if (typeof Event === "function") {
event2 = new Event(eventType);
} else {
event2 = document.createEvent('Event');
event2.initEvent(eventType, true, true);
}
input.dispatchEvent(event2);
});

Expand All @@ -51,12 +71,15 @@ unit.test('domEvents.dispatch works', function (assert) {

var input = document.createElement('input');
var eventType = 'click';
var qf = document.querySelector('#qunit-fixture');
qf.appendChild(input);
var handler = function () {
assert.ok(true, 'event handler should be called');
};

input.addEventListener(eventType, handler);


domEvents.dispatch(input, eventType);

input.removeEventListener(eventType, handler);
Expand Down