Skip to content

Commit d0301a7

Browse files
committed
splice -1 bugfix, fix apache/echarts#1352
1 parent 2ad6042 commit d0301a7

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/Group.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ define(function(require) {
131131
Group.prototype.removeChild = function(child) {
132132
var idx = util.indexOf(this._children, child);
133133

134-
this._children.splice(idx, 1);
134+
if (idx >= 0) {
135+
this._children.splice(idx, 1);
136+
}
135137
child.parent = null;
136138

137139
if (this._storage) {

src/zrender.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,10 @@ define(
425425

426426
var animator = this.animation.animate(target, { loop: loop })
427427
.done(function () {
428-
animators.splice(el.__animators.indexOf(animator), 1);
428+
var idx = util.indexOf(el.__animators, animator);
429+
if (idx >= 0) {
430+
animators.splice(idx, 1);
431+
}
429432
if (animators.length === 0) {
430433
// 从animatingElements里移除
431434
var idx = util.indexOf(animatingElements, el);
@@ -454,7 +457,10 @@ define(
454457
}
455458
if (len > 0) {
456459
var animatingElements = this.animatingElements;
457-
animatingElements.splice(animatingElements.indexOf(el), 1);
460+
var idx = util.indexOf(animatingElements, el);
461+
if (idx >= 0) {
462+
animatingElements.splice(idx, 1);
463+
}
458464
}
459465

460466
animators.length = 0;

0 commit comments

Comments
 (0)