Skip to content

Commit

Permalink
Generate the temporary svg in a Document Fragment again
Browse files Browse the repository at this point in the history
This essentially reverts commmit
b65fe7e which was made to fix
#2. However, the real
reason the original solution didn't work in Chrome was that just
setting the innerHTML to a string didn't create a real SVG XML
document with its methods, including the getTotalLength() method.
  • Loading branch information
Magnus Jacobsson authored and Magnus Jacobsson committed Feb 15, 2018
1 parent e5d2649 commit dd0af0d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/dot.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,16 @@ export default function(src, callback) {
function layoutDone(svgDoc) {
this._dispatch.call("layoutEnd", this);

var newDoc = d3.selection()
.append('div')
.attr('display', 'none');
var newDoc = d3.select(document.createDocumentFragment())
.append('div');

var parser = new window.DOMParser();
var doc = parser.parseFromString(svgDoc, "image/svg+xml");

newDoc
.html(svgDoc);
.append(function() {
return doc.documentElement;
});

var newSvg = newDoc
.select('svg');
Expand All @@ -255,7 +259,6 @@ export default function(src, callback) {
this._data = data;
this._dictionary = dictionary;
this._nodeDictionary = nodeDictionary;
newDoc.remove();

this._extractData = extractData;
this._busy = false;
Expand Down

0 comments on commit dd0af0d

Please sign in to comment.