From fc6bca2c0f407f9c81677b07234e9996e7c2af95 Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 6 Jun 2017 16:15:10 +0200 Subject: [PATCH] catch and log event errors on outputarea.element we already do this on global events, but the new events on output_area.element were unsafe, allowing extension code to prevent actions such as clear_output, etc. from completing. --- notebook/static/notebook/js/outputarea.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/notebook/static/notebook/js/outputarea.js b/notebook/static/notebook/js/outputarea.js index be1ffa89d..c785a2fa1 100644 --- a/notebook/static/notebook/js/outputarea.js +++ b/notebook/static/notebook/js/outputarea.js @@ -54,7 +54,18 @@ define([ **/ OutputArea.prototype.create_elements = function () { - this.element = $("
"); + var element = this.element = $("
"); + // wrap element in safe trigger, + // so that errors (e.g. in widget extensions) are logged instead of + // breaking everything. + this.element._original_trigger = this.element.trigger; + this.element.trigger = function (name, data) { + try { + this._original_trigger.apply(this, arguments); + } catch (e) { + console.error("Exception in event handler for " + name, e, arguments); + } + } this.collapse_button = $("
"); this.prompt_overlay = $("
"); this.wrapper.append(this.prompt_overlay);