diff --git a/src/shapes/image.class.js b/src/shapes/image.class.js index 512fdd710bb..feb137976bb 100644 --- a/src/shapes/image.class.js +++ b/src/shapes/image.class.js @@ -389,6 +389,9 @@ scaleX = this.scaleX * retinaScaling, scaleY = this.scaleY * retinaScaling, elementToFilter = this._filteredEl || this._originalElement; + if (this.group) { + this.set('dirty', true); + } if (!filter || (scaleX > minimumScale && scaleY > minimumScale)) { this._element = elementToFilter; this._filterScalingX = 1; @@ -424,6 +427,9 @@ filters = filters || this.filters || []; filters = filters.filter(function(filter) { return filter; }); + if (this.group) { + this.set('dirty', true); + } if (filters.length === 0) { this._element = this._originalElement; this._filteredEl = null; diff --git a/test/unit/image.js b/test/unit/image.js index b886b296379..6eb1bc5ea48 100644 --- a/test/unit/image.js +++ b/test/unit/image.js @@ -645,4 +645,30 @@ done(); }); }); + + QUnit.test('apply filters do not set the image dirty if not in group', function(assert) { + var done = assert.async(); + createImageObject(function(image) { + image.dirty = false; + assert.equal(image.dirty, false, 'false apply filter dirty is false'); + image.applyFilters(); + assert.equal(image.dirty, false, 'After apply filter dirty is true'); + done(); + }); + }); + + QUnit.test('apply filters set the image dirty and also the group', function(assert) { + var done = assert.async(); + createImageObject(function(image) { + var group = new fabric.Group([image]); + image.dirty = false; + group.dirty = false; + assert.equal(image.dirty, false, 'false apply filter dirty is false'); + assert.equal(group.dirty, false, 'false apply filter dirty is false'); + image.applyFilters(); + assert.equal(image.dirty, true, 'After apply filter dirty is true'); + assert.equal(group.dirty, true, 'After apply filter dirty is true'); + done(); + }); + }); })();