mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-11 23:33:10 +00:00
IE9 bugfix for loading SVGs from URL that contain <text> nodes
This commit is contained in:
parent
d0eb828ba5
commit
1ecebe38ee
1 changed files with 19 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue