From b65fe7ecfa77939a6fcd5911d33d37aee25c9e5f Mon Sep 17 00:00:00 2001 From: Magnus Jacobsson Date: Tue, 29 Aug 2017 05:53:07 +0200 Subject: [PATCH] Generate the temporary svg in the DOM instead of in a Document Fragment. Fixes https://github.com/magjac/d3-graphviz/issues/2 --- src/dot.js | 6 ++++-- test/graphviz-test.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/dot.js b/src/dot.js index 4dc262af..b2764f9d 100644 --- a/src/dot.js +++ b/src/dot.js @@ -157,8 +157,9 @@ export default function(src) { } ); - var newDoc = d3.select(document.createDocumentFragment()) - .append('div'); + var newDoc = d3.selection() + .append('div') + .attr('display', 'none'); newDoc .html(svgDoc); @@ -171,6 +172,7 @@ export default function(src) { this._data = data; this._dictionary = dictionary; this._nodeDictionary = nodeDictionary; + newDoc.remove(); return this; }; diff --git a/test/graphviz-test.js b/test/graphviz-test.js index c6727aa6..50e4c37e 100644 --- a/test/graphviz-test.js +++ b/test/graphviz-test.js @@ -9,7 +9,7 @@ tape("graphviz().render() renders an SVG from graphviz DOT.", function(test) { var document = global.document = jsdom('
'); var graphviz = d3_graphviz.graphviz("#graph"); - svgDoc = ` + svgDoc = ` %0 @@ -92,7 +92,7 @@ tape("graphviz().render() removes SVG elements for nodes and edges when removed .dot('digraph {a}') .render(); - svgDoc2 = ` + svgDoc2 = ` %0