diff --git a/src/mixins/eraser_brush.mixin.js b/src/mixins/eraser_brush.mixin.js index 7ce118ffe2b..03219ed4731 100644 --- a/src/mixins/eraser_brush.mixin.js +++ b/src/mixins/eraser_brush.mixin.js @@ -1,6 +1,7 @@ (function () { var __setBgOverlayColor = fabric.StaticCanvas.prototype.__setBgOverlayColor; var ___setBgOverlay = fabric.StaticCanvas.prototype.__setBgOverlay; + var __setSVGBgOverlayColor = fabric.StaticCanvas.prototype._setSVGBgOverlayColor; fabric.util.object.extend(fabric.StaticCanvas.prototype, { backgroundColor: undefined, overlayColor: undefined, @@ -58,6 +59,23 @@ } }, + /** + * patch serialization + * background/overlay properties could be objects if parsed by this mixin or could be legacy values + * @private + */ + _setSVGBgOverlayColor: function (markup, property, reviver) { + var filler = this[property + 'Color']; + if (filler && typeof filler === 'object' && filler.type === 'rect') { + var excludeFromExport = filler.excludeFromExport || (this[property] && this[property].excludeFromExport); + if (filler && !excludeFromExport && filler.toSVG) { + markup.push(filler.toSVG(reviver)); + } + } else { + __setSVGBgOverlayColor.call(this, markup, property, reviver); + } + }, + /** * @private * @param {CanvasRenderingContext2D} ctx Context to render on