remove Konva.names and Konva.ids. close #1073

This commit is contained in:
Anton Lavrenov
2021-05-06 15:25:12 -05:00
parent ef6fbf2e14
commit 386287eebe
7 changed files with 14 additions and 358 deletions

View File

@@ -709,71 +709,6 @@ describe('Container', function () {
assert.equal(a, 2, 'listener should have fired for rect');
});
// ======================================================
it('test ids and names hashes', function () {
var stage = addStage();
var layer = new Konva.Layer();
var circle = new Konva.Circle({
x: stage.width() / 2,
y: stage.height() / 2,
radius: 70,
fill: 'green',
stroke: 'black',
strokeWidth: 4,
id: 'myCircle3',
});
var rect = new Konva.Rect({
x: 300,
y: 100,
width: 100,
height: 50,
fill: 'purple',
stroke: 'black',
strokeWidth: 4,
name: 'myRect3',
});
layer.add(circle);
layer.add(rect);
stage.add(layer);
assert.equal(
Konva.ids['myCircle3'].getId(),
'myCircle3',
'circle id not in ids hash'
);
assert.equal(
Konva.names['myRect3'][0].getName(),
'myRect3',
'rect name not in names hash'
);
circle.setId('newCircleId');
assert.notEqual(
Konva.ids['newCircleId'],
undefined,
'circle not in ids hash'
);
assert.equal(
Konva.ids['myCircle3'],
undefined,
'old circle id key is still in ids hash'
);
rect.setName('newRectName');
assert.notEqual(
Konva.names['newRectName'][0],
undefined,
'new rect name not in names hash'
);
assert.equal(
Konva.names['myRect3'],
undefined,
'old rect name is still in names hash'
);
});
// ======================================================
it('remove all children from layer', function () {
var stage = addStage();
@@ -816,68 +751,6 @@ describe('Container', function () {
);
});
// ======================================================
it('destroy all children from layer', function () {
var stage = addStage();
var layer = new Konva.Layer({
name: 'layerName',
id: 'layerId',
});
var group = new Konva.Group();
var circle1 = new Konva.Circle({
x: 100,
y: stage.height() / 2,
radius: 70,
fill: 'green',
stroke: 'black',
strokeWidth: 4,
name: 'circleName',
id: 'circleId',
});
var circle2 = new Konva.Circle({
x: 300,
y: stage.height() / 2,
radius: 70,
fill: 'green',
stroke: 'black',
strokeWidth: 4,
});
group.add(circle1);
group.add(circle2);
layer.add(group);
stage.add(layer);
assert.equal(layer.children.length, 1, 'layer should have 1 children');
assert.equal(group.children.length, 2, 'group should have 2 children');
assert(
Konva.names.circleName.length > 0,
'circleName should be in names hash'
);
assert.equal(
Konva.ids.circleId.getId(),
'circleId',
'layerId should be in ids hash'
);
layer.destroyChildren();
layer.draw();
assert.equal(layer.children.length, 0, 'layer should have 0 children');
assert.equal(group.children.length, 0, 'group should have 0 children');
assert.equal(
Konva.names.circleName,
undefined,
'circleName should not be in names hash'
);
assert.equal(
Konva.ids.circleId,
undefined,
'layerId should not be in ids hash'
);
});
// ======================================================
it('add group', function () {
var stage = addStage();