fix(scrollable): check if scrollable exists before unregistering (#3050)

This commit is contained in:
Andrew Seguin
2017-02-16 15:44:01 -08:00
committed by GitHub
parent a91ae72598
commit b358c6c44c
@@ -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 {
@@ -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);
}
}
/**