mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Remove event listeners from orphaned gutters
This commit is contained in:
@@ -743,6 +743,16 @@ describe "TextEditorComponent", ->
|
||||
beforeEach ->
|
||||
gutterNode = componentNode.querySelector('.gutter')
|
||||
|
||||
describe "when the component is destroyed", ->
|
||||
it "stops listening for folding events", ->
|
||||
component.destroy()
|
||||
|
||||
lineNumber = component.lineNumberNodeForScreenRow(1)
|
||||
target = lineNumber.querySelector('.icon-right')
|
||||
target.dispatchEvent(buildClickEvent(target))
|
||||
|
||||
expect(nextAnimationFrame).toBe(noAnimationFrame)
|
||||
|
||||
it "folds and unfolds the block represented by the fold indicator when clicked", ->
|
||||
expect(lineNumberHasClass(1, 'folded')).toBe false
|
||||
|
||||
@@ -1727,6 +1737,14 @@ describe "TextEditorComponent", ->
|
||||
beforeEach ->
|
||||
gutterNode = componentNode.querySelector('.gutter')
|
||||
|
||||
describe "when the component is destroyed", ->
|
||||
it "stops listening for selection events", ->
|
||||
component.destroy()
|
||||
|
||||
gutterNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenRowInGutter(1)))
|
||||
|
||||
expect(editor.getSelectedScreenRange()).toEqual [[0, 0], [0, 0]]
|
||||
|
||||
describe "when the gutter is clicked", ->
|
||||
it "selects the clicked row", ->
|
||||
gutterNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenRowInGutter(4)))
|
||||
|
||||
@@ -16,7 +16,12 @@ class GutterContainerComponent
|
||||
|
||||
@domNode = document.createElement('div')
|
||||
@domNode.classList.add('gutter-container')
|
||||
@domNode.style.display = 'flex';
|
||||
@domNode.style.display = 'flex'
|
||||
|
||||
destroy: ->
|
||||
for {name, component} in @gutterComponents
|
||||
component.destroy?()
|
||||
return
|
||||
|
||||
getDomNode: ->
|
||||
@domNode
|
||||
|
||||
@@ -18,6 +18,10 @@ class LineNumberGutterComponent
|
||||
@domNode.addEventListener 'click', @onClick
|
||||
@domNode.addEventListener 'mousedown', @onMouseDown
|
||||
|
||||
destroy: ->
|
||||
@domNode.removeEventListener 'click', @onClick
|
||||
@domNode.removeEventListener 'mousedown', @onMouseDown
|
||||
|
||||
getDomNode: ->
|
||||
@domNode
|
||||
|
||||
|
||||
@@ -106,6 +106,7 @@ class TextEditorComponent
|
||||
@mounted = false
|
||||
@disposables.dispose()
|
||||
@presenter.destroy()
|
||||
@gutterContainerComponent?.destroy()
|
||||
window.removeEventListener 'resize', @requestHeightAndWidthMeasurement
|
||||
|
||||
getDomNode: ->
|
||||
|
||||
Reference in New Issue
Block a user