Skip to content

Commit

Permalink
Merge pull request kupriyanenko#55 from mindfreakthemon/master
Browse files Browse the repository at this point in the history
Fixing event leak when using multiple event handlers on the same element
  • Loading branch information
kupriyanenko committed Oct 9, 2015
2 parents cac1baa + 8491f31 commit 5f1b299
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions dist/jbone.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* jBone v1.1.1 - 2015-08-13 - Library for DOM manipulation
* jBone v1.1.1 - 2015-10-08 - Library for DOM manipulation
*
* http://jbone.js.org
*
Expand Down Expand Up @@ -350,7 +350,10 @@ jBone.event = {
eventType = event.split(".")[0];
events[eventType] = events[eventType] || [];

if (!events[eventType].length) {
if (events[eventType].length) {
// override with previous event handler
eventHandler = events[eventType][0].fn;
} else {
el.addEventListener && el.addEventListener(eventType, eventHandler, false);
}

Expand Down
4 changes: 2 additions & 2 deletions dist/jbone.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ jBone.event = {
eventType = event.split(".")[0];
events[eventType] = events[eventType] || [];

if (!events[eventType].length) {
if (events[eventType].length) {
// override with previous event handler
eventHandler = events[eventType][0].fn;
} else {
el.addEventListener && el.addEventListener(eventType, eventHandler, false);
}

Expand Down

0 comments on commit 5f1b299

Please sign in to comment.