mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 06:07:13 +08:00
refined global object temp nodes has removal when removing nodes from container. Also added another unit test
This commit is contained in:
parent
2035d188c8
commit
4f36b27199
6
dist/kinetic-core.js
vendored
6
dist/kinetic-core.js
vendored
@ -873,8 +873,10 @@ Kinetic.Container.prototype = {
|
|||||||
_remove: function(child) {
|
_remove: function(child) {
|
||||||
if(this.children[child.index]._id == child._id) {
|
if(this.children[child.index]._id == child._id) {
|
||||||
var stage = this.getStage();
|
var stage = this.getStage();
|
||||||
stage._removeId(child);
|
if(stage !== undefined) {
|
||||||
stage._removeName(child);
|
stage._removeId(child);
|
||||||
|
stage._removeName(child);
|
||||||
|
}
|
||||||
|
|
||||||
var go = Kinetic.GlobalObject;
|
var go = Kinetic.GlobalObject;
|
||||||
for(var n = 0; n < go.tempNodes.length; n++) {
|
for(var n = 0; n < go.tempNodes.length; n++) {
|
||||||
|
4
dist/kinetic-core.min.js
vendored
4
dist/kinetic-core.min.js
vendored
File diff suppressed because one or more lines are too long
@ -34,8 +34,10 @@ Kinetic.Container.prototype = {
|
|||||||
_remove: function(child) {
|
_remove: function(child) {
|
||||||
if(this.children[child.index]._id == child._id) {
|
if(this.children[child.index]._id == child._id) {
|
||||||
var stage = this.getStage();
|
var stage = this.getStage();
|
||||||
stage._removeId(child);
|
if(stage !== undefined) {
|
||||||
stage._removeName(child);
|
stage._removeId(child);
|
||||||
|
stage._removeName(child);
|
||||||
|
}
|
||||||
|
|
||||||
var go = Kinetic.GlobalObject;
|
var go = Kinetic.GlobalObject;
|
||||||
for(var n = 0; n < go.tempNodes.length; n++) {
|
for(var n = 0; n < go.tempNodes.length; n++) {
|
||||||
|
@ -381,6 +381,40 @@ Test.prototype.tests = {
|
|||||||
test(stage.ids.myCircle === undefined, 'circle still in hash');
|
test(stage.ids.myCircle === undefined, 'circle still in hash');
|
||||||
test(stage.names.myRect[0] === undefined, 'rect still in hash');
|
test(stage.names.myRect[0] === undefined, 'rect still in hash');
|
||||||
|
|
||||||
|
},
|
||||||
|
'STAGE - remove shape without adding its parent to stage': function(containerId) {
|
||||||
|
var stage = new Kinetic.Stage({
|
||||||
|
container: containerId,
|
||||||
|
width: 578,
|
||||||
|
height: 200
|
||||||
|
});
|
||||||
|
var layer = new Kinetic.Layer();
|
||||||
|
var circle = new Kinetic.Circle({
|
||||||
|
x: stage.getWidth() / 2,
|
||||||
|
y: stage.getHeight() / 2,
|
||||||
|
radius: 70,
|
||||||
|
fill: 'green',
|
||||||
|
stroke: 'black',
|
||||||
|
strokeWidth: 4,
|
||||||
|
id: 'myCircle'
|
||||||
|
});
|
||||||
|
|
||||||
|
var go = Kinetic.GlobalObject;
|
||||||
|
|
||||||
|
test(go.tempNodes.length === 0, 'shouldn\'t be nodes in the tempNdoes array');
|
||||||
|
|
||||||
|
layer.add(circle);
|
||||||
|
|
||||||
|
var node = stage.get('#myCircle');
|
||||||
|
|
||||||
|
test(node === undefined, 'node should be undefined');
|
||||||
|
|
||||||
|
test(go.tempNodes.length === 1, 'tempNodes array should have one node');
|
||||||
|
|
||||||
|
layer.remove(circle);
|
||||||
|
|
||||||
|
test(go.tempNodes.length === 0, 'shouldn\'t be nodes in the tempNdoes array');
|
||||||
|
|
||||||
},
|
},
|
||||||
'STAGE - remove layer with shape': function(containerId) {
|
'STAGE - remove layer with shape': function(containerId) {
|
||||||
var stage = new Kinetic.Stage({
|
var stage = new Kinetic.Stage({
|
||||||
|
Loading…
Reference in New Issue
Block a user