Browse Source

Pull request #1799: 无JIRA任务 bugfix

Merge in VISUAL/fineui from ~GUY/fineui:master to master

* commit '8641324dd307c2c2ac2b95a079f9faecfd053225':
  update
  update
  update
es6
guy 4 years ago
parent
commit
f7ce1979e4
  1. 73
      dist/fix/fix.compact.ie.js
  2. 2
      dist/fix/fix.compact.js
  3. 20
      src/core/widget.js

73
dist/fix/fix.compact.ie.js vendored

@ -178,6 +178,77 @@
needPop && popTarget();
};
BI.Widget.prototype._initElement = function () {
var self = this;
var render = BI.isFunction(this.options.render) ? this.options.render : this.render;
var els;
if (this.options.updateMode === "auto" && this._store) {
// 自动更新模式
var childComponents = {};
var rendered = false;
this._watchers.push(Fix.watch(this.model, function () {
if (rendered) {
var newEls = render && render.call(this);
BI.each(childComponents, function (i, childComponent) {
if (childComponent.component instanceof BI.Layout) {
return; // 布局的过滤掉
}
var nextProps = BI.get([newEls], childComponent.path);
if (nextProps) {
var shouldUpdate = childComponent.component.shouldUpdate && childComponent.component.shouldUpdate(nextProps);
childComponent.component._update(nextProps, shouldUpdate);
childComponent.props = BI.extend(childComponent.props, nextProps);
}
});
} else {
els = render && render.call(this);
function traverse (parent, path) {
BI.each(parent, function (i, child) {
var childPath = path.concat(i);
if (BI.isArray(child)) {
traverse(child, childPath);
} else if (BI.isPlainObject(child)) {
if (child.type) {
child.__ref = function (_ref) {
if (_ref) {
var comp = childComponents[this.getName()] = {};
comp.component = _ref;
comp.props = child;
comp.path = childPath;
} else {
delete childComponents[this.getName()];
}
};
}
traverse(child, childPath);
}
});
}
traverse([els], []);
rendered = true;
}
}));
} else {
els = render && render.call(this);
}
if (BI.isPlainObject(els)) {
els = [els];
}
if (BI.isArray(els)) {
BI.each(els, function (i, el) {
if (el) {
BI._lazyCreateWidget(el, {
element: self
});
}
});
}
// if (this._isRoot === true || !(this instanceof BI.Layout)) {
this._mount();
};
var unMount = BI.Widget.prototype.__d;
BI.Widget.prototype.__d = function () {
unMount.apply(this, arguments);
@ -197,7 +268,7 @@
delete this.__cacheStore;
};
_.each(["_mount"], function (name) {
_.each(["_mount", "__afterMount"], function (name) {
var old = BI.Widget.prototype[name];
old && (BI.Widget.prototype[name] = function () {
this.store && pushTarget(this.store);

2
dist/fix/fix.compact.js vendored

@ -277,7 +277,7 @@
delete this.__cacheStore;
};
_.each(["_mount"], function (name) {
_.each(["_mount", "__afterMount"], function (name) {
var old = BI.Widget.prototype[name];
old && (BI.Widget.prototype[name] = function () {
this.store && pushTarget(this.store);

20
src/core/widget.js

@ -226,36 +226,32 @@
* @returns {boolean}
* @private
*/
_mount: function (force, deep, lifeHook, predicate, layer, queue) {
_mount: function (force, deep, lifeHook, predicate, layer) {
var self = this;
if (!layer) {
layer = 0;
}
if (!queue) {
queue = [];
}
if (!force && (this._isMounted || !this.isVisible() || this.__asking === true || !(this._isRoot === true || (this._parent && this._parent._isMounted === true)))) {
return false;
}
layer = layer || 0;
lifeHook !== false && callLifeHook(this, "beforeMount");
this._isMounted = true;
queue.push(this);
BI.each(this._children, function (i, widget) {
!self.isEnabled() && widget._setEnable(false);
!self.isValid() && widget._setValid(false);
widget._mount && widget._mount(deep ? force : false, deep, lifeHook, predicate, layer + 1, queue);
widget._mount && widget._mount(deep ? force : false, deep, lifeHook, predicate, layer + 1);
});
this._mountChildren && this._mountChildren();
if (layer === 0) {
BI.each(queue, function (i, w) {
w.__afterMount(lifeHook, predicate);
});
// 最后再统一执行生命周期
this.__afterMount(lifeHook, predicate);
}
return true;
},
__afterMount: function (lifeHook, predicate) {
if (this._isMounted) {
BI.each(this._children, function (i, widget) {
widget.__afterMount && widget.__afterMount(lifeHook, predicate);
});
lifeHook !== false && callLifeHook(this, "mounted");
this.fireEvent(BI.Events.MOUNT);
predicate && predicate(this);

Loading…
Cancel
Save