diff --git a/src/elements_parser.js b/src/elements_parser.js index 35637097..4b70bae4 100644 --- a/src/elements_parser.js +++ b/src/elements_parser.js @@ -43,7 +43,8 @@ fabric.ElementsParser.prototype._createObject = function(klass, el, index) { } else { var obj = klass.fromElement(el, this.options); - this.resolveGradient(obj); + this.resolveGradient(obj,'fill'); + this.resolveGradient(obj,'stroke'); this.reviver && this.reviver(el, obj); this.instances[index] = obj; this.checkIfDone(); @@ -53,22 +54,23 @@ fabric.ElementsParser.prototype._createObject = function(klass, el, index) { fabric.ElementsParser.prototype.createCallback = function(index, el) { var _this = this; return function(obj) { - _this.resolveGradient(obj); + _this.resolveGradient(obj,'fill'); + _this.resolveGradient(obj,'stroke'); _this.reviver && _this.reviver(el, obj); _this.instances[index] = obj; _this.checkIfDone(); }; }; -fabric.ElementsParser.prototype.resolveGradient = function(obj) { +fabric.ElementsParser.prototype.resolveGradient = function(obj,property) { - var instanceFillValue = obj.get('fill'); + var instanceFillValue = obj.get(property); if (!(/^url\(/).test(instanceFillValue)) { return; } var gradientId = instanceFillValue.slice(5, instanceFillValue.length - 1); if (fabric.gradientDefs[gradientId]) { - obj.set('fill', + obj.set(property, fabric.Gradient.fromElement(fabric.gradientDefs[gradientId], obj)); } };