Fix IE/Edge Support ()

This commit is contained in:
TheBrokenRail 2017-02-18 14:06:45 -05:00 committed by GitHub
parent 2463d2c50a
commit ec2361cf91

View file

@ -60,11 +60,11 @@ class SvgRenderer {
// Parse string into SVG XML.
const parser = new DOMParser();
this._svgDom = parser.parseFromString(svgString, 'text/xml');
if (this._svgDom.children.length < 1 ||
this._svgDom.children[0].localName !== 'svg') {
if (this._svgDom.childNodes.length < 1 ||
this._svgDom.childNodes[0].localName !== 'svg') {
throw new Error('Document does not appear to be SVG.');
}
this._svgTag = this._svgDom.children[0];
this._svgTag = this._svgDom.childNodes[0];
// Transform all text elements.
this._transformText();
// Transform measurements.
@ -102,8 +102,8 @@ class SvgRenderer {
if (domElement.localName === 'text') {
textElements.push(domElement);
}
for (let i = 0; i < domElement.children.length; i++) {
collectText(domElement.children[i]);
for (let i = 0; i < domElement.childNodes.length; i++) {
collectText(domElement.childNodes[i]);
}
};
collectText(this._svgTag);
@ -159,7 +159,7 @@ class SvgRenderer {
}
}
newDefs.appendChild(newStyle);
this._svgTag.insertBefore(newDefs, this._svgTag.children[0]);
this._svgTag.insertBefore(newDefs, this._svgTag.childNodes[0]);
}
/**
@ -201,7 +201,7 @@ class SvgRenderer {
// perhaps for security reasons?
const parser = new DOMParser();
this._svgDom = parser.parseFromString(svgText, 'text/xml');
this._svgTag = this._svgDom.children[0];
this._svgTag = this._svgDom.childNodes[0];
// Set the correct measurements on the SVG tag, and save them.
this._svgTag.setAttribute('width', bbox.width);