Skip to content

Commit

Permalink
Merge pull request #4 from canjs/3-jquery-ify
Browse files Browse the repository at this point in the history
Support other binding contexts to fix jquery
  • Loading branch information
justinbmeyer authored Jun 30, 2017
2 parents ec69a48 + 97cdfbd commit 8a287fb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
19 changes: 19 additions & 0 deletions can-event-dom-enter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,22 @@ function runTests (mod) {
}

suites.forEach(runTests);

unit.module("can-event-dom-enter plain");

unit.test("can use custom addEventListener and removeEventListener (#3)", function(assert){
assert.expect(2);
var handler = function(){};
var button = document.createElement("button");
definition.addEventListener.call({
addEventListener: function(){
assert.ok(true, "called custom addEventListener");
}
},button,"enter", handler);

definition.removeEventListener.call({
removeEventListener: function(){
assert.ok(true, "called custom removeEventListener");
}
},button,"enter", handler);
});
4 changes: 2 additions & 2 deletions can-event-dom-enter.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ module.exports = {
};

associateHandler(target, eventType, handler, keyHandler);
target.addEventListener(baseEventType, keyHandler);
this.addEventListener(target, baseEventType, keyHandler);
},

removeEventListener: function (target, eventType, handler) {
var keyHandler = disassociateHandler(target, eventType, handler);
if (keyHandler) {
target.removeEventListener(baseEventType, keyHandler);
this.removeEventListener(target,baseEventType, keyHandler);
}
}
};

0 comments on commit 8a287fb

Please sign in to comment.