This commit is contained in:
dntzhang 2018-10-15 17:53:45 +08:00
parent dd54bd7055
commit 89367a7c52
12 changed files with 88 additions and 178 deletions

47
dist/omi.dev.js vendored
View File

@ -330,13 +330,11 @@
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-spellcheck
if (value == null || value === false) {
if (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());else node.removeAttribute(name);
} else if (typeof value !== 'function') {
} else if (typeof value === 'string') {
if (ns) {
node.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);
node.props[npn(name.toLowerCase())] = value;
} else {
node.setAttribute(name, value);
node.props[npn(name)] = value;
}
}
}
@ -605,33 +603,38 @@
*/
function diffAttributes(dom, attrs, old) {
var name;
var update = false;
var isWeElement = dom.update;
// remove attributes no longer present on the vnode by setting them to undefined
for (name in old) {
if (!(attrs && attrs[name] != null) && old[name] != null) {
setAccessor(dom, name, old[name], old[name] = undefined, isSvgMode);
delete dom.props[name];
if (isWeElement) {
delete dom.props[name];
update = true;
}
}
}
var update = false;
// add new & update changed attributes
for (name in attrs) {
//diable when using store system?
//!dom.store &&
if (typeof attrs[name] === 'object') {
// todo diff??
if (isWeElement && typeof attrs[name] === 'object') {
dom.props[npn(name)] = attrs[name];
dom.parentNode && (update = true);
update = true;
} else if (name !== 'children' && name !== 'innerHTML' && (!(name in old) || attrs[name] !== (name === 'value' || name === 'checked' ? dom[name] : old[name]))) {
setAccessor(dom, name, old[name], old[name] = attrs[name], isSvgMode);
if (isWeElement) {
dom.props[npn(name)] = attrs[name];
update = true;
}
}
}
update && dom.update();
dom.parentNode && update && isWeElement && dom.update();
}
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
@ -667,14 +670,6 @@
this.installed();
};
//chain transfer through this method
WeElement.prototype.attributeChangedCallback = function attributeChangedCallback(name, pre, current) {
this.props[npn(name)] = current;
this.update();
};
WeElement.prototype.disconnectedCallback = function disconnectedCallback() {
this.uninstall();
};
@ -697,18 +692,6 @@
WeElement.prototype.afterUpdate = function afterUpdate() {};
_createClass(WeElement, null, [{
key: 'observedAttributes',
get: function get() {
if (!this.props) return;
if (isArray(this.props)) {
return this.props;
} else {
return Object.keys(this.props);
}
}
}]);
return WeElement;
}(HTMLElement);

2
dist/omi.dev.js.map vendored

File diff suppressed because one or more lines are too long

47
dist/omi.esm.js vendored
View File

@ -327,13 +327,11 @@ function setAccessor(node, name, old, value, isSvg) {
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-spellcheck
if (value == null || value === false) {
if (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());else node.removeAttribute(name);
} else if (typeof value !== 'function') {
} else if (typeof value === 'string') {
if (ns) {
node.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);
node.props[npn(name.toLowerCase())] = value;
} else {
node.setAttribute(name, value);
node.props[npn(name)] = value;
}
}
}
@ -602,33 +600,38 @@ function removeChildren(node) {
*/
function diffAttributes(dom, attrs, old) {
var name;
var update = false;
var isWeElement = dom.update;
// remove attributes no longer present on the vnode by setting them to undefined
for (name in old) {
if (!(attrs && attrs[name] != null) && old[name] != null) {
setAccessor(dom, name, old[name], old[name] = undefined, isSvgMode);
delete dom.props[name];
if (isWeElement) {
delete dom.props[name];
update = true;
}
}
}
var update = false;
// add new & update changed attributes
for (name in attrs) {
//diable when using store system?
//!dom.store &&
if (typeof attrs[name] === 'object') {
// todo diff??
if (isWeElement && typeof attrs[name] === 'object') {
dom.props[npn(name)] = attrs[name];
dom.parentNode && (update = true);
update = true;
} else if (name !== 'children' && name !== 'innerHTML' && (!(name in old) || attrs[name] !== (name === 'value' || name === 'checked' ? dom[name] : old[name]))) {
setAccessor(dom, name, old[name], old[name] = attrs[name], isSvgMode);
if (isWeElement) {
dom.props[npn(name)] = attrs[name];
update = true;
}
}
}
update && dom.update();
dom.parentNode && update && isWeElement && dom.update();
}
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
@ -664,14 +667,6 @@ var WeElement = function (_HTMLElement) {
this.installed();
};
//chain transfer through this method
WeElement.prototype.attributeChangedCallback = function attributeChangedCallback(name, pre, current) {
this.props[npn(name)] = current;
this.update();
};
WeElement.prototype.disconnectedCallback = function disconnectedCallback() {
this.uninstall();
};
@ -694,18 +689,6 @@ var WeElement = function (_HTMLElement) {
WeElement.prototype.afterUpdate = function afterUpdate() {};
_createClass(WeElement, null, [{
key: 'observedAttributes',
get: function get() {
if (!this.props) return;
if (isArray(this.props)) {
return this.props;
} else {
return Object.keys(this.props);
}
}
}]);
return WeElement;
}(HTMLElement);

2
dist/omi.esm.js.map vendored

File diff suppressed because one or more lines are too long

56
dist/omi.js vendored
View File

@ -89,13 +89,7 @@
if ((null == value || !1 === value) && 'spellcheck' != name) node.removeAttribute(name);
} else {
var ns = isSvg && name !== (name = name.replace(/^xlink:?/, ''));
if (null == value || !1 === value) if (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase()); else node.removeAttribute(name); else if ('function' != typeof value) if (ns) {
node.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);
node.props[npn(name.toLowerCase())] = value;
} else {
node.setAttribute(name, value);
node.props[npn(name)] = value;
}
if (null == value || !1 === value) if (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase()); else node.removeAttribute(name); else if ('string' == typeof value) if (ns) node.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value); else node.setAttribute(name, value);
}
}
function eventProxy(e) {
@ -198,16 +192,26 @@
}
function diffAttributes(dom, attrs, old) {
var name;
var update = !1;
var isWeElement = dom.update;
for (name in old) if ((!attrs || null == attrs[name]) && null != old[name]) {
setAccessor(dom, name, old[name], old[name] = void 0, isSvgMode);
delete dom.props[name];
if (isWeElement) {
delete dom.props[name];
update = !0;
}
}
var update = !1;
for (name in attrs) if ('object' == typeof attrs[name]) {
for (name in attrs) if (isWeElement && 'object' == typeof attrs[name]) {
dom.props[npn(name)] = attrs[name];
dom.parentNode && (update = !0);
} else if (!('children' === name || 'innerHTML' === name || name in old && attrs[name] === ('value' === name || 'checked' === name ? dom[name] : old[name]))) setAccessor(dom, name, old[name], old[name] = attrs[name], isSvgMode);
update && dom.update();
update = !0;
} else if (!('children' === name || 'innerHTML' === name || name in old && attrs[name] === ('value' === name || 'checked' === name ? dom[name] : old[name]))) {
setAccessor(dom, name, old[name], old[name] = attrs[name], isSvgMode);
if (isWeElement) {
dom.props[npn(name)] = attrs[name];
update = !0;
}
}
dom.parentNode && update && isWeElement && dom.update();
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
@ -380,22 +384,6 @@
var diffLevel = 0;
var isSvgMode = !1;
var hydrating = !1;
var _createClass = function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || !1;
descriptor.configurable = !0;
if ("value" in descriptor) descriptor.writable = !0;
descriptor.key;
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var WeElement = function(_HTMLElement) {
function WeElement() {
_classCallCheck(this, WeElement);
@ -417,10 +405,6 @@
shadowRoot.appendChild(this.host);
this.installed();
};
WeElement.prototype.attributeChangedCallback = function(name, pre, current) {
this.props[npn(name)] = current;
this.update();
};
WeElement.prototype.disconnectedCallback = function() {
this.uninstall();
};
@ -438,12 +422,6 @@
WeElement.prototype.installed = function() {};
WeElement.prototype.beforeUpdate = function() {};
WeElement.prototype.afterUpdate = function() {};
_createClass(WeElement, null, [ {
key: 'observedAttributes',
get: function() {
if (this.props) if (isArray(this.props)) return this.props; else return Object.keys(this.props);
}
} ]);
return WeElement;
}(HTMLElement);
var instances = [];

2
dist/omi.js.map vendored

File diff suppressed because one or more lines are too long

2
dist/omi.min.js vendored

File diff suppressed because one or more lines are too long

2
dist/omi.min.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -326,13 +326,11 @@
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-spellcheck
if (value == null || value === false) {
if (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());else node.removeAttribute(name);
} else if (typeof value !== 'function') {
} else if (typeof value === 'string') {
if (ns) {
node.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);
node.props[npn(name.toLowerCase())] = value;
} else {
node.setAttribute(name, value);
node.props[npn(name)] = value;
}
}
}
@ -601,33 +599,38 @@
*/
function diffAttributes(dom, attrs, old) {
var name = void 0;
var update = false;
var isWeElement = dom.update;
// remove attributes no longer present on the vnode by setting them to undefined
for (name in old) {
if (!(attrs && attrs[name] != null) && old[name] != null) {
setAccessor(dom, name, old[name], old[name] = undefined, isSvgMode);
delete dom.props[name];
if (isWeElement) {
delete dom.props[name];
update = true;
}
}
}
var update = false;
// add new & update changed attributes
for (name in attrs) {
//diable when using store system?
//!dom.store &&
if (typeof attrs[name] === 'object') {
// todo diff??
if (isWeElement && typeof attrs[name] === 'object') {
dom.props[npn(name)] = attrs[name];
dom.parentNode && (update = true);
update = true;
} else if (name !== 'children' && name !== 'innerHTML' && (!(name in old) || attrs[name] !== (name === 'value' || name === 'checked' ? dom[name] : old[name]))) {
setAccessor(dom, name, old[name], old[name] = attrs[name], isSvgMode);
if (isWeElement) {
dom.props[npn(name)] = attrs[name];
update = true;
}
}
}
update && dom.update();
dom.parentNode && update && isWeElement && dom.update();
}
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
@ -663,14 +666,6 @@
this.installed();
};
//chain transfer through this method
WeElement.prototype.attributeChangedCallback = function attributeChangedCallback(name, pre, current) {
this.props[npn(name)] = current;
this.update();
};
WeElement.prototype.disconnectedCallback = function disconnectedCallback() {
this.uninstall();
};
@ -693,18 +688,6 @@
WeElement.prototype.afterUpdate = function afterUpdate() {};
_createClass(WeElement, null, [{
key: 'observedAttributes',
get: function get() {
if (!this.props) return;
if (isArray(this.props)) {
return this.props;
} else {
return Object.keys(this.props);
}
}
}]);
return WeElement;
}(HTMLElement);
@ -948,7 +931,7 @@
options.root.Omi.version = '4.0.0';
var _createClass$1 = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@ -1042,7 +1025,7 @@
}, 1000);
};
_createClass$1(TodoApp, null, [{
_createClass(TodoApp, null, [{
key: 'data',
get: function get() {
return {

File diff suppressed because one or more lines are too long

View File

@ -326,13 +326,11 @@
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-spellcheck
if (value == null || value === false) {
if (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());else node.removeAttribute(name);
} else if (typeof value !== 'function') {
} else if (typeof value === 'string') {
if (ns) {
node.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);
node.props[npn(name.toLowerCase())] = value;
} else {
node.setAttribute(name, value);
node.props[npn(name)] = value;
}
}
}
@ -601,33 +599,38 @@
*/
function diffAttributes(dom, attrs, old) {
var name = void 0;
var update = false;
var isWeElement = dom.update;
// remove attributes no longer present on the vnode by setting them to undefined
for (name in old) {
if (!(attrs && attrs[name] != null) && old[name] != null) {
setAccessor(dom, name, old[name], old[name] = undefined, isSvgMode);
delete dom.props[name];
if (isWeElement) {
delete dom.props[name];
update = true;
}
}
}
var update = false;
// add new & update changed attributes
for (name in attrs) {
//diable when using store system?
//!dom.store &&
if (typeof attrs[name] === 'object') {
// todo diff??
if (isWeElement && typeof attrs[name] === 'object') {
dom.props[npn(name)] = attrs[name];
dom.parentNode && (update = true);
update = true;
} else if (name !== 'children' && name !== 'innerHTML' && (!(name in old) || attrs[name] !== (name === 'value' || name === 'checked' ? dom[name] : old[name]))) {
setAccessor(dom, name, old[name], old[name] = attrs[name], isSvgMode);
if (isWeElement) {
dom.props[npn(name)] = attrs[name];
update = true;
}
}
}
update && dom.update();
dom.parentNode && update && isWeElement && dom.update();
}
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
@ -663,14 +666,6 @@
this.installed();
};
//chain transfer through this method
WeElement.prototype.attributeChangedCallback = function attributeChangedCallback(name, pre, current) {
this.props[npn(name)] = current;
this.update();
};
WeElement.prototype.disconnectedCallback = function disconnectedCallback() {
this.uninstall();
};
@ -693,18 +688,6 @@
WeElement.prototype.afterUpdate = function afterUpdate() {};
_createClass(WeElement, null, [{
key: 'observedAttributes',
get: function get() {
if (!this.props) return;
if (isArray(this.props)) {
return this.props;
} else {
return Object.keys(this.props);
}
}
}]);
return WeElement;
}(HTMLElement);
@ -948,7 +931,7 @@
options.root.Omi.version = '4.0.0';
var _createClass$1 = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@ -1040,7 +1023,7 @@
);
};
_createClass$1(TodoApp, null, [{
_createClass(TodoApp, null, [{
key: 'data',
get: function get() {
return { items: [], text: '' };

File diff suppressed because one or more lines are too long