diff --git a/core/modules/parsers/javascriptparser/javascriptparser.js b/core/modules/parsers/javascriptparser/javascriptparser.js index 89724711e..f1c8d63c5 100644 --- a/core/modules/parsers/javascriptparser/javascriptparser.js +++ b/core/modules/parsers/javascriptparser/javascriptparser.js @@ -22,6 +22,13 @@ var JavaScriptParser = function(options) { // Parse a string of JavaScript code and return the parse tree as a wikitext parse tree JavaScriptParser.prototype.parse = function(type,code) { // Try to parse the code + if(!code) { + return new $tw.Renderer([ + $tw.Tree.Element("pre",{"class": "javascript-source"},[ + $tw.Tree.Text("") + ]) + ],new $tw.Dependencies(),this.wiki); + } var parseTree; try { parseTree = esprima.parse(code,{comment: true,tokens: true,range: true});