Skip to content

Commit

Permalink
Fix #4123: Memory leak when using importHref
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel Garcia authored Nov 2, 2016
1 parent 4be2e44 commit 132010e
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/standard/utils.html
Original file line number Diff line number Diff line change
Expand Up @@ -375,20 +375,22 @@
var cached = list[link.href];
var imprt = cached || link;
var self = this;
var loadListener = function(e) {
e.target.__firedLoad = true;
e.target.removeEventListener('load', loadListener);
e.target.removeEventListener('error', errorListener);
return onload.call(self, e);
};
var errorListener = function(e) {
e.target.__firedError = true;
e.target.removeEventListener('load', loadListener);
e.target.removeEventListener('error', errorListener);
return onerror.call(self, e);
};
if (onload) {
var loadListener = function(e) {
e.target.__firedLoad = true;
e.target.removeEventListener('load', loadListener);
return onload.call(self, e);
}
imprt.addEventListener('load', loadListener);
}
if (onerror) {
var errorListener = function(e) {
e.target.__firedError = true;
e.target.removeEventListener('error', errorListener);
return onerror.call(self, e);
}
imprt.addEventListener('error', errorListener);
}
// if already loaded/erroed, fire 'fake' load/error event
Expand Down

0 comments on commit 132010e

Please sign in to comment.