diff --git a/src/Stage.js b/src/Stage.js index d1931816..81944653 100644 --- a/src/Stage.js +++ b/src/Stage.js @@ -153,6 +153,10 @@ if(content && Kinetic.Util._isInDocument(content)) { this.getContainer().removeChild(content); } + var index = Kinetic.stages.indexOf(this); + if (index > -1) { + Kinetic.stages.splice(index, 1); + } }, /** * get pointer position which can be a touch position or mouse position diff --git a/test/unit/Stage-test.js b/test/unit/Stage-test.js index 99b393f3..645202d1 100644 --- a/test/unit/Stage-test.js +++ b/test/unit/Stage-test.js @@ -403,6 +403,7 @@ suite('Stage', function() { assert.equal(Kinetic.names.stageFalconName, undefined, 'stage should no longer be in names map'); assert.equal(Kinetic.ids.circleFalconId, undefined, 'circle should no longer be in ids map'); assert.equal(Kinetic.names.circleFalconName, undefined, 'circle should no longer be in names map'); + assert.equal(Kinetic.stages.indexOf(stage) === -1, true, 'stage should not be in stages array'); });