From 33e8b0ca57703ae9cb85b87afa3d4af9bf0b2fb5 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Thu, 3 Dec 2015 10:54:53 +0000 Subject: [PATCH] Fix +10613 don't crash when there is not a next panel --- plugins/c9.ide.editors/pane.js | 52 ++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/plugins/c9.ide.editors/pane.js b/plugins/c9.ide.editors/pane.js index d796518f..541f16ab 100644 --- a/plugins/c9.ide.editors/pane.js +++ b/plugins/c9.ide.editors/pane.js @@ -585,32 +585,34 @@ define(function(require, module, exports) { next = next.selectNodes("tab|hsplitbox|vsplitbox")[op](); } - // move all pages to another pane - getTabs().forEach(function(tab) { - tab.attachTo(next.cloud9pane, null, true); - }); - - // destroy aml element - amlPane.destroy(true, true); - - // Clean up tree - if (last) { - var place = parent.nextSibling; - var grandpa = parent.parentNode; - parent.removeChild(last); - if (parent != options.container) - parent.destroy(true, true); - grandpa.insertBefore(last, place); + if (next) { + // move all pages to another pane + getTabs().forEach(function(tab) { + tab.attachTo(next.cloud9pane, null, true); + }); + + // destroy aml element + amlPane.destroy(true, true); - queue = [grandpa] - - var size = grandpa.$vbox ? "height" : "width"; - last.setAttribute(size, parent[size]); - size = grandpa.$vbox ? "width" : "height"; - last.setAttribute(size, ""); - } - else { - queue = [parent]; + // Clean up tree + if (last) { + var place = parent.nextSibling; + var grandpa = parent.parentNode; + parent.removeChild(last); + if (parent != options.container) + parent.destroy(true, true); + grandpa.insertBefore(last, place); + + queue = [grandpa] + + var size = grandpa.$vbox ? "height" : "width"; + last.setAttribute(size, parent[size]); + size = grandpa.$vbox ? "width" : "height"; + last.setAttribute(size, ""); + } + else { + queue = [parent]; + } } if (last && last.parentNode.localName == "bar") {