From 62d49508961b5201669648bed02963741de1dfbd Mon Sep 17 00:00:00 2001 From: guy Date: Sun, 12 Sep 2021 15:27:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/4.widget.js | 124 +++++++++++++++++++++---------------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/src/core/4.widget.js b/src/core/4.widget.js index 923849a6e..539ad078d 100644 --- a/src/core/4.widget.js +++ b/src/core/4.widget.js @@ -40,7 +40,7 @@ cls: "", css: null, - vdom: false + // vdom: false }); }, @@ -195,9 +195,9 @@ this.element = BI.Widget._renderEngine.createElement(this); } this.element._isWidget = true; - var widgets = this.element.data("__widgets") || []; - widgets.push(this); - this.element.data("__widgets", widgets); + // var widgets = this.element.data("__widgets") || []; + // widgets.push(this); + // this.element.data("__widgets", widgets); this._initCurrent(); }, @@ -243,52 +243,7 @@ var self = this; var isMounted = this._isMounted; this.__async === true && isMounted && callLifeHook(this, "beforeMount"); - if (!this._initVNode()) { - var render = BI.isFunction(this.options.render) ? this.options.render : this.render; - var els = render && render.call(this); - els = BI.Plugin.getRender(this.options.type, els); - if (BI.isPlainObject(els)) { - els = [els]; - } - if (BI.isArray(els)) { - BI.each(els, function (i, el) { - if (el) { - BI._lazyCreateWidget(el, { - element: self - }); - } - }); - } - } - this._mount(); - if (this.__async === true && isMounted) { - callLifeHook(this, "mounted"); - this.fireEvent(BI.Events.MOUNT); - } - }, - - _initVNode: function () { - if (this.options.vdom) { - var div = document.createElement("div"); - var element = this.element; - element.append(div); - this.vnode = this._renderVNode(); - BI.patchVNode(div, this.vnode); - // 去除这个临时的div - BI.DOM.hang([div]); - element.attr("style", this.vnode.elm.getAttribute("style")); - element.addClass(this.vnode.elm.getAttribute("class")); - element.empty(); - BI.each(BI.jQuery(this.vnode.elm).children(), function (i, node) { - element.append(node); - }); - return true; - } - return false; - }, - - _renderVNode: function () { - var self = this; + // if (!this._initVNode()) { var render = BI.isFunction(this.options.render) ? this.options.render : this.render; var els = render && render.call(this); els = BI.Plugin.getRender(this.options.type, els); @@ -296,20 +251,65 @@ els = [els]; } if (BI.isArray(els)) { - var container = document.createElement("div"); - this._children = {}; BI.each(els, function (i, el) { if (el) { - var w = BI._lazyCreateWidget(el, { - element: container + BI._lazyCreateWidget(el, { + element: self }); - self.addWidget(w); } }); } - return BI.Element2Vnode(container); + // } + this._mount(); + if (this.__async === true && isMounted) { + callLifeHook(this, "mounted"); + this.fireEvent(BI.Events.MOUNT); + } }, + // _initVNode: function () { + // if (this.options.vdom) { + // var div = document.createElement("div"); + // var element = this.element; + // element.append(div); + // this.vnode = this._renderVNode(); + // BI.patchVNode(div, this.vnode); + // // 去除这个临时的div + // BI.DOM.hang([div]); + // element.attr("style", this.vnode.elm.getAttribute("style")); + // element.addClass(this.vnode.elm.getAttribute("class")); + // element.empty(); + // BI.each(BI.jQuery(this.vnode.elm).children(), function (i, node) { + // element.append(node); + // }); + // return true; + // } + // return false; + // }, + + // _renderVNode: function () { + // var self = this; + // var render = BI.isFunction(this.options.render) ? this.options.render : this.render; + // var els = render && render.call(this); + // els = BI.Plugin.getRender(this.options.type, els); + // if (BI.isPlainObject(els)) { + // els = [els]; + // } + // if (BI.isArray(els)) { + // var container = document.createElement("div"); + // this._children = {}; + // BI.each(els, function (i, el) { + // if (el) { + // var w = BI._lazyCreateWidget(el, { + // element: container + // }); + // self.addWidget(w); + // } + // }); + // } + // return BI.Element2Vnode(container); + // }, + _setParent: function (parent) { this._parent = parent; }, @@ -647,12 +647,12 @@ if (this.__async === true || this.__asking === true) { return; } - if (this.options.vdom) { - var vnode = this._renderVNode(); - BI.patchVNode(this.vnode, vnode); - this.vnode = vnode; - return; - } + // if (this.options.vdom) { + // var vnode = this._renderVNode(); + // BI.patchVNode(this.vnode, vnode); + // this.vnode = vnode; + // return; + // } // this._isMounted = false; // this.purgeListeners(); this._empty();