From c87237089712a2f5aba49f3f64c4a7f0cef0af21 Mon Sep 17 00:00:00 2001 From: zsmj1994 Date: Tue, 9 Mar 2021 19:04:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20revert:=205fb?= =?UTF-8?q?75ef130a517e53b39421b384fa27914ccf0e0=20[5fb75ef]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/wrapper/layout.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index 20f68850c..5d4fdc470 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -71,13 +71,12 @@ BI.Layout = BI.inherit(BI.Widget, { var self = this; var frag = BI.Widget._renderEngine.createFragment(); var hasChild = false; - for (var key in this._children) { - var child = this._children[key]; - if (child.element !== self.element) { - frag.appendChild(child.element[0]); + BI.each(this._children, function (i, widget) { + if (widget.element !== self.element) { + frag.appendChild(widget.element[0]); hasChild = true; } - } + }); if (hasChild === true) { this.appendFragment(frag); } @@ -269,13 +268,19 @@ BI.Layout = BI.inherit(BI.Widget, { if (!child.shouldUpdate) { return null; } - return child.shouldUpdate(this._getOptions(item)); + return child.shouldUpdate(this._getOptions(item)) === true; }, updateItemAt: function (index, item) { if (index < 0 || index > this.options.items.length - 1) { return; } + + var child = this._children[this._getChildName(index)]; + var updated; + if (updated = child.update(this._getOptions(item))) { + return updated; + } var del = this._children[this._getChildName(index)]; delete this._children[this._getChildName(index)]; this.options.items.splice(index, 1); @@ -362,14 +367,7 @@ BI.Layout = BI.inherit(BI.Widget, { patchItem: function (oldVnode, vnode, index) { var shouldUpdate = this.shouldUpdateItem(index, vnode); - var child = this._children[this._getChildName(index)]; - if (shouldUpdate) { - return child._update(this._getOptions(vnode), shouldUpdate); - } - if (shouldUpdate === null && !this._compare(oldVnode, vnode)) { - // if (child.update) { - // return child.update(this._getOptions(vnode)); - // } + if (shouldUpdate === true || (shouldUpdate === null && !this._compare(oldVnode, vnode))) { return this.updateItemAt(index, vnode); } },