From 4cf2a8a0bdf8449e70b6ba84fd37593db7b24be4 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 26 Jan 2016 11:32:12 +0100 Subject: [PATCH] rtwiki.js : catch some typeErrors --- www/code/rtwiki.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/www/code/rtwiki.js b/www/code/rtwiki.js index b749ebe78..a6a209d69 100644 --- a/www/code/rtwiki.js +++ b/www/code/rtwiki.js @@ -437,7 +437,11 @@ define([ }, 500); socket.onClose.push(function () { clearTimeout(to); - toolbar.remove(); + if (toolbar && typeof toolbar.remove === 'function') { + toolbar.remove(); + } else { + warn("toolbar.remove is not a function"); //why not? + } setAutosaveHiddenState(false); }); @@ -752,6 +756,12 @@ define([ //error(false, "userDocBeforePatch != textAreaVal"); } var op = attempt(Otaml.makeTextOperation)(userDocBeforePatch, realtime.getUserDoc()); + + if (typeof op === 'undefined') { + warn("TypeError: op is undefined"); + return; + } + var oldValue = textAreaVal; var newValue = realtime.getUserDoc(); // Fix cursor and/or selection @@ -825,7 +835,11 @@ define([ }, 500); socket.onClose.push(function () { clearTimeout(to); - toolbar.remove(); + if (toolbar && typeof toolbar.remove === 'function') { + toolbar.remove(); + } else { + warn("toolbar.remove is not a function"); //why not? + } setAutosaveHiddenState(false); }); socket.onEvent = function(){