Skip to content

Commit

Permalink
Add defensive code on decorations methods
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Dec 2, 2014
1 parent c2c6907 commit 6104fe1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/mixins/decoration-management.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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]

Expand All @@ -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}
Expand All @@ -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()

Expand Down

0 comments on commit 6104fe1

Please sign in to comment.