mirror of
https://github.com/konvajs/konva.git
synced 2025-08-20 06:40:18 +08:00
Fixed possible crash on node.to()
method. close #1944
This commit is contained in:
parent
cad1c0ee0f
commit
750484b0ad
@ -3,6 +3,10 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## 9.3.22 (2025-07-08)
|
||||
|
||||
- Fixed possible crash on `node.to()` method
|
||||
|
||||
## 9.3.21 (2025-07-07)
|
||||
|
||||
- Fixed memory leaks on Tween destroy
|
||||
|
12
src/Tween.ts
12
src/Tween.ts
@ -530,11 +530,13 @@ export class Tween {
|
||||
delete Tween.attrs[nodeId][thisId];
|
||||
|
||||
// Clean up parent objects if empty
|
||||
if (Object.keys(Tween.tweens[nodeId]).length === 0) {
|
||||
delete Tween.tweens[nodeId];
|
||||
}
|
||||
if (Object.keys(Tween.attrs[nodeId]).length === 0) {
|
||||
delete Tween.attrs[nodeId];
|
||||
if (Tween.tweens[nodeId]) {
|
||||
if (Object.keys(Tween.tweens[nodeId]).length === 0) {
|
||||
delete Tween.tweens[nodeId];
|
||||
}
|
||||
if (Object.keys(Tween.attrs[nodeId]).length === 0) {
|
||||
delete Tween.attrs[nodeId];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -257,6 +257,34 @@ describe('Tween', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('to method double simple usage', function (done) {
|
||||
var stage = addStage();
|
||||
|
||||
let finishCount = 0;
|
||||
const onFinish = () => {
|
||||
if (finishCount === 2) {
|
||||
done();
|
||||
}
|
||||
};
|
||||
stage.to({
|
||||
x: 10,
|
||||
duration: 0.001,
|
||||
onFinish: () => {
|
||||
assert(stage.x() === 10);
|
||||
finishCount += 1;
|
||||
onFinish();
|
||||
},
|
||||
});
|
||||
stage.to({
|
||||
y: 10,
|
||||
duration: 0.001,
|
||||
onFinish: () => {
|
||||
finishCount += 1;
|
||||
onFinish();
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('tween to call update callback', function (done) {
|
||||
var stage = addStage();
|
||||
var updateCount = 0;
|
||||
@ -303,6 +331,8 @@ describe('Tween', function () {
|
||||
|
||||
line.to({
|
||||
points: [100, 100, 200, 100, 200, 200, 100, 200],
|
||||
// add another attribute for better test of cleanup
|
||||
x: 10,
|
||||
duration: 0.1,
|
||||
onFinish: function () {
|
||||
assert.deepEqual(
|
||||
|
Loading…
Reference in New Issue
Block a user