diff --git a/editor/js/editor.js b/editor/js/editor.js index 5ec6d67cb..4f31bef12 100644 --- a/editor/js/editor.js +++ b/editor/js/editor.js @@ -30,16 +30,19 @@ * } */ function getOutput() { - var editorContents = { - htmlContent: tabby.editors.html.editor.getValue(), - cssContent: tabby.editors.css.editor.getValue(), - }; - - // not all editor instances have a JS panel - if (tabby.editors.js.editor) { - editorContents.jsContent = tabby.editors.js.editor.getValue(); - } + var editorContents = {}; + + setContent("htmlContent", "html"); + setContent("cssContent", "css"); + setContent("jsContent", "js"); + function setContent(propertyName, editorName) { + if (tabby.editors[editorName].editor) { + editorContents[propertyName] = tabby.editors[editorName].editor.getValue(); + } else { + editorContents[propertyName] = ""; + } + } return editorContents; }