diff --git a/src/parser.js b/src/parser.js
index 82edc8abaaa..39e7fe1bc63 100644
--- a/src/parser.js
+++ b/src/parser.js
@@ -464,7 +464,7 @@
while (nodelist.length && i < nodelist.length) {
var el = nodelist[i],
- xlink = el.getAttribute('xlink:href').substr(1),
+ xlink = (el.getAttribute('xlink:href') || el.getAttribute('href')).substr(1),
x = el.getAttribute('x') || 0,
y = el.getAttribute('y') || 0,
el2 = elementById(doc, xlink).cloneNode(true),
@@ -487,7 +487,8 @@
for (j = 0, attrs = el.attributes, len = attrs.length; j < len; j++) {
attr = attrs.item(j);
- if (attr.nodeName === 'x' || attr.nodeName === 'y' || attr.nodeName === 'xlink:href') {
+ if (attr.nodeName === 'x' || attr.nodeName === 'y' ||
+ attr.nodeName === 'xlink:href' || attr.nodeName === 'href') {
continue;
}
diff --git a/test/unit/parser.js b/test/unit/parser.js
index a90249b7f22..ef58d22f8d5 100644
--- a/test/unit/parser.js
+++ b/test/unit/parser.js
@@ -372,6 +372,40 @@
});
});
+ QUnit.test('parseSVGFromString with xlink:href', function(assert) {
+ var done = assert.async();
+ var string = '',
+ rect;
+
+ assert.ok(fabric.loadSVGFromString);
+
+ fabric.loadSVGFromString(string, function(objects) {
+ rect = objects[0];
+ assert.ok(rect instanceof fabric.Rect);
+ done();
+ });
+ });
+
+ QUnit.test('parseSVGFromString with href', function(assert) {
+ var done = assert.async();
+ var string = '',
+ rect;
+
+ assert.ok(fabric.loadSVGFromString);
+
+ fabric.loadSVGFromString(string, function(objects) {
+ rect = objects[0];
+ assert.ok(rect instanceof fabric.Rect);
+ done();
+ });
+ });
+
QUnit.test('parseSVGFromString nested opacity', function(assert) {
var done = assert.async();
var string = '' +