This commit is contained in:
dntzhang 2018-11-27 09:24:42 +08:00
parent b0d41ec147
commit 2698e3b1ae
9 changed files with 38 additions and 26 deletions

View File

@ -1,6 +1,6 @@
{
"props": {
"cname": 35,
"cname": 36,
"props": {
"$_dirty": "__d",
"$_disable": "__x",
@ -34,7 +34,8 @@
"$___touchY": "G",
"$___scrollTop": "H",
"$__elementId": "I",
"$_willUpdate": "J"
"$_willUpdate": "J",
"$_preCss": "K"
}
},
"vars": {

View File

@ -1,5 +1,5 @@
/**
* omi v5.0.2 http://omijs.org
* omi v5.0.3 http://omijs.org
* Omi === Preact + Scoped CSS + Store System + Native Support in 3kb javascript.
* By dntzhang https://github.com/dntzhang
* Github: https://github.com/Tencent/omi
@ -713,17 +713,17 @@
will emit
{op: replace, path: '/arr/1', value: arr_2}
{op: remove, path: '/arr/2'}
by default, the second operation would revoke the proxy, and this renders arr revoked.
by default, the second operation would revoke the proxy, and this renders arr revoked.
That's why we need to remember the proxies that are inherited.
*/
var revokableInstance = instance.proxifiedObjectsMap.get(newValue);
/*
Why do we need to check instance.isProxifyingTreeNow?
We need to make sure we mark revokables as inherited ONLY when we're observing,
We need to make sure we mark revokables as inherited ONLY when we're observing,
because throughout the first proxification, a sub-object is proxified and then assigned to
its parent object. This assignment of a pre-proxified object can fool us into thinking
that it's a proxified object moved around, while in fact it's the first assignment ever.
Checking isProxifyingTreeNow ensures this is not happening in the first proxification,
Checking isProxifyingTreeNow ensures this is not happening in the first proxification,
but in fact is is a proxified object moved around the tree
*/
if (revokableInstance && !instance.isProxifyingTreeNow) {
@ -801,7 +801,7 @@
this is an inherited proxy (an already proxified object that was moved around),
we shouldn't revoke it, because even though it was removed from path1, it is still used in path2.
And we know that because we mark moved proxies with `inherited` flag when we move them
it is a good idea to remove this flag if we come across it here, in deleteProperty trap.
it is a good idea to remove this flag if we come across it here, in deleteProperty trap.
We DO want to revoke the proxy if it was removed again.
*/
revokableProxyInstance.inherited = false;
@ -1328,7 +1328,7 @@
args[key] = arguments[key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn$1(this, _WeElement.call.apply(_WeElement, [this].concat(args))), _this), _this._useId = 0, _this._useMap = {}, _temp), _possibleConstructorReturn$1(_this, _ret);
return _ret = (_temp = (_this = _possibleConstructorReturn$1(this, _WeElement.call.apply(_WeElement, [this].concat(args))), _this), _this._useId = 0, _this._useMap = {}, _this._preCss = null, _temp), _possibleConstructorReturn$1(_this, _ret);
}
Element.prototype.render = function render(props, data) {
@ -1340,6 +1340,10 @@
};
Element.prototype.useCss = function useCss(css) {
if (css === this._preCss) {
return;
}
this._preCss = css;
var style = this.shadowRoot.querySelector('style');
style && this.shadowRoot.removeChild(style);
this.shadowRoot.appendChild(cssToDom(css));
@ -1509,7 +1513,7 @@
};
options.root.Omi = omi;
options.root.Omi.version = '5.0.2';
options.root.Omi.version = '5.0.3';
if (typeof module != 'undefined') module.exports = omi;else self.Omi = omi;
}());

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
/**
* omi v5.0.2 http://omijs.org
* omi v5.0.3 http://omijs.org
* Omi === Preact + Scoped CSS + Store System + Native Support in 3kb javascript.
* By dntzhang https://github.com/dntzhang
* Github: https://github.com/Tencent/omi
@ -710,17 +710,17 @@ var JSONPatcherProxy = function () {
will emit
{op: replace, path: '/arr/1', value: arr_2}
{op: remove, path: '/arr/2'}
by default, the second operation would revoke the proxy, and this renders arr revoked.
by default, the second operation would revoke the proxy, and this renders arr revoked.
That's why we need to remember the proxies that are inherited.
*/
var revokableInstance = instance.proxifiedObjectsMap.get(newValue);
/*
Why do we need to check instance.isProxifyingTreeNow?
We need to make sure we mark revokables as inherited ONLY when we're observing,
We need to make sure we mark revokables as inherited ONLY when we're observing,
because throughout the first proxification, a sub-object is proxified and then assigned to
its parent object. This assignment of a pre-proxified object can fool us into thinking
that it's a proxified object moved around, while in fact it's the first assignment ever.
Checking isProxifyingTreeNow ensures this is not happening in the first proxification,
Checking isProxifyingTreeNow ensures this is not happening in the first proxification,
but in fact is is a proxified object moved around the tree
*/
if (revokableInstance && !instance.isProxifyingTreeNow) {
@ -798,7 +798,7 @@ operation.op = 'replace', operation.value = null;
this is an inherited proxy (an already proxified object that was moved around),
we shouldn't revoke it, because even though it was removed from path1, it is still used in path2.
And we know that because we mark moved proxies with `inherited` flag when we move them
it is a good idea to remove this flag if we come across it here, in deleteProperty trap.
it is a good idea to remove this flag if we come across it here, in deleteProperty trap.
We DO want to revoke the proxy if it was removed again.
*/
revokableProxyInstance.inherited = false;
@ -1325,7 +1325,7 @@ function define(name, ctor) {
args[key] = arguments[key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn$1(this, _WeElement.call.apply(_WeElement, [this].concat(args))), _this), _this._useId = 0, _this._useMap = {}, _temp), _possibleConstructorReturn$1(_this, _ret);
return _ret = (_temp = (_this = _possibleConstructorReturn$1(this, _WeElement.call.apply(_WeElement, [this].concat(args))), _this), _this._useId = 0, _this._useMap = {}, _this._preCss = null, _temp), _possibleConstructorReturn$1(_this, _ret);
}
Element.prototype.render = function render(props, data) {
@ -1337,6 +1337,10 @@ function define(name, ctor) {
};
Element.prototype.useCss = function useCss(css) {
if (css === this._preCss) {
return;
}
this._preCss = css;
var style = this.shadowRoot.querySelector('style');
style && this.shadowRoot.removeChild(style);
this.shadowRoot.appendChild(cssToDom(css));
@ -1506,7 +1510,7 @@ var omi = {
};
options.root.Omi = omi;
options.root.Omi.version = '5.0.2';
options.root.Omi.version = '5.0.3';
export default omi;
export { tag, WeElement, Component, render, h, h as createElement, options, define, observe, cloneElement, getHost, rpx, tick, nextTick, ModelView };

File diff suppressed because one or more lines are too long

View File

@ -442,7 +442,7 @@
_classCallCheck$1(this, Element);
for (var _len = arguments.length, args = Array(_len), key = 0; key < _len; key++) args[key] = arguments[key];
return _ret = (_temp = _this = _possibleConstructorReturn$1(this, _WeElement.call.apply(_WeElement, [ this ].concat(args))),
_this.C = 0, _this.D = {}, _temp), _possibleConstructorReturn$1(_this, _ret);
_this.C = 0, _this.D = {}, _this.K = null, _temp), _possibleConstructorReturn$1(_this, _ret);
}
_inherits$1(Element, _WeElement);
Element.prototype.render = function(props, data) {
@ -452,9 +452,12 @@
this.C = 0;
};
Element.prototype.useCss = function(css) {
var style = this.shadowRoot.querySelector('style');
style && this.shadowRoot.removeChild(style);
this.shadowRoot.appendChild(cssToDom(css));
if (css !== this.K) {
this.K = css;
var style = this.shadowRoot.querySelector('style');
style && this.shadowRoot.removeChild(style);
this.shadowRoot.appendChild(cssToDom(css));
}
};
Element.prototype.useData = function(data) {
return this.use({
@ -893,7 +896,7 @@
ModelView: ModelView
};
options.root.Omi = omi;
options.root.Omi.version = '5.0.2';
options.root.Omi.version = '5.0.3';
if ('undefined' != typeof module) module.exports = omi; else self.Omi = omi;
}();
//# sourceMappingURL=omi.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long