fineui是帆软报表和BI产品线所使用的前端框架。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.9 KiB

4 years ago
!function () {
var patch = BI.Snabbdom.init([BI.Snabbdom.attributesModule, BI.Snabbdom.classModule, BI.Snabbdom.datasetModule, BI.Snabbdom.propsModule, BI.Snabbdom.styleModule, BI.Snabbdom.eventListenersModule]);
4 years ago
BI.Element2Vnode = function (parentNode) {
4 years ago
if (parentNode.nodeType === 3) {
4 years ago
return BI.Snabbdom.vnode(undefined, undefined, undefined, parentNode.textContent, parentNode);
4 years ago
}
var data = BI.jQuery._data(parentNode);
var on = {};
BI.each(data && data.events, function (eventName, events) {
on[eventName] = function () {
var ob = this, args = arguments;
BI.each(events, function (i, ev) {
ev.handler.apply(ob, args);
});
};
});
4 years ago
var attrs = {};
var elmAttrs = parentNode.attributes;
var elmChildren = parentNode.childNodes;
4 years ago
var key = parentNode.getAttribute("key");
4 years ago
for (i = 0, n = elmAttrs.length; i < n; i++) {
var name = elmAttrs[i].nodeName;
if (name !== "id" && name !== "class") {
attrs[name] = elmAttrs[i].nodeValue;
}
}
var vnode = BI.Snabbdom.vnode(parentNode.nodeName, {
4 years ago
class: BI.makeObject(parentNode.classList),
4 years ago
attrs: attrs,
4 years ago
key: key,
4 years ago
on: on,
hook: {
create: function () {
4 years ago
BI.each(BI.Widget._renderEngine.createElement(parentNode).data("__widgets"), function (i, w) {
4 years ago
w.element = BI.Widget._renderEngine.createElement(vnode.elm);
4 years ago
});
}
}
4 years ago
}, BI.map(elmChildren, function (i, childNode) {
return BI.Element2Vnode(childNode);
}), undefined, parentNode);
4 years ago
return vnode;
};
BI.patchVNode = function (element, node) {
patch(element, node);
};
}();