|
|
|
@ -12122,7 +12122,32 @@ _.extend(BI.OB.prototype, {
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
BI.mount = function (widget, container, predicate) { |
|
|
|
|
BI.mount = function (widget, container, predicate, hydrate) { |
|
|
|
|
if(hydrate === true){ |
|
|
|
|
// 将widget的element元素都挂载好
|
|
|
|
|
var res = widget._mount(true, false, false, function(w){ |
|
|
|
|
var ws = w.element.data("__widgets"); |
|
|
|
|
if(!ws) { |
|
|
|
|
ws = []; |
|
|
|
|
} |
|
|
|
|
ws.push(w); |
|
|
|
|
w.element.data("__widgets", ws); |
|
|
|
|
}); |
|
|
|
|
// 将新的dom树属性(事件等)patch到已存在的dom上
|
|
|
|
|
var c = BI.Widget._renderEngine.createElement; |
|
|
|
|
BI.DOM.patchProps(widget.element, c(c(container).children()[0])); |
|
|
|
|
|
|
|
|
|
var triggerLifeHook = function (w) { |
|
|
|
|
w.beforeMount && w.beforeMount(); |
|
|
|
|
w.mounted && w.mounted(); |
|
|
|
|
BI.each(w._children, function (i, child) { |
|
|
|
|
triggerLifeHook(child); |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
//最后触发组件树生命周期函数
|
|
|
|
|
triggerLifeHook(widget); |
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
if (container) { |
|
|
|
|
BI.Widget._renderEngine.createElement(container).append(widget.element); |
|
|
|
|
} |
|
|
|
@ -18497,9 +18522,30 @@ BI.prepares.push(function () {
|
|
|
|
|
* 对DOM操作的通用函数 |
|
|
|
|
* @type {{}} |
|
|
|
|
*/ |
|
|
|
|
BI.DOM = {}; |
|
|
|
|
BI.extend(BI.DOM, { |
|
|
|
|
!(function () { |
|
|
|
|
BI.DOM = {}; |
|
|
|
|
BI.extend(BI.DOM, { |
|
|
|
|
|
|
|
|
|
patchProps: function (fromElement, toElement) { |
|
|
|
|
var elemData = jQuery._data(fromElement[0]); |
|
|
|
|
var events = elemData.events; |
|
|
|
|
BI.each(events, function (eventKey, event) { |
|
|
|
|
var handlers = event.handlers; |
|
|
|
|
BI.each(handlers, function (i, handler) { |
|
|
|
|
toElement.on(eventKey, handler); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
var fromChildren = fromElement.children(), toChildren = toElement.children(); |
|
|
|
|
if(fromChildren.length !== toChildren.length) { |
|
|
|
|
throw new Error("不匹配"); |
|
|
|
|
} |
|
|
|
|
BI.each(fromChildren, function (i, child) { |
|
|
|
|
BI.DOM.patchProps(jQuery(child), jQuery(toChildren[i])); |
|
|
|
|
}); |
|
|
|
|
BI.each(fromElement.data("__widgets"), function (i, widget) { |
|
|
|
|
widget.element = toElement; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
/** |
|
|
|
|
* 把dom数组或元素悬挂起来,使其不对html产生影响 |
|
|
|
|
* @param dom |
|
|
|
@ -18746,7 +18792,8 @@ BI.extend(BI.DOM, {
|
|
|
|
|
param: param |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
});BI.EventListener = { |
|
|
|
|
}); |
|
|
|
|
})();BI.EventListener = { |
|
|
|
|
listen: function listen (target, eventType, callback) { |
|
|
|
|
if (target.addEventListener) { |
|
|
|
|
target.addEventListener(eventType, callback, false); |
|
|
|
|