From 6104fe17625e30af5d4f9d211d393167830f18aa Mon Sep 17 00:00:00 2001 From: abe33 Date: Tue, 2 Dec 2014 20:11:23 +0100 Subject: [PATCH] Add defensive code on decorations methods --- lib/mixins/decoration-management.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/mixins/decoration-management.coffee b/lib/mixins/decoration-management.coffee index d81d013c..3f615d2c 100644 --- a/lib/mixins/decoration-management.coffee +++ b/lib/mixins/decoration-management.coffee @@ -91,6 +91,7 @@ class DecorationManagement extends Mixin # # Returns a `Decoration` object. decorateMarker: (marker, decorationParams) -> + return unless marker? marker = @getMarker(marker.id) if !decorationParams.scope? and decorationParams.class? @@ -163,6 +164,7 @@ class DecorationManagement extends Mixin # # decoration - The `Decoration` to remove. removeDecoration: (decoration) -> + return unless decoration? {marker} = decoration return unless decorations = @decorationsByMarkerId[marker.id] @@ -186,6 +188,7 @@ class DecorationManagement extends Mixin # # marker - The `marker` for which removing decorations. removeAllDecorationsForMarker: (marker) -> + return unless marker? decorations = @decorationsByMarkerId[marker.id].slice() for decoration in decorations @emitter.emit 'did-remove-decoration', {marker, decoration} @@ -197,6 +200,7 @@ class DecorationManagement extends Mixin # # marker - The `marker` for which removing decorations. removedAllMarkerDecorations: (marker) -> + return unless marker? @decorationMarkerChangedSubscriptions[marker.id].dispose() @decorationMarkerDestroyedSubscriptions[marker.id].dispose()