From e094fca4ef4f1a8cb123f779a8c498bf53cab862 Mon Sep 17 00:00:00 2001 From: Paul Ivanov Date: Tue, 7 Jan 2014 13:03:21 -0800 Subject: [PATCH] dispatch on mime type for append methods --- IPython/html/static/notebook/js/outputarea.js | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/IPython/html/static/notebook/js/outputarea.js b/IPython/html/static/notebook/js/outputarea.js index 51ec780b5..c1a90b6b4 100644 --- a/IPython/html/static/notebook/js/outputarea.js +++ b/IPython/html/static/notebook/js/outputarea.js @@ -514,11 +514,12 @@ var IPython = (function (IPython) { return true; } } else { - var old_name = OutputArea.mime_map[type] - this['append_'+old_name](json[type], md, element, type); - return true; + var append = OutputArea.append_map[type]; + if (append !== undefined) { + append.apply(this, [json[type], md, element, type]); + return true; + } } - return false; } } return false; @@ -634,6 +635,17 @@ var IPython = (function (IPython) { element.append(toinsert); }; + OutputArea.append_map = { + "text/plain" : OutputArea.prototype.append_text, + "text/html" : OutputArea.prototype.append_html, + "image/svg+xml" : OutputArea.prototype.append_svg, + "image/png" : OutputArea.prototype.append_png, + "image/jpeg" : OutputArea.prototype.append_jpeg, + "text/latex" : OutputArea.prototype.append_latex, + "application/json" : OutputArea.prototype.append_json, + "application/javascript" : OutputArea.prototype.append_javascript, + }; + OutputArea.prototype.append_raw_input = function (msg) { var that = this; this.expand();