fix memory leak. close #198

This commit is contained in:
Anton Lavrenov
2017-01-10 08:27:32 -05:00
parent 523e7ebe90
commit e523c86ebd
5 changed files with 44 additions and 5 deletions

View File

@@ -2557,6 +2557,32 @@ suite('Node', function() {
assert.equal(circle.getParent(), undefined);
});
// ======================================================
test('memory leak test for destroy and a shape with several names', function() {
var stage = addStage();
var layer = new Konva.Layer();
var circle = new Konva.Circle({
x: stage.getWidth() / 2,
y: stage.getHeight() / 2,
radius: 70,
fill: 'green',
stroke: 'black',
strokeWidth: 4,
name: 'my-new-shape my-new-circle'
});
layer.add(circle);
stage.add(layer);
assert.equal(Konva.names['my-new-shape'].length, 1);
assert.equal(Konva.names['my-new-circle'].length, 1);
circle.destroy();
assert.equal(Konva.names['my-new-shape'], undefined);
assert.equal(Konva.names['my-new-circle'], undefined);
});
// ======================================================
test('destroy shape without adding its parent to stage', function() {
var stage = addStage();