Skip to content

Commit

Permalink
Chore: Guarding the removal of additional event listener
Browse files Browse the repository at this point in the history
  • Loading branch information
pramodsum committed Jan 9, 2019
1 parent 847c75b commit 57fa2e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Annotator.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,10 @@ class Annotator extends EventEmitter {
*/
unbindCustomListeners() {
this.removeListener(ANNOTATOR_EVENT.scale, this.scaleAnnotations);
this.api.removeListener(ANNOTATOR_EVENT.error, this.handleServicesErrors);

if (this.api) {
this.api.removeListener(ANNOTATOR_EVENT.error, this.handleServicesErrors);
}
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/controllers/AnnotationModeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ class AnnotationModeController extends EventEmitter {
if (this.buttonEl) {
this.buttonEl.removeEventListener('click', this.toggleMode);
}
this.api.removeListener(CONTROLLER_EVENT.error, this.handleAPIErrors);

if (this.api) {
this.api.removeListener(CONTROLLER_EVENT.error, this.handleAPIErrors);
}
}

/**
Expand Down

0 comments on commit 57fa2e8

Please sign in to comment.