From f152996f11e5ccc48796432c3df1283d7e7750f5 Mon Sep 17 00:00:00 2001 From: Pablo de Oliveira Date: Sun, 22 Sep 2013 12:53:05 +0200 Subject: [PATCH 01/10] outputarea.js: Wrap inline SVGs inside an iframe When multiple inline SVGs are included in a single document, they share the same parse tree. Therefore, style collisions and use id collisions can occur and upset the rendering. This patch wraps each SVG inside an individual iframe, ensuring that SVG's declarations do not collide. (The SVG representation is kept as XML and not converted to a binary format, so I do not think this approach precludes the use of d3.js) Tested on: * Chrome Version 29.0.1547.57 Debian 7.1 (217859) * Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130806 Firefox/17.0 Iceweasel/17.0.8 Closes #1866 --- IPython/html/static/notebook/js/outputarea.js | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/IPython/html/static/notebook/js/outputarea.js b/IPython/html/static/notebook/js/outputarea.js index 91886df25..35bd0d868 100644 --- a/IPython/html/static/notebook/js/outputarea.js +++ b/IPython/html/static/notebook/js/outputarea.js @@ -494,9 +494,36 @@ var IPython = (function (IPython) { OutputArea.prototype.append_svg = function (svg, md, element) { - var toinsert = $("
").addClass("output_subarea output_svg"); - toinsert.append(svg); - element.append(toinsert); + // To avoid style or use collisions between multiple svg figures, + // svg figures are wrapped inside an iframe. + + var iframe = $('