Update elements_parser.js

This commit is contained in:
Andrea Bogazzi 2014-09-21 01:15:39 +02:00
parent 066eb54d30
commit a70321f9a8

View file

@ -3,6 +3,7 @@ fabric.ElementsParser = function(elements, callback, options, reviver) {
this.callback = callback;
this.options = options;
this.reviver = reviver;
this.svgUid = (options && options.svgUid) || 0;
};
fabric.ElementsParser.prototype.parse = function() {
@ -14,6 +15,7 @@ fabric.ElementsParser.prototype.parse = function() {
fabric.ElementsParser.prototype.createObjects = function() {
for (var i = 0, len = this.elements.length; i < len; i++) {
this.elements[i].setAttribute('svgUid', this.svgUid);
(function(_this, i) {
setTimeout(function() {
_this.createObject(_this.elements[i], i);
@ -69,9 +71,9 @@ fabric.ElementsParser.prototype.resolveGradient = function(obj, property) {
return;
}
var gradientId = instanceFillValue.slice(5, instanceFillValue.length - 1);
if (fabric.gradientDefs[gradientId]) {
if (fabric.gradientDefs[this.svgUid][gradientId]) {
obj.set(property,
fabric.Gradient.fromElement(fabric.gradientDefs[gradientId], obj));
fabric.Gradient.fromElement(fabric.gradientDefs[this.svgUid][gradientId], obj));
}
};