Skip to content

Commit

Permalink
fix(scrollable): check if scrollable exists before unregistering (#3050)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewseguin authored Feb 16, 2017
1 parent a91ae72 commit b358c6c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib/core/overlay/scroll/scroll-dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export class ScrollDispatcher {
/**
* Registers a Scrollable with the service and listens for its scrolled events. When the
* scrollable is scrolled, the service emits the event in its scrolled observable.
*
* @param scrollable Scrollable instance to be registered.
*/
register(scrollable: Scrollable): void {
Expand All @@ -44,12 +43,13 @@ export class ScrollDispatcher {

/**
* Deregisters a Scrollable reference and unsubscribes from its scroll event observable.
*
* @param scrollable Scrollable instance to be deregistered.
*/
deregister(scrollable: Scrollable): void {
this.scrollableReferences.get(scrollable).unsubscribe();
this.scrollableReferences.delete(scrollable);
if (this.scrollableReferences.has(scrollable)) {
this.scrollableReferences.get(scrollable).unsubscribe();
this.scrollableReferences.delete(scrollable);
}
}

/**
Expand Down

0 comments on commit b358c6c

Please sign in to comment.