diff --git a/src/core/4.widget.js b/src/core/4.widget.js index f9f18c253..c3d1e0bc5 100644 --- a/src/core/4.widget.js +++ b/src/core/4.widget.js @@ -129,7 +129,6 @@ renderCallbackCalled = true; self._render(); self.__afterRender(); - self.__async = false; } if (self.options.beforeRender || self.beforeRender) { @@ -151,11 +150,15 @@ __afterRender: function () { pushTarget(this); - this.__async === true && this._isMounted && callLifeHook(this, "beforeMount"); - this._mount(); - if (this.__async === true && this._isMounted) { + var async = this.__async; + this.__async = false; + if (async && this._isMounted) { + callLifeHook(this, "beforeMount"); + this._mount(); callLifeHook(this, "mounted"); this.fireEvent(BI.Events.MOUNT); + } else { + this._mount(); } popTarget(); }, @@ -330,49 +333,6 @@ } }, - // _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; }, @@ -806,7 +766,7 @@ BI.onBeforeMount = function (beforeMount) { if (current) { - if(current.__isMounting){ + if (current.__isMounting) { beforeMount(); return; } @@ -820,7 +780,7 @@ }; BI.onMounted = function (mounted) { if (current) { - if(current._isMounted && !this.__async){ + if (current._isMounted && !this.__async) { mounted(); return; }