Browse Source

Revert "优化一下context的传递"

This reverts commit e0311e8d2f.

# Conflicts:
#	src/core/base.js
#	src/core/shortcut.js
#	src/core/widget.js
es6
guy 4 years ago
parent
commit
c627070cb8
  1. 4
      dist/fix/fix.compact.ie.js
  2. 4
      dist/fix/fix.compact.js
  3. 30
      examples/dev.html
  4. 4
      src/core/base.js
  5. 5
      src/core/shortcut.js
  6. 11
      src/core/widget.js

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

@ -82,7 +82,7 @@
if (p instanceof Fix.Model || p.store || p.__cacheStore) {
break;
}
p = p._context || p._parent || (p.options && p.options.element);
p = p._parent || (p.options && p.options.element);
}
if (p) {
if (p instanceof Fix.Model) {
@ -121,7 +121,7 @@
function createStore () {
var needPop = false;
if (_global.Fix && this._store) {
var store = findStore(this.options.context || p._context || this._parent || this.options.element);
var store = findStore(this.options.context || this._parent || this.options.element);
if (store) {
pushTarget(store);
needPop = true;

4
dist/fix/fix.compact.js vendored

@ -86,7 +86,7 @@
if (p instanceof Fix.Model || p.store || p.__cacheStore) {
break;
}
p = p._context || p._parent || (p.options && p.options.element);
p = p._parent || (p.options && p.options.element);
}
if (p) {
if (p instanceof Fix.Model) {
@ -134,7 +134,7 @@
function createStore () {
var needPop = false;
if (_global.Fix && this._store) {
var store = findStore(this.options.context || this._context || this._parent || this.options.element);
var store = findStore(this.options.context || this._parent || this.options.element);
if (store) {
pushTarget(store);
needPop = true;

30
examples/dev.html

@ -45,8 +45,14 @@
return {
render: function () {
return {
type: "bi.button",
text: store.model.text
type: "bi.vertical",
items: [{
type: "bi.button",
text: store.model.text
}, {
type: "bi.label",
text: store.model.text
}]
};
}
};
@ -67,7 +73,7 @@
store.toggle();
}, 1000);
BI.watch("text", function () {
// child.reset();
child.populate();
});
return function () {
return {
@ -79,23 +85,7 @@
child = _ref;
}
}, {
type: "bi.combo",
el: {
type: "bi.button",
text: "点击"
},
popup: {
el: {
type: "bi.tab",
height: 100,
showIndex: 0,
cardCreator: function () {
return {
type: "demo.child"
};
}
}
}
type: "demo.child"
}]
};
};

4
src/core/base.js

@ -70,7 +70,7 @@ if (!_global.BI) {
},
isWidget: function (widget) {
return widget instanceof BI.Widget;
return widget instanceof BI.Widget || (BI.View && widget instanceof BI.View);
},
createWidgets: function (items, options, context) {
@ -107,7 +107,7 @@ if (!_global.BI) {
el: innerAttr.shift()
});
}
if (item.el instanceof BI.Widget) {
if (item.el instanceof BI.Widget || (BI.View && item.el instanceof BI.View)) {
innerAttr.shift();
return BI.extend({}, outerAttr.shift(), { type: null }, item);
}

5
src/core/shortcut.js

@ -18,12 +18,11 @@
throw new Error("组件" + config.type + "未定义");
}
var pushed = false;
var widget = new cls();
widget._context = BI.Widget.context || context;
if (!BI.Widget.context && context) {
if (context) {
pushed = true;
BI.Widget.pushContext(context);
}
var widget = new cls();
widget._initProps(config);
widget._constructed();
widget._initRoot();

11
src/core/widget.js

@ -152,9 +152,16 @@
this._children = {};
if (BI.isWidget(o.element)) {
this.element = this.options.element.element;
this._parent = o.element;
this._parent.addWidget(this.widgetName, this);
if (o.element instanceof BI.Widget) {
this._parent = o.element;
this._parent.addWidget(this.widgetName, this);
} else {
this._isRoot = true;
}
} else if (o.element) {
// if (o.root !== true) {
// throw new Error("root is a required property");
// }
this.element = BI.Widget._renderEngine.createElement(this);
this._isRoot = true;
} else {

Loading…
Cancel
Save