Properly unmount the component when the shadow DOM is enabled.

This commit is contained in:
Ben Ogle 2014-12-16 14:36:51 -08:00
parent 44fceaae20
commit 0829da53b0
2 changed files with 26 additions and 1 deletions

View File

@ -32,6 +32,31 @@ describe "TextEditorElement", ->
element.setModel(model)
expect(element.hasAttribute('mini')).toBe true
describe "when the editor is attached to the DOM", ->
describe "when the editor.useShadowDOM config option is true", ->
it "mounts the react component and unmounts when removed from the dom", ->
atom.config.set('editor.useShadowDOM', true)
element = new TextEditorElement
jasmine.attachToDOM(element)
component = element.component
expect(component.isMounted()).toBe true
element.getModel().destroy()
expect(component.isMounted()).toBe false
describe "when the editor.useShadowDOM config option is false", ->
it "mounts the react component and unmounts when removed from the dom", ->
atom.config.set('editor.useShadowDOM', false)
element = new TextEditorElement
jasmine.attachToDOM(element)
component = element.component
expect(component.isMounted()).toBe true
element.getModel().destroy()
expect(component.isMounted()).toBe false
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

@ -123,7 +123,7 @@ class TextEditorElement extends HTMLElement
unmountComponent: ->
return unless @component?.isMounted()
callRemoveHooks(this)
React.unmountComponentAtNode(this)
React.unmountComponentAtNode(@rootElement)
@component = null
focused: ->