From 34666f397cb902697b8ed74132763183910f5c28 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 2 Mar 2021 19:39:21 +0800 Subject: [PATCH] update --- src/core/widget.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/core/widget.js b/src/core/widget.js index 262a4b4ad..c9f6c03b0 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -226,35 +226,36 @@ * @returns {boolean} * @private */ - _mount: function (force, deep, lifeHook, predicate) { - if (this.__beforeMount(force, deep, lifeHook, predicate)) { - this.__afterMount(lifeHook, predicate); - return true; - } - return false; - }, - - __beforeMount: function (force, deep, lifeHook, predicate) { + _mount: function (force, deep, lifeHook, predicate, layer, queue) { var self = this; + if (!layer) { + layer = 0; + } + if (!queue) { + queue = []; + } if (!force && (this._isMounted || !this.isVisible() || this.__asking === true || !(this._isRoot === true || (this._parent && this._parent._isMounted === true)))) { return false; } lifeHook !== false && callLifeHook(this, "beforeMount"); this._isMounted = true; + queue.push(this); BI.each(this._children, function (i, widget) { !self.isEnabled() && widget._setEnable(false); !self.isValid() && widget._setValid(false); - widget.__beforeMount && widget.__beforeMount(deep ? force : false, deep, lifeHook, predicate); + widget._mount && widget._mount(deep ? force : false, deep, lifeHook, predicate, layer + 1, queue); }); this._mountChildren && this._mountChildren(); + if (layer === 0) { + BI.each(queue, function (i, w) { + w.__afterMount(lifeHook, predicate); + }); + } return true; }, __afterMount: function (lifeHook, predicate) { if (this._isMounted) { - BI.each(this._children, function (i, widget) { - widget.__afterMount && widget.__afterMount(lifeHook, predicate); - }); lifeHook !== false && callLifeHook(this, "mounted"); this.fireEvent(BI.Events.MOUNT); predicate && predicate(this);