From 6c46e44bbd2ba88fd3d8f63f71d8f9fa1606f8a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B0=D0=B2=D1=80=D1=91=D0=BD=D0=BE=D0=B2=20=D0=90?= =?UTF-8?q?=D0=BD=D1=82=D0=BE=D0=BD?= Date: Thu, 27 Feb 2014 22:53:30 +0800 Subject: [PATCH] fix #500 --- src/Stage.js | 4 ++++ test/unit/Stage-test.js | 1 + 2 files changed, 5 insertions(+) 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'); });