Skip to content

Commit

Permalink
Merge pull request #25 from derbyjs/revert-7c6d9b9
Browse files Browse the repository at this point in the history
Switch ElementOn back to addEventListener instead of dom.on
  • Loading branch information
ericyhwang authored Dec 22, 2022
2 parents 3f84fdc + c9eaeb8 commit 308e799
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,13 @@ ElementOn.prototype.emit = function(context, element) {
var listener = function elementOnListener(event) {
return elementOn.apply(context, element, event);
};
context.controller.dom.on(this.name, element, listener, false);
// Using `context.controller.dom.on` would be better for garbage collection,
// but since it synchronously removes listeners on component destroy, it would
// break existing code relying on `on-*` listeners firing as a component is
// being destroyed. Even with `addEventListener`, browsers should still GC
// the listeners once there are no references to the element.
element.addEventListener(this.name, listener, false);
// context.controller.dom.on(this.name, element, listener, false);
};
ElementOn.prototype.apply = function(context, element, event) {
var modelData = context.controller.model.data;
Expand Down

0 comments on commit 308e799

Please sign in to comment.