mirror of
https://github.com/konvajs/konva.git
synced 2025-11-24 08:46:44 +08:00
fix memory leak. close #198
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user