[Gutter] Clear custom gutter decorations from previous usages of a custom gutter element

This commit is contained in:
Jess Lin 2015-04-29 08:53:04 -07:00
parent 192997c8cf
commit 5e766b6eee
2 changed files with 17 additions and 0 deletions

View File

@ -79,6 +79,21 @@ describe "TextEditorElement", ->
jasmine.attachToDOM(element)
expect(element.shadowRoot.querySelectorAll('.line-number').length).toBe initialCount
it "does not render duplicate decorations in custom gutters", ->
editor = new TextEditor
editor.setText('1\n2\n3')
editor.addGutter({name: 'test-gutter'})
marker = editor.markBufferRange([[0,0],[2,0]])
editor.decorateMarker(marker, {type: 'gutter', gutterName: 'test-gutter'})
element = atom.views.getView(editor)
jasmine.attachToDOM(element)
initialDecorationCount = element.shadowRoot.querySelectorAll('.decoration').length
element.remove()
jasmine.attachToDOM(element)
expect(element.shadowRoot.querySelectorAll('.decoration').length).toBe initialDecorationCount
describe "focus and blur handling", ->
describe "when the editor.useShadowDOM config option is true", ->
it "proxies focus/blur events to/from the hidden input inside the shadow root", ->

View File

@ -13,6 +13,8 @@ class CustomGutterComponent
@domNode = atom.views.getView(@gutter)
@decorationsNode = @domNode.firstChild
# Clear the contents in case the domNode is being reused.
@decorationsNode.innerHTML = ''
getDomNode: ->
@domNode