mirror of
https://github.com/scratchfoundation/scratch-render.git
synced 2025-07-08 04:34:51 -04:00
Fix IE/Edge Support (#85)
This commit is contained in:
parent
2463d2c50a
commit
ec2361cf91
1 changed files with 7 additions and 7 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue