Browse Source

feature: listeners支持传对象

es6
guy 2 years ago
parent
commit
5dd22609b5
  1. 16
      src/core/5.inject.js

16
src/core/5.inject.js

@ -449,7 +449,7 @@
} else if (item.el && (item.el.type || options.type)) { } else if (item.el && (item.el.type || options.type)) {
el = BI.extend({}, options, item.el); el = BI.extend({}, options, item.el);
} }
if (el) { if (el) {
var elType = (el.type && el.type.xtype) || el.type; var elType = (el.type && el.type.xtype) || el.type;
runConfigFunction(elType); runConfigFunction(elType);
@ -471,12 +471,18 @@
var wType = (w.type && w.type.xtype) || w.type; var wType = (w.type && w.type.xtype) || w.type;
if (wType === elType) { if (wType === elType) {
if (BI.Plugin.hasObject(elType)) { if (BI.Plugin.hasObject(elType)) {
w.listeners = (w.listeners || []).concat([{ if (!w.listeners || BI.isArray(w.listeners)) {
eventName: BI.Events.MOUNT, w.listeners = (w.listeners || []).concat([{
action: function () { eventName: BI.Events.MOUNT,
action: function () {
BI.Plugin.getObject(elType, this);
}
}]);
} else {
w.listeners[BI.Events.MOUNT] = function () {
BI.Plugin.getObject(elType, this); BI.Plugin.getObject(elType, this);
} }
}]); }
} }
return createWidget(w, context, lazy); return createWidget(w, context, lazy);
} }

Loading…
Cancel
Save