Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Don't emit events after MarkerTextDecorationLayer has been destroyed
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Scandurra committed May 2, 2017
1 parent c869372 commit 7cf95b2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions spec/marker-text-decoration-layer-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,11 @@ describe('MarkerTextDecorationLayer', () => {
expect(rangeInvalidationEvents).toEqual([])
textDecorationLayer.clearInvalidatedRanges()
expect(textDecorationLayer.getInvalidatedRanges()).toEqual([])

rangeInvalidationEvents = []
textDecorationLayer.destroy()
marker2.setRange(Range(Point(2, 1), Point(2, 7)))
expect(textDecorationLayer.getInvalidatedRanges()).toEqual([])
expect(rangeInvalidationEvents).toEqual([])
})
})
3 changes: 3 additions & 0 deletions src/marker-layer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,9 @@ class MarkerLayer
registerMarkerTextDecorationLayer: (markerTextDecorationLayer) ->
@markerTextDecorationLayers.add(markerTextDecorationLayer)

unregisterMarkerTextDecorationLayer: (markerTextDecorationLayer) ->
@markerTextDecorationLayers.delete(markerTextDecorationLayer)

filterSet = (set1, set2) ->
if set1
intersectSet(set1, set2)
Expand Down
4 changes: 4 additions & 0 deletions src/marker-text-decoration-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ class MarkerTextDecorationLayer {
this.inlineStyleForScopeId = inlineStyleForMarkerId || NOOP
}

destroy () {
this.markerLayer.unregisterMarkerTextDecorationLayer(this)
}

buildIterator () {
return new MarkerTextDecorationLayerIterator(this)
}
Expand Down

0 comments on commit 7cf95b2

Please sign in to comment.