From d0301a7f1c514dd19f59de41327639548da81ae1 Mon Sep 17 00:00:00 2001 From: lang Date: Thu, 12 Mar 2015 16:58:56 +0800 Subject: [PATCH] splice -1 bugfix, fix ecomfe/echarts#1352 --- src/Group.js | 4 +++- src/zrender.js | 10 ++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Group.js b/src/Group.js index b52485d85..a5957649b 100644 --- a/src/Group.js +++ b/src/Group.js @@ -131,7 +131,9 @@ define(function(require) { Group.prototype.removeChild = function(child) { var idx = util.indexOf(this._children, child); - this._children.splice(idx, 1); + if (idx >= 0) { + this._children.splice(idx, 1); + } child.parent = null; if (this._storage) { diff --git a/src/zrender.js b/src/zrender.js index 894b6dc2c..e4924f5a8 100644 --- a/src/zrender.js +++ b/src/zrender.js @@ -425,7 +425,10 @@ define( var animator = this.animation.animate(target, { loop: loop }) .done(function () { - animators.splice(el.__animators.indexOf(animator), 1); + var idx = util.indexOf(el.__animators, animator); + if (idx >= 0) { + animators.splice(idx, 1); + } if (animators.length === 0) { // 从animatingElements里移除 var idx = util.indexOf(animatingElements, el); @@ -454,7 +457,10 @@ define( } if (len > 0) { var animatingElements = this.animatingElements; - animatingElements.splice(animatingElements.indexOf(el), 1); + var idx = util.indexOf(animatingElements, el); + if (idx >= 0) { + animatingElements.splice(idx, 1); + } } animators.length = 0;