diff --git a/lib/core/Canvas.js b/lib/core/Canvas.js index 79613510e..828101398 100644 --- a/lib/core/Canvas.js +++ b/lib/core/Canvas.js @@ -239,6 +239,10 @@ Canvas.prototype._clear = function() { } }); + // remove all planes + this._activePlane = null; + this._planes = {}; + // force recomputation of view box delete this._cachedViewbox; }; diff --git a/test/spec/core/CanvasSpec.js b/test/spec/core/CanvasSpec.js index 0670c24e6..30d07f059 100644 --- a/test/spec/core/CanvasSpec.js +++ b/test/spec/core/CanvasSpec.js @@ -135,6 +135,23 @@ describe('Canvas', function() { expect(canvas._cachedViewbox).not.to.exist; })); + + it('should remove planes', inject(function(canvas, elementRegistry) { + + // given + canvas.createPlane('a'); + canvas.createPlane('b'); + canvas.setActivePlane('b'); + + // when + canvas._clear(); + + // then + expect(canvas.getPlane('a')).not.to.exist; + expect(canvas.getPlane('b')).not.to.exist; + expect(canvas.getActivePlane().name).to.eql('base'); + })); + }); @@ -2110,6 +2127,19 @@ describe('Canvas', function() { expect(plane).to.eq(originalPlane); })); + + it('should not return a non-existent plane', inject(function(canvas) { + + // given + canvas.createPlane('a'); + + // when + var plane = canvas.getPlane('b'); + + // then + expect(plane).not.to.exist; + })); + });