diff --git a/spec/panel-container-element-spec.coffee b/spec/panel-container-element-spec.coffee index 12e28e04d..a0ca70f52 100644 --- a/spec/panel-container-element-spec.coffee +++ b/spec/panel-container-element-spec.coffee @@ -43,28 +43,56 @@ describe "PanelContainerElement", -> expect(element.parentNode).not.toBe jasmineContent describe "adding and removing panels", -> - it "adds atom-panel elements when a new panel is added to the container; removes them when the panels are destroyed", -> - expect(element.childNodes.length).toBe 0 + describe "when the container is at the left location", -> + it "adds atom-panel elements when a new panel is added to the container; removes them when the panels are destroyed", -> + expect(element.childNodes.length).toBe 0 - panel1 = new Panel({viewRegistry, item: new TestPanelContainerItem(), location: 'left'}) - container.addPanel(panel1) - expect(element.childNodes.length).toBe 1 - expect(element.childNodes[0].getAttribute('location')).toBe 'left' + panel1 = new Panel({viewRegistry, item: new TestPanelContainerItem()}) + container.addPanel(panel1) + expect(element.childNodes.length).toBe 1 + expect(element.childNodes[0].getAttribute('location')).toBe 'left' - expect(element.childNodes[0].tagName).toBe 'ATOM-PANEL' + expect(element.childNodes[0].tagName).toBe 'ATOM-PANEL' - panel2 = new Panel({viewRegistry, item: new TestPanelContainerItem(), location: 'left'}) - container.addPanel(panel2) - expect(element.childNodes.length).toBe 2 + panel2 = new Panel({viewRegistry, item: new TestPanelContainerItem()}) + container.addPanel(panel2) + expect(element.childNodes.length).toBe 2 - expect(panel1.getView().style.display).not.toBe 'none' - expect(panel2.getView().style.display).not.toBe 'none' + expect(panel1.getView().style.display).not.toBe 'none' + expect(panel2.getView().style.display).not.toBe 'none' - panel1.destroy() - expect(element.childNodes.length).toBe 1 + panel1.destroy() + expect(element.childNodes.length).toBe 1 - panel2.destroy() - expect(element.childNodes.length).toBe 0 + panel2.destroy() + expect(element.childNodes.length).toBe 0 + + describe "when the container is at the bottom location", -> + beforeEach -> + container = new PanelContainer({viewRegistry, location: 'bottom'}) + element = container.getView() + jasmineContent.appendChild(element) + + it "adds atom-panel elements when a new panel is added to the container; removes them when the panels are destroyed", -> + expect(element.childNodes.length).toBe 0 + + panel1 = new Panel({viewRegistry, item: new TestPanelContainerItem(), className: 'one'}) + container.addPanel(panel1) + expect(element.childNodes.length).toBe 1 + expect(element.childNodes[0].getAttribute('location')).toBe 'bottom' + expect(element.childNodes[0].tagName).toBe 'ATOM-PANEL' + expect(panel1.getView()).toHaveClass 'one' + + panel2 = new Panel({viewRegistry, item: new TestPanelContainerItem(), className: 'two'}) + container.addPanel(panel2) + expect(element.childNodes.length).toBe 2 + expect(panel2.getView()).toHaveClass 'two' + + panel1.destroy() + expect(element.childNodes.length).toBe 1 + + panel2.destroy() + expect(element.childNodes.length).toBe 0 describe "when the container is modal", -> beforeEach -> diff --git a/src/panel-container-element.coffee b/src/panel-container-element.coffee index d162686cf..2517eafe5 100644 --- a/src/panel-container-element.coffee +++ b/src/panel-container-element.coffee @@ -28,7 +28,7 @@ class PanelContainerElement extends HTMLElement @hideAllPanelsExcept(panel) if visible panelRemoved: ({panel, index}) -> - @removeChild(@childNodes[index]) + @removeChild(panel.getView()) destroyed: -> @subscriptions.dispose()