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

9
src/core/wrapper/layout.js

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

Loading…
Cancel
Save