Skip to content

Commit

Permalink
Clean up event handlers in paper dialog
Browse files Browse the repository at this point in the history
paper-dialog registered event handlers for each image in the dialog, because the size of the content can change when they load. It never cleaned up these handlers, which could cause tests to fail if the dialog in the test contained an image.
  • Loading branch information
joukevandermaas authored May 11, 2017
1 parent 7d61085 commit 3864c01
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion addon/components/paper-dialog-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ export default Component.extend({
didInsertElement() {
// content overflow might change depending on load of images inside dialog.
let images = this.$().find('img');
images.on('load', run.bind(this, this.imagesLoaded));

let imageLoadHandler = run.bind(this, this.imagesLoaded);
this.set('imageLoadHandler', imageLoadHandler);

images.on('load', imageLoadHandler);
},

willDestroyElement() {
this._super(...arguments);
let images = this.$().find('img');
images.off('load', this.get('imageLoadHandler'));
}
});

0 comments on commit 3864c01

Please sign in to comment.