From 3e8e4cd820c31d9a91e48bf5e1b89be17efa95dc Mon Sep 17 00:00:00 2001 From: guy Date: Sun, 6 Mar 2022 18:33:22 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20items=E5=92=8Cvalue=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E8=87=AA=E5=8A=A8watch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/4.widget.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/core/4.widget.js b/src/core/4.widget.js index 088d644fd..b396acf1e 100644 --- a/src/core/4.widget.js +++ b/src/core/4.widget.js @@ -688,12 +688,17 @@ }, __d: function () { - callLifeHook(this, "beforeDestroy"); - this.beforeDestroy = null; BI.each(this._children, function (i, widget) { widget && widget._unMount && widget._unMount(); }); this._children = {}; + }, + + // 主要是因为_destroy已经提供了protected方法 + __destroy: function () { + callLifeHook(this, "beforeDestroy"); + this.beforeDestroy = null; + this.__d(); this._parent = null; this._isMounted = false; callLifeHook(this, "destroyed"); @@ -701,16 +706,13 @@ }, _unMount: function () { - this.__d(); + this.__destroy(); this.fireEvent(BI.Events.UNMOUNT); this.purgeListeners(); }, _empty: function () { - BI.each(this._children, function (i, widget) { - widget && widget._unMount && widget._unMount(); - }); - this._children = {}; + this.__d(); this.element.empty(); }, @@ -748,14 +750,14 @@ }, _destroy: function () { - this.__d(); + this.__destroy(); this.element.destroy(); this.purgeListeners(); }, destroy: function () { var self = this, o = this.options; - this.__d(); + this.__destroy(); if (o.animation) { this._innerSetVisible(false); setTimeout(function () {