diff --git a/src/shapes/text.class.js b/src/shapes/text.class.js index 66a9164f..1c74e483 100644 --- a/src/shapes/text.class.js +++ b/src/shapes/text.class.js @@ -1038,8 +1038,25 @@ if (!options.originX) { options.originX = 'left'; } - var textContent = element.textContent.replace(/^\s+|\s+$|\n+/g, '').replace(/\s+/g, ' '), - text = new fabric.Text(textContent, options), + + var textContent = ''; + + // The XML is not properly parsed in IE9 so a workaround to get + // textContent is through firstChild.data. Another workaround would be + // to convert XML loaded from a file to be converted using DOMParser (same way loadSVGFromString() does) + if (!('textContent' in element)) { + if ('firstChild' in element && element.firstChild !== null) { + if ('data' in element.firstChild && element.firstChild.data !== null) { + textContent = element.firstChild.data; + } + } + } else { + textContent = element.textContent; + } + + textContent = element.textContent.replace(/^\s+|\s+$|\n+/g, '').replace(/\s+/g, ' '); + + var text = new fabric.Text(textContent, options); /* Adjust positioning: x/y attributes in SVG correspond to the bottom-left corner of text bounding box