Browse Source

Pull request #1805: 无JIRA任务 减少一点点的函数调用

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

* commit '7721039ecc07d045f805000bf28eb0782c8a5dc4':
  减少一点点的函数调用
es6
guy 4 years ago
parent
commit
9bd93530b4
  1. 18
      src/core/widget.js
  2. 9
      src/core/wrapper/layout.js

18
src/core/widget.js

@ -246,11 +246,12 @@
layer = layer || 0;
lifeHook !== false && callLifeHook(this, "beforeMount");
this._isMounted = true;
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);
});
for (var key in this._children) {
var child = this._children[key];
!self.isEnabled() && child._setEnable(false);
!self.isValid() && child._setValid(false);
child._mount && child._mount(deep ? force : false, deep, lifeHook, predicate, layer + 1);
}
this._mountChildren && this._mountChildren();
if (layer === 0) {
// 最后再统一执行生命周期
@ -261,9 +262,10 @@
__afterMount: function (lifeHook, predicate) {
if (this._isMounted) {
BI.each(this._children, function (i, widget) {
widget.__afterMount && widget.__afterMount(lifeHook, predicate);
});
for (var key in this._children) {
var child = this._children[key];
child.__afterMount && child.__afterMount(lifeHook, predicate);
}
lifeHook !== false && callLifeHook(this, "mounted");
this.fireEvent(BI.Events.MOUNT);
predicate && predicate(this);

9
src/core/wrapper/layout.js

@ -71,12 +71,13 @@ BI.Layout = BI.inherit(BI.Widget, {
var self = this;
var frag = BI.Widget._renderEngine.createFragment();
var hasChild = false;
BI.each(this._children, function (i, widget) {
if (widget.element !== self.element) {
frag.appendChild(widget.element[0]);
for (var key in this._children) {
var child = this._children[key];
if (child.element !== self.element) {
frag.appendChild(child.element[0]);
hasChild = true;
}
});
}
if (hasChild === true) {
this.appendFragment(frag);
}

Loading…
Cancel
Save