diff --git a/README.md b/README.md index cc7aed23a..26dc54396 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Coming soon.... - JSX 是开发体验最棒(智能提示),[语法噪音最少](https://github.com/facebook/jsx#why-not-template-literals)的 UI 表达式 - 每一个组件拥有 update 方法自由渲染最佳更新视图的时机,功耗低,自由度高,性能卓越 - 局部 CSS 最佳解决方案(Shadow DOM),社区为局部 CSS 折腾了不少框架,Shadow DOM Style 是最完美的方案 -- WeStore 体系,99% 的项目不需要什么时间旅行,请不要上来就 redux,Omi store 体系可以满足所有项目,也能时间旅行 +- 类似 WeStore 体系,99% 的项目不需要什么时间旅行,请不要上来就 redux,Omi store 体系可以满足所有项目,也能时间旅行 - 看看[Facebook React 和 Web Components对比优势](https://www.cnblogs.com/rubylouvre/p/4072979.html),Omi 融合了各自的优点,而且给开发者自由的选择喜爱的方式 对比同样开发 TodoApp, Omi 和 React 渲染完的 DOM 结构: @@ -25,6 +25,8 @@ Coming soon.... - [Getting Started](#getting-started) - [Hello Omi](#hello-omi) + - [TodoApp](#todoapp) + - [Store](#store) - [Lifecycle](#lifecycle) - [Install](#install) - [Links](#links) @@ -131,9 +133,6 @@ render(, 'body') "babel-preset-omi": "^0.1.1", ``` -### Scoped CSS - - 如果不想把 css 写在 js 里,你可以使用 [to-string-loader](https://www.npmjs.com/package/to-string-loader), 比如下面配置: ``` js @@ -231,6 +230,71 @@ define('todo-app', TodoApp) render(, 'body') ``` +### Store + + +```js +export default { + data: { + items: [], + text: '', + firstName: 'dnt', + lastName: 'zhang', + fullName: function () { + return this.firstName + this.lastName + }, + globalPropTest: 'abc', //更改我会刷新所有页面,不需要再组件和页面声明data依赖 + ccc: { ddd: 1 } //更改我会刷新所有页面,不需要再组件和页面声明data依赖 + }, + add: function () { + this.data.items.push({ + text: this.data.text, + id: Date.now() + }) + this.data.text = '' + this.update() + }, + globalData: ['globalPropTest', 'ccc.ddd'], + logMotto: function () { + console.log(this.data.motto) + }, + //默认 false,为 true 会无脑更新所有实例 + //updateAll: true +} +``` + +自定义 Element 需要声明依赖的 data,这样 Omi store 根据自定义组件上声明的 data 计算依赖 path 并会按需局部更新。如: + +```js +class TodoApp extends WeElement { + static get data() { + return { items: [], text: '' } + } + ... + ... + ... + handleChange = (e) => { + this.store.data.text = e.target.value + } + + handleSubmit = (e) => { + e.preventDefault(); + if (!this.store.data.text.length) { + return; + } + this.store.add() + } +} + +define('todo-app', TodoApp) +``` + +需要在 render 的时候从根节点注入 store 才能在所有自定义 Element 里使用 this.store: + +```js +render(, 'body', store) +``` + ### Lifecycle | Lifecycle method | When it gets called | diff --git a/dist/omi.dev.js b/dist/omi.dev.js index 2e41d9455..81ce7ae53 100644 --- a/dist/omi.dev.js +++ b/dist/omi.dev.js @@ -616,10 +616,12 @@ 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?? dom.props[npn(name)] = attrs[name]; - update = true; + dom.parentNode && (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); } @@ -650,6 +652,10 @@ } WeElement.prototype.connectedCallback = function connectedCallback() { + this.store = options.store; + if (this.store) { + this.store.instances.push(this); + } this.install(); var shadowRoot = this.attachShadow({ mode: 'open' }); @@ -706,9 +712,224 @@ return WeElement; }(HTMLElement); - function render(vnode, parent) { - parent = typeof parent === 'string' ? document.querySelector(parent) : parent; - diff(null, vnode, {}, false, parent, false); + function diff$1(current, pre) { + var result = {}; + syncKeys(current, pre); + _diff(current, pre, '', result); + return result; + } + + function syncKeys(current, pre) { + if (current === pre) return; + var rootCurrentType = type(current); + var rootPreType = type(pre); + if (rootCurrentType == '[object Object]' && rootPreType == '[object Object]') { + if (Object.keys(current).length >= Object.keys(pre).length) { + for (var key in pre) { + var currentValue = current[key]; + if (currentValue === undefined) { + current[key] = null; + } else { + syncKeys(currentValue, pre[key]); + } + } + } + } else if (rootCurrentType == '[object Array]' && rootPreType == '[object Array]') { + if (current.length >= pre.length) { + pre.forEach(function (item, index) { + syncKeys(current[index], item); + }); + } + } + } + + function _diff(current, pre, path, result) { + if (current === pre) return; + var rootCurrentType = type(current); + var rootPreType = type(pre); + if (rootCurrentType == '[object Object]') { + if (rootPreType != '[object Object]' || Object.keys(current).length < Object.keys(pre).length) { + setResult(result, path, current); + } else { + var _loop = function _loop(key) { + var currentValue = current[key]; + var preValue = pre[key]; + var currentType = type(currentValue); + var preType = type(preValue); + if (currentType != '[object Array]' && currentType != '[object Object]') { + if (currentValue != pre[key]) { + setResult(result, (path == '' ? '' : path + ".") + key, currentValue); + } + } else if (currentType == '[object Array]') { + if (preType != '[object Array]') { + setResult(result, (path == '' ? '' : path + ".") + key, currentValue); + } else { + if (currentValue.length < preValue.length) { + setResult(result, (path == '' ? '' : path + ".") + key, currentValue); + } else { + currentValue.forEach(function (item, index) { + _diff(item, preValue[index], (path == '' ? '' : path + ".") + key + '[' + index + ']', result); + }); + } + } + } else if (currentType == '[object Object]') { + if (preType != '[object Object]' || Object.keys(currentValue).length < Object.keys(preValue).length) { + setResult(result, (path == '' ? '' : path + ".") + key, currentValue); + } else { + for (var subKey in currentValue) { + _diff(currentValue[subKey], preValue[subKey], (path == '' ? '' : path + ".") + key + '.' + subKey, result); + } + } + } + }; + + for (var key in current) { + _loop(key); + } + } + } else if (rootCurrentType == '[object Array]') { + if (rootPreType != '[object Array]') { + setResult(result, path, current); + } else { + if (current.length < pre.length) { + setResult(result, path, current); + } else { + current.forEach(function (item, index) { + _diff(item, pre[index], path + '[' + index + ']', result); + }); + } + } + } else { + setResult(result, path, current); + } + } + + function setResult(result, k, v) { + if (type(v) != '[object Function]') { + result[k] = v; + } + } + + function type(obj) { + return Object.prototype.toString.call(obj); + } + + function render(vnode, parent, store) { + parent = typeof parent === 'string' ? document.querySelector(parent) : parent; + if (store) { + store.instances = []; + extendStoreUpate(store); + options.store = store; + store.originData = JSON.parse(JSON.stringify(store.data)); + } + diff(null, vnode, {}, false, parent, false); + } + + function extendStoreUpate(store) { + store.update = function () { + var _this = this; + + var diffResult = diff$1(this.data, this.originData); + if (Object.keys(diffResult)[0] == '') { + diffResult = diffResult['']; + } + var updateAll = matchGlobalData(this.globalData, diffResult); + if (Object.keys(diffResult).length > 0) { + this.instances.forEach(function (instance) { + if (updateAll || _this.updateAll || instance.constructor.updatePath && needUpdate(diffResult, instance.constructor.updatePath)) { + instance.update(); + } + }); + this.onChange && this.onChange(diffResult); + for (var key in diffResult) { + updateByPath(this.originData, key, typeof diffResult[key] === 'object' ? JSON.parse(JSON.stringify(diffResult[key])) : diffResult[key]); + } + } + }; + } + + function matchGlobalData(globalData, diffResult) { + if (!globalData) return false; + for (var keyA in diffResult) { + if (globalData.indexOf(keyA) > -1) { + return true; + } + for (var i = 0, len = globalData.length; i < len; i++) { + if (includePath(keyA, globalData[i])) { + return true; + } + } + } + return false; + } + + function needUpdate(diffResult, updatePath) { + for (var keyA in diffResult) { + if (updatePath[keyA]) { + return true; + } + for (var keyB in updatePath) { + if (includePath(keyA, keyB)) { + return true; + } + } + } + return false; + } + + function includePath(pathA, pathB) { + if (pathA.indexOf(pathB) === 0) { + var next = pathA.substr(pathB.length, 1); + if (next === '[' || next === '.') { + return true; + } + } + return false; + } + + function updateByPath(origin, path, value) { + var arr = path.replace(/]/g, '').replace(/\[/g, '.').split('.'); + var current = origin; + for (var i = 0, len = arr.length; i < len; i++) { + if (i === len - 1) { + current[arr[i]] = value; + } else { + current = current[arr[i]]; + } + } + } + + function define(name, ctor) { + customElements.define(name, ctor); + if (ctor.data) { + ctor.updatePath = getUpdatePath(ctor.data); + } + } + + function getUpdatePath(data) { + var result = {}; + dataToPath(data, result); + return result; + } + + function dataToPath(data, result) { + Object.keys(data).forEach(function (key) { + result[key] = true; + var type = Object.prototype.toString.call(data[key]); + if (type === '[object Object]') { + _dataToPath(data[key], key, result); + } + }); + } + + function _dataToPath(data, path, result) { + Object.keys(data).forEach(function (key) { + result[path + '.' + key] = true; + var type = Object.prototype.toString.call(data[key]); + if (type === '[object Object]') { + _dataToPath(data[key], path + '.' + key, result); + } + }); } var instances = []; @@ -719,7 +940,8 @@ WeElement: WeElement, render: render, options: options, - instances: instances + instances: instances, + define: define }; options.root.Omi.version = '4.0.0'; @@ -730,7 +952,8 @@ WeElement: WeElement, render: render, options: options, - instances: instances + instances: instances, + define: define }; if (typeof module != 'undefined') module.exports = Omi;else self.Omi = Omi; diff --git a/dist/omi.dev.js.map b/dist/omi.dev.js.map index d3ae57f21..250661f08 100644 --- a/dist/omi.dev.js.map +++ b/dist/omi.dev.js.map @@ -1 +1 @@ -{"version":3,"file":"omi.dev.js","sources":["../src/vnode.js","../src/options.js","../src/h.js","../src/util.js","../src/constants.js","../src/vdom/index.js","../src/dom/index.js","../src/vdom/diff.js","../src/we-element.js","../src/render.js","../src/omi.js","../src/omi.js"],"sourcesContent":["/** Virtual DOM Node */\r\nexport function VNode() {}\r\n","function getGlobal() {\r\n\tif (typeof global !== 'object' || !global || global.Math !== Math || global.Array !== Array) {\r\n\t\tif (typeof self !== 'undefined') {\r\n\t\t\treturn self;\r\n\t\t} else if (typeof window !== 'undefined') {\r\n\t\t\treturn window;\r\n\t\t} else if (typeof global !== 'undefined') {\r\n\t\t\treturn global;\r\n\t\t}\r\n\t\treturn (function(){\r\n\t\t\treturn this;\r\n\t\t})();\r\n\t\t\r\n\t}\r\n\treturn global;\r\n}\r\n\r\n/** Global options\r\n *\t@public\r\n *\t@namespace options {Object}\r\n */\r\nexport default {\r\n\r\n\tstore: null,\r\n\t\r\n\troot: getGlobal()\r\n\t//componentChange(component, element) { },\r\n\t/** If `true`, `prop` changes trigger synchronous component updates.\r\n\t *\t@name syncComponentUpdates\r\n\t *\t@type Boolean\r\n\t *\t@default true\r\n\t */\r\n\t//syncComponentUpdates: true,\r\n\r\n\t/** Processes all created VNodes.\r\n\t *\t@param {VNode} vnode\tA newly-created VNode to normalize/process\r\n\t */\r\n\t//vnode(vnode) { }\r\n\r\n\t/** Hook invoked after a component is mounted. */\r\n\t//afterMount(component) { },\r\n\r\n\t/** Hook invoked after the DOM is updated with a component's latest render. */\r\n\t//afterUpdate(component) { }\r\n\r\n\t/** Hook invoked immediately before a component is unmounted. */\r\n\t// beforeUnmount(component) { }\r\n};\r\n","import { VNode } from './vnode';\r\nimport options from './options';\r\n\r\n\r\nconst stack = [];\r\n\r\nconst EMPTY_CHILDREN = [];\r\n\r\nexport function h(nodeName, attributes) {\r\n\tlet children=EMPTY_CHILDREN, lastSimple, child, simple, i;\r\n\tfor (i=arguments.length; i-- > 2; ) {\r\n\t\tstack.push(arguments[i]);\r\n\t}\r\n\tif (attributes && attributes.children!=null) {\r\n\t\tif (!stack.length) stack.push(attributes.children);\r\n\t\tdelete attributes.children;\r\n\t}\r\n\twhile (stack.length) {\r\n\t\tif ((child = stack.pop()) && child.pop!==undefined) {\r\n\t\t\tfor (i=child.length; i--; ) stack.push(child[i]);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tif (typeof child==='boolean') child = null;\r\n\r\n\t\t\tif ((simple = typeof nodeName!=='function')) {\r\n\t\t\t\tif (child==null) child = '';\r\n\t\t\t\telse if (typeof child==='number') child = String(child);\r\n\t\t\t\telse if (typeof child!=='string') simple = false;\r\n\t\t\t}\r\n\r\n\t\t\tif (simple && lastSimple) {\r\n\t\t\t\tchildren[children.length-1] += child;\r\n\t\t\t}\r\n\t\t\telse if (children===EMPTY_CHILDREN) {\r\n\t\t\t\tchildren = [child];\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tchildren.push(child);\r\n\t\t\t}\r\n\r\n\t\t\tlastSimple = simple;\r\n\t\t}\r\n\t}\r\n\r\n\tlet p = new VNode();\r\n\tp.nodeName = nodeName;\r\n\tp.children = children;\r\n\tp.attributes = attributes==null ? undefined : attributes;\r\n\tp.key = attributes==null ? undefined : attributes.key;\r\n\r\n\t// if a \"vnode hook\" is defined, pass every created VNode to it\r\n\tif (options.vnode!==undefined) options.vnode(p);\r\n\r\n\treturn p;\r\n}","/**\r\n * @license\r\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\r\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\r\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\r\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\r\n * Code distributed by Google as part of the polymer project is also\r\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\r\n */\r\n\r\n/**\r\n * This shim allows elements written in, or compiled to, ES5 to work on native\r\n * implementations of Custom Elements v1. It sets new.target to the value of\r\n * this.constructor so that the native HTMLElement constructor can access the\r\n * current under-construction element's definition.\r\n */\r\n(function() {\r\n if (\r\n // No Reflect, no classes, no need for shim because native custom elements\r\n // require ES2015 classes or Reflect.\r\n window.Reflect === undefined ||\r\n window.customElements === undefined ||\r\n // The webcomponentsjs custom elements polyfill doesn't require\r\n // ES2015-compatible construction (`super()` or `Reflect.construct`).\r\n window.customElements.hasOwnProperty('polyfillWrapFlushCallback')\r\n ) {\r\n return;\r\n }\r\n const BuiltInHTMLElement = HTMLElement;\r\n window.HTMLElement = function HTMLElement() {\r\n return Reflect.construct(BuiltInHTMLElement, [], this.constructor);\r\n };\r\n HTMLElement.prototype = BuiltInHTMLElement.prototype;\r\n HTMLElement.prototype.constructor = HTMLElement;\r\n Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement);\r\n })();\r\n\r\n\r\n\r\nexport function cssToDom(css) {\r\n const node = document.createElement('style')\r\n node.innerText = css\r\n return node\r\n}\r\n\r\n\r\nexport function npn(str) {\r\n return str.replace(/-(\\w)/g, function ($, $1) {\r\n return $1.toUpperCase();\r\n });\r\n}\r\n\r\nexport function extend(obj, props) {\r\n\tfor (let i in props) obj[i] = props[i];\r\n\treturn obj;\r\n}\r\n\r\n/** Invoke or update a ref, depending on whether it is a function or object ref.\r\n * @param {object|function} [ref=null]\r\n * @param {any} [value]\r\n */\r\nexport function applyRef(ref, value) {\r\n\tif (ref!=null) {\r\n\t\tif (typeof ref=='function') ref(value);\r\n\t\telse ref.current = value;\r\n\t}\r\n}\r\n\r\n/**\r\n * Call a function asynchronously, as soon as possible. Makes\r\n * use of HTML Promise to schedule the callback if available,\r\n * otherwise falling back to `setTimeout` (mainly for IE<11).\r\n * @type {(callback: function) => void}\r\n */\r\nexport const defer = typeof Promise=='function' ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout;\r\n\r\nexport function isArray(obj){\r\n return Object.prototype.toString.call(obj) === '[object Array]'\r\n}\r\n\r\nexport function nProps(props){\r\n if(!props || isArray(props)) return {}\r\n const result = {}\r\n Object.keys(props).forEach(key =>{\r\n result[key] = props[key].value \r\n })\r\n return result\r\n}\r\n","// render modes\r\n\r\nexport const NO_RENDER = 0;\r\nexport const SYNC_RENDER = 1;\r\nexport const FORCE_RENDER = 2;\r\nexport const ASYNC_RENDER = 3;\r\n\r\n\r\nexport const ATTR_KEY = '__preactattr_';\r\n\r\n// DOM properties that should NOT have \"px\" added when numeric\r\nexport const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i;\r\n\r\n","import { extend } from '../util';\r\n\r\n\r\n/**\r\n * Check if two nodes are equivalent.\r\n *\r\n * @param {Node} node\t\t\tDOM Node to compare\r\n * @param {VNode} vnode\t\t\tVirtual DOM node to compare\r\n * @param {boolean} [hydrating=false]\tIf true, ignores component constructors when comparing.\r\n * @private\r\n */\r\nexport function isSameNodeType(node, vnode, hydrating) {\r\n\tif (typeof vnode==='string' || typeof vnode==='number') {\r\n\t\treturn node.splitText!==undefined;\r\n\t}\r\n\tif (typeof vnode.nodeName==='string') {\r\n\t\treturn !node._componentConstructor && isNamedNode(node, vnode.nodeName);\r\n\t}\r\n\treturn hydrating || node._componentConstructor===vnode.nodeName;\r\n}\r\n\r\n\r\n/**\r\n * Check if an Element has a given nodeName, case-insensitively.\r\n *\r\n * @param {Element} node\tA DOM Element to inspect the name of.\r\n * @param {String} nodeName\tUnnormalized name to compare against.\r\n */\r\nexport function isNamedNode(node, nodeName) {\r\n\treturn node.normalizedNodeName===nodeName || node.nodeName.toLowerCase()===nodeName.toLowerCase();\r\n}\r\n\r\n\r\n/**\r\n * Reconstruct Component-style `props` from a VNode.\r\n * Ensures default/fallback values from `defaultProps`:\r\n * Own-properties of `defaultProps` not present in `vnode.attributes` are added.\r\n *\r\n * @param {VNode} vnode\r\n * @returns {Object} props\r\n */\r\nexport function getNodeProps(vnode) {\r\n\tlet props = extend({}, vnode.attributes);\r\n\tprops.children = vnode.children;\r\n\r\n\tlet defaultProps = vnode.nodeName.defaultProps;\r\n\tif (defaultProps!==undefined) {\r\n\t\tfor (let i in defaultProps) {\r\n\t\t\tif (props[i]===undefined) {\r\n\t\t\t\tprops[i] = defaultProps[i];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn props;\r\n}\r\n","import { IS_NON_DIMENSIONAL } from '../constants';\r\nimport { applyRef } from '../util';\r\nimport options from '../options';\r\nimport { npn } from '../util'\r\n\r\n/**\r\n * A DOM event listener\r\n * @typedef {(e: Event) => void} EventListner\r\n */\r\n\r\n/**\r\n * A mapping of event types to event listeners\r\n * @typedef {Object.} EventListenerMap\r\n */\r\n\r\n/**\r\n * Properties Preact adds to elements it creates\r\n * @typedef PreactElementExtensions\r\n * @property {string} [normalizedNodeName] A normalized node name to use in diffing\r\n * @property {EventListenerMap} [_listeners] A map of event listeners added by components to this DOM node\r\n * @property {import('../component').Component} [_component] The component that rendered this DOM node\r\n * @property {function} [_componentConstructor] The constructor of the component that rendered this DOM node\r\n */\r\n\r\n/**\r\n * A DOM element that has been extended with Preact properties\r\n * @typedef {Element & ElementCSSInlineStyle & PreactElementExtensions} PreactElement\r\n */\r\n\r\n/**\r\n * Create an element with the given nodeName.\r\n * @param {string} nodeName The DOM node to create\r\n * @param {boolean} [isSvg=false] If `true`, creates an element within the SVG\r\n * namespace.\r\n * @returns {PreactElement} The created DOM node\r\n */\r\nexport function createNode(nodeName, isSvg) {\r\n\t/** @type {PreactElement} */\r\n\tlet node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName);\r\n\tnode.normalizedNodeName = nodeName;\r\n\treturn node;\r\n}\r\n\r\n\r\n/**\r\n * Remove a child node from its parent if attached.\r\n * @param {Node} node The node to remove\r\n */\r\nexport function removeNode(node) {\r\n\tlet parentNode = node.parentNode;\r\n\tif (parentNode) parentNode.removeChild(node);\r\n}\r\n\r\n\r\n/**\r\n * Set a named attribute on the given Node, with special behavior for some names\r\n * and event handlers. If `value` is `null`, the attribute/handler will be\r\n * removed.\r\n * @param {PreactElement} node An element to mutate\r\n * @param {string} name The name/key to set, such as an event or attribute name\r\n * @param {*} old The last value that was set for this name/node pair\r\n * @param {*} value An attribute value, such as a function to be used as an\r\n * event handler\r\n * @param {boolean} isSvg Are we currently diffing inside an svg?\r\n * @private\r\n */\r\nexport function setAccessor(node, name, old, value, isSvg) {\r\n\tif (name==='className') name = 'class';\r\n\r\n\r\n\tif (name==='key') {\r\n\t\t// ignore\r\n\t}\r\n\telse if (name==='ref') {\r\n\t\tapplyRef(old, null);\r\n\t\tapplyRef(value, node);\r\n\t}\r\n\telse if (name==='class' && !isSvg) {\r\n\t\tnode.className = value || '';\r\n\t}\r\n\telse if (name==='style') {\r\n\t\tif (!value || typeof value==='string' || typeof old==='string') {\r\n\t\t\tnode.style.cssText = value || '';\r\n\t\t}\r\n\t\tif (value && typeof value==='object') {\r\n\t\t\tif (typeof old!=='string') {\r\n\t\t\t\tfor (let i in old) if (!(i in value)) node.style[i] = '';\r\n\t\t\t}\r\n\t\t\tfor (let i in value) {\r\n\t\t\t\tnode.style[i] = typeof value[i]==='number' && IS_NON_DIMENSIONAL.test(i)===false ? (value[i]+'px') : value[i];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\telse if (name==='dangerouslySetInnerHTML') {\r\n\t\tif (value) node.innerHTML = value.__html || '';\r\n\t}\r\n\telse if (name[0]=='o' && name[1]=='n') {\r\n\t\tlet useCapture = name !== (name=name.replace(/Capture$/, ''));\r\n\t\tname = name.toLowerCase().substring(2);\r\n\t\tif (value) {\r\n\t\t\tif (!old) node.addEventListener(name, eventProxy, useCapture);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tnode.removeEventListener(name, eventProxy, useCapture);\r\n\t\t}\r\n\t\t(node._listeners || (node._listeners = {}))[name] = value;\r\n\t}\r\n\telse if (name!=='list' && name!=='type' && !isSvg && name in node) {\r\n\t\t// Attempt to set a DOM property to the given value.\r\n\t\t// IE & FF throw for certain property-value combinations.\r\n\t\ttry {\r\n\t\t\tnode[name] = value==null ? '' : value;\r\n\t\t} catch (e) { }\r\n\t\tif ((value==null || value===false) && name!='spellcheck') node.removeAttribute(name);\r\n\t}\r\n\telse {\r\n\t\tlet ns = isSvg && (name !== (name = name.replace(/^xlink:?/, '')));\r\n\t\t// spellcheck is treated differently than all other boolean values and\r\n\t\t// should not be removed when the value is `false`. See:\r\n\t\t// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-spellcheck\r\n\t\tif (value==null || value===false) {\r\n\t\t\tif (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());\r\n\t\t\telse node.removeAttribute(name);\r\n\t\t}\r\n\t\telse if (typeof value!=='function') {\r\n\t\t\tif (ns) {\r\n\t\t\t\tnode.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);\r\n\t\t\t\tnode.props[npn(name.toLowerCase())] = value;\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tnode.setAttribute(name, value);\r\n\t\t\t\tnode.props[npn(name)] = value;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\n/**\r\n * Proxy an event to hooked event handlers\r\n * @param {Event} e The event object from the browser\r\n * @private\r\n */\r\nfunction eventProxy(e) {\r\n\treturn this._listeners[e.type](options.event && options.event(e) || e);\r\n}","import { ATTR_KEY } from '../constants';\r\nimport { isSameNodeType, isNamedNode } from './index';\r\nimport { createNode, setAccessor } from '../dom/index';\r\nimport { npn } from '../util'\r\nimport { removeNode } from '../dom/index';\r\n\r\n/** Queue of components that have been mounted and are awaiting componentDidMount */\r\nexport const mounts = [];\r\n\r\n/** Diff recursion count, used to track the end of the diff cycle. */\r\nexport let diffLevel = 0;\r\n\r\n/** Global flag indicating if the diff is currently within an SVG */\r\nlet isSvgMode = false;\r\n\r\n/** Global flag indicating if the diff is performing hydration */\r\nlet hydrating = false;\r\n\r\n\r\n\r\n\r\n/** Apply differences in a given vnode (and it's deep children) to a real DOM Node.\r\n *\t@param {Element} [dom=null]\t\tA DOM node to mutate into the shape of the `vnode`\r\n *\t@param {VNode} vnode\t\t\tA VNode (with descendants forming a tree) representing the desired DOM structure\r\n *\t@returns {Element} dom\t\t\tThe created/mutated element\r\n *\t@private\r\n */\r\nexport function diff(dom, vnode, context, mountAll, parent, componentRoot) {\r\n\t// diffLevel having been 0 here indicates initial entry into the diff (not a subdiff)\r\n\tif (!diffLevel++) {\r\n\t\t// when first starting the diff, check if we're diffing an SVG or within an SVG\r\n\t\tisSvgMode = parent!=null && parent.ownerSVGElement!==undefined;\r\n\r\n\t\t// hydration is indicated by the existing element to be diffed not having a prop cache\r\n\t\thydrating = dom!=null && !(ATTR_KEY in dom);\r\n\t}\r\n\r\n\tlet ret = idiff(dom, vnode, context, mountAll, componentRoot);\r\n\r\n\t// append the element if its a new parent\r\n\tif (parent && ret.parentNode!==parent) parent.appendChild(ret);\r\n\r\n\t// diffLevel being reduced to 0 means we're exiting the diff\r\n\tif (!--diffLevel) {\r\n\t\thydrating = false;\r\n\t\t// invoke queued componentDidMount lifecycle methods\r\n\t\t\r\n\t}\r\n\r\n\treturn ret;\r\n}\r\n\r\n\r\n/** Internals of `diff()`, separated to allow bypassing diffLevel / mount flushing. */\r\nfunction idiff(dom, vnode, context, mountAll, componentRoot) {\r\n\tlet out = dom,\r\n\t\tprevSvgMode = isSvgMode;\r\n\r\n\t// empty values (null, undefined, booleans) render as empty Text nodes\r\n\tif (vnode==null || typeof vnode==='boolean') vnode = '';\r\n\r\n\r\n\t// Fast case: Strings & Numbers create/update Text nodes.\r\n\tif (typeof vnode==='string' || typeof vnode==='number') {\r\n\r\n\t\t// update if it's already a Text node:\r\n\t\tif (dom && dom.splitText!==undefined && dom.parentNode && (!dom._component || componentRoot)) {\r\n\t\t\t/* istanbul ignore if */ /* Browser quirk that can't be covered: https://github.com/developit/preact/commit/fd4f21f5c45dfd75151bd27b4c217d8003aa5eb9 */\r\n\t\t\tif (dom.nodeValue!=vnode) {\r\n\t\t\t\tdom.nodeValue = vnode;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse {\r\n\t\t\t// it wasn't a Text node: replace it with one and recycle the old Element\r\n\t\t\tout = document.createTextNode(vnode);\r\n\t\t\tif (dom) {\r\n\t\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\r\n\t\t\t\trecollectNodeTree(dom, true);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tout[ATTR_KEY] = true;\r\n\r\n\t\treturn out;\r\n\t}\r\n\r\n\r\n\t// If the VNode represents a Component, perform a component diff:\r\n\tlet vnodeName = vnode.nodeName;\r\n\t\r\n\r\n\t// Tracks entering and exiting SVG namespace when descending through the tree.\r\n\tisSvgMode = vnodeName==='svg' ? true : vnodeName==='foreignObject' ? false : isSvgMode;\r\n\r\n\r\n\t// If there's no existing element or it's the wrong type, create a new one:\r\n\tvnodeName = String(vnodeName);\r\n\tif (!dom || !isNamedNode(dom, vnodeName)) {\r\n\t\tout = createNode(vnodeName, isSvgMode);\r\n\r\n\t\tif (dom) {\r\n\t\t\t// move children into the replacement node\r\n\t\t\twhile (dom.firstChild) out.appendChild(dom.firstChild);\r\n\r\n\t\t\t// if the previous Element was mounted into the DOM, replace it inline\r\n\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\r\n\r\n\t\t\t// recycle the old element (skips non-Element node types)\r\n\t\t\trecollectNodeTree(dom, true);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tlet fc = out.firstChild,\r\n\t\tprops = out[ATTR_KEY],\r\n\t\tvchildren = vnode.children;\r\n\r\n\tif (props==null) {\r\n\t\tprops = out[ATTR_KEY] = {};\r\n\t\tfor (let a=out.attributes, i=a.length; i--; ) props[a[i].name] = a[i].value;\r\n\t}\r\n\r\n\t// Optimization: fast-path for elements containing a single TextNode:\r\n\tif (!hydrating && vchildren && vchildren.length===1 && typeof vchildren[0]==='string' && fc!=null && fc.splitText!==undefined && fc.nextSibling==null) {\r\n\t\tif (fc.nodeValue!=vchildren[0]) {\r\n\t\t\tfc.nodeValue = vchildren[0];\r\n\t\t}\r\n\t}\r\n\t// otherwise, if there are existing or new children, diff them:\r\n\telse if (vchildren && vchildren.length || fc!=null) {\r\n\t\tinnerDiffNode(out, vchildren, context, mountAll, hydrating || props.dangerouslySetInnerHTML!=null);\r\n\t}\r\n\r\n\r\n\t// Apply attributes/props from VNode to the DOM Element:\r\n\tdiffAttributes(out, vnode.attributes, props);\r\n\r\n\r\n\t// restore previous SVG mode: (in case we're exiting an SVG namespace)\r\n\tisSvgMode = prevSvgMode;\r\n\r\n\treturn out;\r\n}\r\n\r\n\r\n/** Apply child and attribute changes between a VNode and a DOM Node to the DOM.\r\n *\t@param {Element} dom\t\t\tElement whose children should be compared & mutated\r\n *\t@param {Array} vchildren\t\tArray of VNodes to compare to `dom.childNodes`\r\n *\t@param {Object} context\t\t\tImplicitly descendant context object (from most recent `getChildContext()`)\r\n *\t@param {Boolean} mountAll\r\n *\t@param {Boolean} isHydrating\tIf `true`, consumes externally created elements similar to hydration\r\n */\r\nfunction innerDiffNode(dom, vchildren, context, mountAll, isHydrating) {\r\n\tlet originalChildren = dom.childNodes,\r\n\t\tchildren = [],\r\n\t\tkeyed = {},\r\n\t\tkeyedLen = 0,\r\n\t\tmin = 0,\r\n\t\tlen = originalChildren.length,\r\n\t\tchildrenLen = 0,\r\n\t\tvlen = vchildren ? vchildren.length : 0,\r\n\t\tj, c, f, vchild, child;\r\n\r\n\t// Build up a map of keyed children and an Array of unkeyed children:\r\n\tif (len!==0) {\r\n\t\tfor (let i=0; i 2; ) {\r\n\t\tstack.push(arguments[i]);\r\n\t}\r\n\tif (attributes && attributes.children!=null) {\r\n\t\tif (!stack.length) stack.push(attributes.children);\r\n\t\tdelete attributes.children;\r\n\t}\r\n\twhile (stack.length) {\r\n\t\tif ((child = stack.pop()) && child.pop!==undefined) {\r\n\t\t\tfor (i=child.length; i--; ) stack.push(child[i]);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tif (typeof child==='boolean') child = null;\r\n\r\n\t\t\tif ((simple = typeof nodeName!=='function')) {\r\n\t\t\t\tif (child==null) child = '';\r\n\t\t\t\telse if (typeof child==='number') child = String(child);\r\n\t\t\t\telse if (typeof child!=='string') simple = false;\r\n\t\t\t}\r\n\r\n\t\t\tif (simple && lastSimple) {\r\n\t\t\t\tchildren[children.length-1] += child;\r\n\t\t\t}\r\n\t\t\telse if (children===EMPTY_CHILDREN) {\r\n\t\t\t\tchildren = [child];\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tchildren.push(child);\r\n\t\t\t}\r\n\r\n\t\t\tlastSimple = simple;\r\n\t\t}\r\n\t}\r\n\r\n\tlet p = new VNode();\r\n\tp.nodeName = nodeName;\r\n\tp.children = children;\r\n\tp.attributes = attributes==null ? undefined : attributes;\r\n\tp.key = attributes==null ? undefined : attributes.key;\r\n\r\n\t// if a \"vnode hook\" is defined, pass every created VNode to it\r\n\tif (options.vnode!==undefined) options.vnode(p);\r\n\r\n\treturn p;\r\n}","/**\r\n * @license\r\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\r\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\r\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\r\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\r\n * Code distributed by Google as part of the polymer project is also\r\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\r\n */\r\n\r\n/**\r\n * This shim allows elements written in, or compiled to, ES5 to work on native\r\n * implementations of Custom Elements v1. It sets new.target to the value of\r\n * this.constructor so that the native HTMLElement constructor can access the\r\n * current under-construction element's definition.\r\n */\r\n(function() {\r\n if (\r\n // No Reflect, no classes, no need for shim because native custom elements\r\n // require ES2015 classes or Reflect.\r\n window.Reflect === undefined ||\r\n window.customElements === undefined ||\r\n // The webcomponentsjs custom elements polyfill doesn't require\r\n // ES2015-compatible construction (`super()` or `Reflect.construct`).\r\n window.customElements.hasOwnProperty('polyfillWrapFlushCallback')\r\n ) {\r\n return;\r\n }\r\n const BuiltInHTMLElement = HTMLElement;\r\n window.HTMLElement = function HTMLElement() {\r\n return Reflect.construct(BuiltInHTMLElement, [], this.constructor);\r\n };\r\n HTMLElement.prototype = BuiltInHTMLElement.prototype;\r\n HTMLElement.prototype.constructor = HTMLElement;\r\n Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement);\r\n })();\r\n\r\n\r\n\r\nexport function cssToDom(css) {\r\n const node = document.createElement('style')\r\n node.innerText = css\r\n return node\r\n}\r\n\r\n\r\nexport function npn(str) {\r\n return str.replace(/-(\\w)/g, function ($, $1) {\r\n return $1.toUpperCase();\r\n });\r\n}\r\n\r\nexport function extend(obj, props) {\r\n\tfor (let i in props) obj[i] = props[i];\r\n\treturn obj;\r\n}\r\n\r\n/** Invoke or update a ref, depending on whether it is a function or object ref.\r\n * @param {object|function} [ref=null]\r\n * @param {any} [value]\r\n */\r\nexport function applyRef(ref, value) {\r\n\tif (ref!=null) {\r\n\t\tif (typeof ref=='function') ref(value);\r\n\t\telse ref.current = value;\r\n\t}\r\n}\r\n\r\n/**\r\n * Call a function asynchronously, as soon as possible. Makes\r\n * use of HTML Promise to schedule the callback if available,\r\n * otherwise falling back to `setTimeout` (mainly for IE<11).\r\n * @type {(callback: function) => void}\r\n */\r\nexport const defer = typeof Promise=='function' ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout;\r\n\r\nexport function isArray(obj){\r\n return Object.prototype.toString.call(obj) === '[object Array]'\r\n}\r\n\r\nexport function nProps(props){\r\n if(!props || isArray(props)) return {}\r\n const result = {}\r\n Object.keys(props).forEach(key =>{\r\n result[key] = props[key].value \r\n })\r\n return result\r\n}\r\n","// render modes\r\n\r\nexport const NO_RENDER = 0;\r\nexport const SYNC_RENDER = 1;\r\nexport const FORCE_RENDER = 2;\r\nexport const ASYNC_RENDER = 3;\r\n\r\n\r\nexport const ATTR_KEY = '__preactattr_';\r\n\r\n// DOM properties that should NOT have \"px\" added when numeric\r\nexport const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i;\r\n\r\n","import { extend } from '../util';\r\n\r\n\r\n/**\r\n * Check if two nodes are equivalent.\r\n *\r\n * @param {Node} node\t\t\tDOM Node to compare\r\n * @param {VNode} vnode\t\t\tVirtual DOM node to compare\r\n * @param {boolean} [hydrating=false]\tIf true, ignores component constructors when comparing.\r\n * @private\r\n */\r\nexport function isSameNodeType(node, vnode, hydrating) {\r\n\tif (typeof vnode==='string' || typeof vnode==='number') {\r\n\t\treturn node.splitText!==undefined;\r\n\t}\r\n\tif (typeof vnode.nodeName==='string') {\r\n\t\treturn !node._componentConstructor && isNamedNode(node, vnode.nodeName);\r\n\t}\r\n\treturn hydrating || node._componentConstructor===vnode.nodeName;\r\n}\r\n\r\n\r\n/**\r\n * Check if an Element has a given nodeName, case-insensitively.\r\n *\r\n * @param {Element} node\tA DOM Element to inspect the name of.\r\n * @param {String} nodeName\tUnnormalized name to compare against.\r\n */\r\nexport function isNamedNode(node, nodeName) {\r\n\treturn node.normalizedNodeName===nodeName || node.nodeName.toLowerCase()===nodeName.toLowerCase();\r\n}\r\n\r\n\r\n/**\r\n * Reconstruct Component-style `props` from a VNode.\r\n * Ensures default/fallback values from `defaultProps`:\r\n * Own-properties of `defaultProps` not present in `vnode.attributes` are added.\r\n *\r\n * @param {VNode} vnode\r\n * @returns {Object} props\r\n */\r\nexport function getNodeProps(vnode) {\r\n\tlet props = extend({}, vnode.attributes);\r\n\tprops.children = vnode.children;\r\n\r\n\tlet defaultProps = vnode.nodeName.defaultProps;\r\n\tif (defaultProps!==undefined) {\r\n\t\tfor (let i in defaultProps) {\r\n\t\t\tif (props[i]===undefined) {\r\n\t\t\t\tprops[i] = defaultProps[i];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn props;\r\n}\r\n","import { IS_NON_DIMENSIONAL } from '../constants';\r\nimport { applyRef } from '../util';\r\nimport options from '../options';\r\nimport { npn } from '../util'\r\n\r\n/**\r\n * A DOM event listener\r\n * @typedef {(e: Event) => void} EventListner\r\n */\r\n\r\n/**\r\n * A mapping of event types to event listeners\r\n * @typedef {Object.} EventListenerMap\r\n */\r\n\r\n/**\r\n * Properties Preact adds to elements it creates\r\n * @typedef PreactElementExtensions\r\n * @property {string} [normalizedNodeName] A normalized node name to use in diffing\r\n * @property {EventListenerMap} [_listeners] A map of event listeners added by components to this DOM node\r\n * @property {import('../component').Component} [_component] The component that rendered this DOM node\r\n * @property {function} [_componentConstructor] The constructor of the component that rendered this DOM node\r\n */\r\n\r\n/**\r\n * A DOM element that has been extended with Preact properties\r\n * @typedef {Element & ElementCSSInlineStyle & PreactElementExtensions} PreactElement\r\n */\r\n\r\n/**\r\n * Create an element with the given nodeName.\r\n * @param {string} nodeName The DOM node to create\r\n * @param {boolean} [isSvg=false] If `true`, creates an element within the SVG\r\n * namespace.\r\n * @returns {PreactElement} The created DOM node\r\n */\r\nexport function createNode(nodeName, isSvg) {\r\n\t/** @type {PreactElement} */\r\n\tlet node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName);\r\n\tnode.normalizedNodeName = nodeName;\r\n\treturn node;\r\n}\r\n\r\n\r\n/**\r\n * Remove a child node from its parent if attached.\r\n * @param {Node} node The node to remove\r\n */\r\nexport function removeNode(node) {\r\n\tlet parentNode = node.parentNode;\r\n\tif (parentNode) parentNode.removeChild(node);\r\n}\r\n\r\n\r\n/**\r\n * Set a named attribute on the given Node, with special behavior for some names\r\n * and event handlers. If `value` is `null`, the attribute/handler will be\r\n * removed.\r\n * @param {PreactElement} node An element to mutate\r\n * @param {string} name The name/key to set, such as an event or attribute name\r\n * @param {*} old The last value that was set for this name/node pair\r\n * @param {*} value An attribute value, such as a function to be used as an\r\n * event handler\r\n * @param {boolean} isSvg Are we currently diffing inside an svg?\r\n * @private\r\n */\r\nexport function setAccessor(node, name, old, value, isSvg) {\r\n\tif (name==='className') name = 'class';\r\n\r\n\r\n\tif (name==='key') {\r\n\t\t// ignore\r\n\t}\r\n\telse if (name==='ref') {\r\n\t\tapplyRef(old, null);\r\n\t\tapplyRef(value, node);\r\n\t}\r\n\telse if (name==='class' && !isSvg) {\r\n\t\tnode.className = value || '';\r\n\t}\r\n\telse if (name==='style') {\r\n\t\tif (!value || typeof value==='string' || typeof old==='string') {\r\n\t\t\tnode.style.cssText = value || '';\r\n\t\t}\r\n\t\tif (value && typeof value==='object') {\r\n\t\t\tif (typeof old!=='string') {\r\n\t\t\t\tfor (let i in old) if (!(i in value)) node.style[i] = '';\r\n\t\t\t}\r\n\t\t\tfor (let i in value) {\r\n\t\t\t\tnode.style[i] = typeof value[i]==='number' && IS_NON_DIMENSIONAL.test(i)===false ? (value[i]+'px') : value[i];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\telse if (name==='dangerouslySetInnerHTML') {\r\n\t\tif (value) node.innerHTML = value.__html || '';\r\n\t}\r\n\telse if (name[0]=='o' && name[1]=='n') {\r\n\t\tlet useCapture = name !== (name=name.replace(/Capture$/, ''));\r\n\t\tname = name.toLowerCase().substring(2);\r\n\t\tif (value) {\r\n\t\t\tif (!old) node.addEventListener(name, eventProxy, useCapture);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tnode.removeEventListener(name, eventProxy, useCapture);\r\n\t\t}\r\n\t\t(node._listeners || (node._listeners = {}))[name] = value;\r\n\t}\r\n\telse if (name!=='list' && name!=='type' && !isSvg && name in node) {\r\n\t\t// Attempt to set a DOM property to the given value.\r\n\t\t// IE & FF throw for certain property-value combinations.\r\n\t\ttry {\r\n\t\t\tnode[name] = value==null ? '' : value;\r\n\t\t} catch (e) { }\r\n\t\tif ((value==null || value===false) && name!='spellcheck') node.removeAttribute(name);\r\n\t}\r\n\telse {\r\n\t\tlet ns = isSvg && (name !== (name = name.replace(/^xlink:?/, '')));\r\n\t\t// spellcheck is treated differently than all other boolean values and\r\n\t\t// should not be removed when the value is `false`. See:\r\n\t\t// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-spellcheck\r\n\t\tif (value==null || value===false) {\r\n\t\t\tif (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());\r\n\t\t\telse node.removeAttribute(name);\r\n\t\t}\r\n\t\telse if (typeof value!=='function') {\r\n\t\t\tif (ns) {\r\n\t\t\t\tnode.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);\r\n\t\t\t\tnode.props[npn(name.toLowerCase())] = value;\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tnode.setAttribute(name, value);\r\n\t\t\t\tnode.props[npn(name)] = value;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\n/**\r\n * Proxy an event to hooked event handlers\r\n * @param {Event} e The event object from the browser\r\n * @private\r\n */\r\nfunction eventProxy(e) {\r\n\treturn this._listeners[e.type](options.event && options.event(e) || e);\r\n}","import { ATTR_KEY } from '../constants';\r\nimport { isSameNodeType, isNamedNode } from './index';\r\nimport { createNode, setAccessor } from '../dom/index';\r\nimport { npn } from '../util'\r\nimport { removeNode } from '../dom/index';\r\n\r\n/** Queue of components that have been mounted and are awaiting componentDidMount */\r\nexport const mounts = [];\r\n\r\n/** Diff recursion count, used to track the end of the diff cycle. */\r\nexport let diffLevel = 0;\r\n\r\n/** Global flag indicating if the diff is currently within an SVG */\r\nlet isSvgMode = false;\r\n\r\n/** Global flag indicating if the diff is performing hydration */\r\nlet hydrating = false;\r\n\r\n\r\n\r\n\r\n/** Apply differences in a given vnode (and it's deep children) to a real DOM Node.\r\n *\t@param {Element} [dom=null]\t\tA DOM node to mutate into the shape of the `vnode`\r\n *\t@param {VNode} vnode\t\t\tA VNode (with descendants forming a tree) representing the desired DOM structure\r\n *\t@returns {Element} dom\t\t\tThe created/mutated element\r\n *\t@private\r\n */\r\nexport function diff(dom, vnode, context, mountAll, parent, componentRoot) {\r\n\t// diffLevel having been 0 here indicates initial entry into the diff (not a subdiff)\r\n\tif (!diffLevel++) {\r\n\t\t// when first starting the diff, check if we're diffing an SVG or within an SVG\r\n\t\tisSvgMode = parent!=null && parent.ownerSVGElement!==undefined;\r\n\r\n\t\t// hydration is indicated by the existing element to be diffed not having a prop cache\r\n\t\thydrating = dom!=null && !(ATTR_KEY in dom);\r\n\t}\r\n\r\n\tlet ret = idiff(dom, vnode, context, mountAll, componentRoot);\r\n\r\n\t// append the element if its a new parent\r\n\tif (parent && ret.parentNode!==parent) parent.appendChild(ret);\r\n\r\n\t// diffLevel being reduced to 0 means we're exiting the diff\r\n\tif (!--diffLevel) {\r\n\t\thydrating = false;\r\n\t\t// invoke queued componentDidMount lifecycle methods\r\n\t\t\r\n\t}\r\n\r\n\treturn ret;\r\n}\r\n\r\n\r\n/** Internals of `diff()`, separated to allow bypassing diffLevel / mount flushing. */\r\nfunction idiff(dom, vnode, context, mountAll, componentRoot) {\r\n\tlet out = dom,\r\n\t\tprevSvgMode = isSvgMode;\r\n\r\n\t// empty values (null, undefined, booleans) render as empty Text nodes\r\n\tif (vnode==null || typeof vnode==='boolean') vnode = '';\r\n\r\n\r\n\t// Fast case: Strings & Numbers create/update Text nodes.\r\n\tif (typeof vnode==='string' || typeof vnode==='number') {\r\n\r\n\t\t// update if it's already a Text node:\r\n\t\tif (dom && dom.splitText!==undefined && dom.parentNode && (!dom._component || componentRoot)) {\r\n\t\t\t/* istanbul ignore if */ /* Browser quirk that can't be covered: https://github.com/developit/preact/commit/fd4f21f5c45dfd75151bd27b4c217d8003aa5eb9 */\r\n\t\t\tif (dom.nodeValue!=vnode) {\r\n\t\t\t\tdom.nodeValue = vnode;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse {\r\n\t\t\t// it wasn't a Text node: replace it with one and recycle the old Element\r\n\t\t\tout = document.createTextNode(vnode);\r\n\t\t\tif (dom) {\r\n\t\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\r\n\t\t\t\trecollectNodeTree(dom, true);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tout[ATTR_KEY] = true;\r\n\r\n\t\treturn out;\r\n\t}\r\n\r\n\r\n\t// If the VNode represents a Component, perform a component diff:\r\n\tlet vnodeName = vnode.nodeName;\r\n\t\r\n\r\n\t// Tracks entering and exiting SVG namespace when descending through the tree.\r\n\tisSvgMode = vnodeName==='svg' ? true : vnodeName==='foreignObject' ? false : isSvgMode;\r\n\r\n\r\n\t// If there's no existing element or it's the wrong type, create a new one:\r\n\tvnodeName = String(vnodeName);\r\n\tif (!dom || !isNamedNode(dom, vnodeName)) {\r\n\t\tout = createNode(vnodeName, isSvgMode);\r\n\r\n\t\tif (dom) {\r\n\t\t\t// move children into the replacement node\r\n\t\t\twhile (dom.firstChild) out.appendChild(dom.firstChild);\r\n\r\n\t\t\t// if the previous Element was mounted into the DOM, replace it inline\r\n\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\r\n\r\n\t\t\t// recycle the old element (skips non-Element node types)\r\n\t\t\trecollectNodeTree(dom, true);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tlet fc = out.firstChild,\r\n\t\tprops = out[ATTR_KEY],\r\n\t\tvchildren = vnode.children;\r\n\r\n\tif (props==null) {\r\n\t\tprops = out[ATTR_KEY] = {};\r\n\t\tfor (let a=out.attributes, i=a.length; i--; ) props[a[i].name] = a[i].value;\r\n\t}\r\n\r\n\t// Optimization: fast-path for elements containing a single TextNode:\r\n\tif (!hydrating && vchildren && vchildren.length===1 && typeof vchildren[0]==='string' && fc!=null && fc.splitText!==undefined && fc.nextSibling==null) {\r\n\t\tif (fc.nodeValue!=vchildren[0]) {\r\n\t\t\tfc.nodeValue = vchildren[0];\r\n\t\t}\r\n\t}\r\n\t// otherwise, if there are existing or new children, diff them:\r\n\telse if (vchildren && vchildren.length || fc!=null) {\r\n\t\tinnerDiffNode(out, vchildren, context, mountAll, hydrating || props.dangerouslySetInnerHTML!=null);\r\n\t}\r\n\r\n\r\n\t// Apply attributes/props from VNode to the DOM Element:\r\n\tdiffAttributes(out, vnode.attributes, props);\r\n\r\n\r\n\t// restore previous SVG mode: (in case we're exiting an SVG namespace)\r\n\tisSvgMode = prevSvgMode;\r\n\r\n\treturn out;\r\n}\r\n\r\n\r\n/** Apply child and attribute changes between a VNode and a DOM Node to the DOM.\r\n *\t@param {Element} dom\t\t\tElement whose children should be compared & mutated\r\n *\t@param {Array} vchildren\t\tArray of VNodes to compare to `dom.childNodes`\r\n *\t@param {Object} context\t\t\tImplicitly descendant context object (from most recent `getChildContext()`)\r\n *\t@param {Boolean} mountAll\r\n *\t@param {Boolean} isHydrating\tIf `true`, consumes externally created elements similar to hydration\r\n */\r\nfunction innerDiffNode(dom, vchildren, context, mountAll, isHydrating) {\r\n\tlet originalChildren = dom.childNodes,\r\n\t\tchildren = [],\r\n\t\tkeyed = {},\r\n\t\tkeyedLen = 0,\r\n\t\tmin = 0,\r\n\t\tlen = originalChildren.length,\r\n\t\tchildrenLen = 0,\r\n\t\tvlen = vchildren ? vchildren.length : 0,\r\n\t\tj, c, f, vchild, child;\r\n\r\n\t// Build up a map of keyed children and an Array of unkeyed children:\r\n\tif (len!==0) {\r\n\t\tfor (let i=0; i= Object.keys(pre).length){\n for (let key in pre) {\n const currentValue = current[key]\n if (currentValue === undefined) {\n current[key] = null\n } else {\n syncKeys(currentValue, pre[key])\n }\n }\n }\n } else if (rootCurrentType == ARRAYTYPE && rootPreType == ARRAYTYPE) {\n if (current.length >= pre.length) {\n pre.forEach((item, index) => {\n syncKeys(current[index], item)\n })\n }\n }\n}\n\nfunction _diff(current, pre, path, result) {\n if (current === pre) return\n const rootCurrentType = type(current)\n const rootPreType = type(pre)\n if (rootCurrentType == OBJECTTYPE) {\n if (rootPreType != OBJECTTYPE || Object.keys(current).length < Object.keys(pre).length) {\n setResult(result, path, current)\n } else {\n for (let key in current) {\n const currentValue = current[key]\n const preValue = pre[key]\n const currentType = type(currentValue)\n const preType = type(preValue)\n if (currentType != ARRAYTYPE && currentType != OBJECTTYPE) {\n if (currentValue != pre[key]) {\n setResult(result, (path == '' ? '' : path + \".\") + key, currentValue)\n }\n } else if (currentType == ARRAYTYPE) {\n if (preType != ARRAYTYPE) {\n setResult(result, (path == '' ? '' : path + \".\") + key, currentValue)\n } else {\n if (currentValue.length < preValue.length) {\n setResult(result, (path == '' ? '' : path + \".\") + key, currentValue)\n } else {\n currentValue.forEach((item, index) => {\n _diff(item, preValue[index], (path == '' ? '' : path + \".\") + key + '[' + index + ']', result)\n })\n }\n }\n } else if (currentType == OBJECTTYPE) {\n if (preType != OBJECTTYPE || Object.keys(currentValue).length < Object.keys(preValue).length) {\n setResult(result, (path == '' ? '' : path + \".\") + key, currentValue)\n } else {\n for (let subKey in currentValue) {\n _diff(currentValue[subKey], preValue[subKey], (path == '' ? '' : path + \".\") + key + '.' + subKey, result)\n }\n }\n }\n }\n }\n } else if (rootCurrentType == ARRAYTYPE) {\n if (rootPreType != ARRAYTYPE) {\n setResult(result, path, current)\n } else {\n if (current.length < pre.length) {\n setResult(result, path, current)\n } else {\n current.forEach((item, index) => {\n _diff(item, pre[index], path + '[' + index + ']', result)\n })\n }\n }\n } else {\n setResult(result, path, current)\n }\n}\n\nfunction setResult(result, k, v) {\n if (type(v) != FUNCTIONTYPE) {\n result[k] = v\n }\n}\n\nfunction type(obj) {\n return Object.prototype.toString.call(obj)\n}","\r\nimport { diff } from './vdom/diff'\r\nimport options from './options'\r\nimport jsonDiff from './json-diff'\r\n\r\nexport function render(vnode, parent, store) {\r\n\tparent = typeof parent === 'string' ? document.querySelector(parent) : parent\r\n\tif(store){\r\n\t\tstore.instances = []\r\n\t\textendStoreUpate(store)\r\n\t\toptions.store = store\r\n\t\tstore.originData = JSON.parse(JSON.stringify(store.data))\t\r\n\t}\r\n\tdiff(null, vnode, {}, false, parent, false)\r\n} \r\n\r\nfunction extendStoreUpate(store){\r\n\tstore.update = function(){\r\n\t\tlet diffResult = jsonDiff(this.data, this.originData)\r\n\t\tif (Object.keys(diffResult)[0] == '') {\r\n\t\t\tdiffResult = diffResult['']\r\n\t\t}\r\n\t\tconst updateAll = matchGlobalData(this.globalData, diffResult)\r\n\t\tif (Object.keys(diffResult).length > 0) {\r\n\t\t\tthis.instances.forEach(instance => {\r\n\t\t\t\tif(updateAll || this.updateAll || instance.constructor.updatePath && needUpdate(diffResult, instance.constructor.updatePath)){\r\n\t\t\t\t\tinstance.update()\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t\tthis.onChange && this.onChange(diffResult)\r\n\t\t\tfor (let key in diffResult) {\r\n\t\t\t\tupdateByPath(this.originData, key, typeof diffResult[key] === 'object' ? JSON.parse(JSON.stringify(diffResult[key])) : diffResult[key])\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunction matchGlobalData(globalData, diffResult) {\r\n\tif(!globalData) return false\r\n for (let keyA in diffResult) {\r\n if (globalData.indexOf(keyA) > -1) {\r\n return true\r\n }\r\n for (let i = 0, len = globalData.length; i < len; i++) {\r\n if (includePath(keyA, globalData[i])) {\r\n return true\r\n }\r\n }\r\n }\r\n return false\r\n}\r\n\r\nfunction needUpdate(diffResult, updatePath){\r\n for(let keyA in diffResult){\r\n if(updatePath[keyA]){\r\n return true\r\n }\r\n for(let keyB in updatePath){\r\n if(includePath(keyA, keyB)){\r\n return true\r\n }\r\n }\r\n }\r\n return false\r\n}\r\n\r\nfunction includePath(pathA, pathB){\r\n if(pathA.indexOf(pathB)===0){\r\n const next = pathA.substr(pathB.length, 1)\r\n if(next === '['||next === '.'){\r\n return true\r\n }\r\n }\r\n return false\r\n}\r\n\r\nfunction updateByPath(origin, path, value) {\r\n const arr = path.replace(/]/g, '').replace(/\\[/g, '.').split('.')\r\n let current = origin\r\n for (let i = 0, len = arr.length; i < len; i++) {\r\n if (i === len - 1) {\r\n current[arr[i]] = value\r\n } else {\r\n current = current[arr[i]]\r\n }\r\n }\r\n}\r\n","const OBJECTTYPE = '[object Object]'\r\n\r\nexport function define(name, ctor) {\r\n customElements.define(name, ctor)\r\n if (ctor.data) {\r\n ctor.updatePath = getUpdatePath(ctor.data)\r\n }\r\n}\r\n\r\nfunction getUpdatePath(data) {\r\n const result = {}\r\n dataToPath(data, result)\r\n return result\r\n}\r\n\r\nfunction dataToPath(data, result) {\r\n Object.keys(data).forEach(key => {\r\n result[key] = true\r\n const type = Object.prototype.toString.call(data[key])\r\n if (type === OBJECTTYPE) {\r\n _dataToPath(data[key], key, result)\r\n }\r\n })\r\n}\r\n\r\nfunction _dataToPath(data, path, result) {\r\n Object.keys(data).forEach(key => {\r\n result[path + '.' + key] = true\r\n const type = Object.prototype.toString.call(data[key])\r\n if (type === OBJECTTYPE) {\r\n _dataToPath(data[key], path + '.' + key, result)\r\n }\r\n })\r\n}","import { h, h as createElement } from './h';\r\nimport options from './options';\r\nimport WeElement from './we-element';\r\nimport { render } from './render';\r\nimport { define } from './define'\r\n\r\nconst instances = [];\r\n\r\noptions.root.Omi = {\r\n\th,\r\n\tcreateElement,\r\n\tWeElement,\r\n\trender,\r\n\toptions,\r\n\tinstances,\r\n\tdefine\r\n};\r\n\r\noptions.root.Omi.version = '4.0.0';\r\n\r\nexport default {\r\n\th,\r\n\tcreateElement,\r\n\tWeElement,\r\n\trender,\r\n\toptions,\r\n\tinstances,\r\n\tdefine\r\n};\r\n\r\nexport {\r\n\th,\r\n\tcreateElement,\r\n\tWeElement,\r\n\trender,\r\n\toptions,\r\n\tinstances,\r\n\tdefine\r\n};\r\n","\n\t\t\t\timport Omi from './omi';\n\t\t\t\tif (typeof module!='undefined') module.exports = Omi;\n\t\t\t\telse self.Omi = Omi;\n\t\t\t"],"names":["VNode","getGlobal","global","Math","Array","self","window","store","root","stack","EMPTY_CHILDREN","h","nodeName","attributes","children","lastSimple","child","simple","i","arguments","length","push","pop","undefined","String","p","key","options","vnode","Reflect","customElements","hasOwnProperty","BuiltInHTMLElement","HTMLElement","construct","constructor","prototype","Object","setPrototypeOf","cssToDom","css","node","document","createElement","innerText","npn","str","replace","$","$1","toUpperCase","applyRef","ref","value","current","defer","Promise","resolve","then","bind","setTimeout","isArray","obj","toString","call","nProps","props","result","keys","forEach","ATTR_KEY","IS_NON_DIMENSIONAL","isSameNodeType","hydrating","splitText","_componentConstructor","isNamedNode","normalizedNodeName","toLowerCase","createNode","isSvg","createElementNS","removeNode","parentNode","removeChild","setAccessor","name","old","className","style","cssText","test","innerHTML","__html","useCapture","substring","addEventListener","eventProxy","removeEventListener","_listeners","e","removeAttribute","ns","removeAttributeNS","setAttributeNS","setAttribute","type","event","diffLevel","isSvgMode","diff","dom","context","mountAll","parent","componentRoot","ownerSVGElement","ret","idiff","appendChild","out","prevSvgMode","_component","nodeValue","createTextNode","replaceChild","recollectNodeTree","vnodeName","firstChild","fc","vchildren","a","nextSibling","innerDiffNode","dangerouslySetInnerHTML","diffAttributes","isHydrating","originalChildren","childNodes","keyed","keyedLen","min","len","childrenLen","vlen","j","c","f","vchild","__key","trim","insertBefore","unmountOnly","removeChildren","lastChild","next","previousSibling","attrs","update","WeElement","data","connectedCallback","instances","install","shadowRoot","attachShadow","mode","host","render","installed","attributeChangedCallback","pre","disconnectedCallback","uninstall","beforeUpdate","afterUpdate","fire","dispatchEvent","CustomEvent","detail","ARRAYTYPE","OBJECTTYPE","FUNCTIONTYPE","syncKeys","_diff","rootCurrentType","rootPreType","currentValue","item","index","path","setResult","preValue","currentType","preType","subKey","k","v","querySelector","extendStoreUpate","originData","JSON","parse","stringify","diffResult","jsonDiff","updateAll","matchGlobalData","globalData","instance","updatePath","needUpdate","onChange","updateByPath","keyA","indexOf","includePath","keyB","pathA","pathB","substr","origin","arr","split","define","ctor","getUpdatePath","dataToPath","_dataToPath","Omi","version","module","exports"],"mappings":";;;;;;;;;;;CAAA;AACA,CAAO,SAASA,KAAT,GAAiB;;CCDxB,SAASC,SAAT,GAAqB;CACpB,KAAI,OAAOC,MAAP,KAAkB,QAAlB,IAA8B,CAACA,MAA/B,IAAyCA,OAAOC,IAAP,KAAgBA,IAAzD,IAAiED,OAAOE,KAAP,KAAiBA,KAAtF,EAA6F;CAC5F,MAAI,OAAOC,IAAP,KAAgB,WAApB,EAAiC;CAChC,UAAOA,IAAP;CACA,GAFD,MAEO,IAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;CACzC,UAAOA,MAAP;CACA,GAFM,MAEA,IAAI,OAAOJ,MAAP,KAAkB,WAAtB,EAAmC;CACzC,UAAOA,MAAP;CACA;CACD,SAAQ,YAAU;CACjB,UAAO,IAAP;CACA,GAFM,EAAP;CAIA;CACD,QAAOA,MAAP;CACA;;CAED;;;;AAIA,eAAe;;CAEdK,QAAO,IAFO;;CAIdC,OAAMP;CACN;CACA;;;;;CAKA;;CAEA;;;CAGA;;CAEA;CACA;;CAEA;CACA;;CAEA;CACA;CAzBc,CAAf;;KCjBMQ,QAAQ,EAAd;;CAEA,IAAMC,iBAAiB,EAAvB;;AAEA,CAAO,SAASC,CAAT,CAAWC,QAAX,EAAqBC,UAArB,EAAiC;CACvC,KAAIC,WAASJ,cAAb;CAAA,KAA6BK,mBAA7B;CAAA,KAAyCC,cAAzC;CAAA,KAAgDC,eAAhD;CAAA,KAAwDC,UAAxD;CACA,MAAKA,IAAEC,UAAUC,MAAjB,EAAyBF,MAAM,CAA/B,GAAoC;CACnCT,QAA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,qBAHc;CAIdS,eAJc;CAKd7I,iBALc;CAMduI,qBANc;CAOd8D;CAPc,CAAf;;CClBI,IAAI,OAAOO,MAAP,IAAe,WAAnB,EAAgCA,OAAOC,OAAP,GAAiBH,GAAjB,CAAhC,KACKhO,KAAKgO,GAAL,GAAWA,GAAX;;"} \ No newline at end of file diff --git a/dist/omi.esm.js b/dist/omi.esm.js index a98676756..35845d6ca 100644 --- a/dist/omi.esm.js +++ b/dist/omi.esm.js @@ -613,10 +613,12 @@ function diffAttributes(dom, attrs, old) { 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?? dom.props[npn(name)] = attrs[name]; - update = true; + dom.parentNode && (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); } @@ -647,6 +649,10 @@ var WeElement = function (_HTMLElement) { } WeElement.prototype.connectedCallback = function connectedCallback() { + this.store = options.store; + if (this.store) { + this.store.instances.push(this); + } this.install(); var shadowRoot = this.attachShadow({ mode: 'open' }); @@ -703,9 +709,224 @@ var WeElement = function (_HTMLElement) { return WeElement; }(HTMLElement); -function render(vnode, parent) { - parent = typeof parent === 'string' ? document.querySelector(parent) : parent; - diff(null, vnode, {}, false, parent, false); +function diff$1(current, pre) { + var result = {}; + syncKeys(current, pre); + _diff(current, pre, '', result); + return result; +} + +function syncKeys(current, pre) { + if (current === pre) return; + var rootCurrentType = type(current); + var rootPreType = type(pre); + if (rootCurrentType == '[object Object]' && rootPreType == '[object Object]') { + if (Object.keys(current).length >= Object.keys(pre).length) { + for (var key in pre) { + var currentValue = current[key]; + if (currentValue === undefined) { + current[key] = null; + } else { + syncKeys(currentValue, pre[key]); + } + } + } + } else if (rootCurrentType == '[object Array]' && rootPreType == '[object Array]') { + if (current.length >= pre.length) { + pre.forEach(function (item, index) { + syncKeys(current[index], item); + }); + } + } +} + +function _diff(current, pre, path, result) { + if (current === pre) return; + var rootCurrentType = type(current); + var rootPreType = type(pre); + if (rootCurrentType == '[object Object]') { + if (rootPreType != '[object Object]' || Object.keys(current).length < Object.keys(pre).length) { + setResult(result, path, current); + } else { + var _loop = function _loop(key) { + var currentValue = current[key]; + var preValue = pre[key]; + var currentType = type(currentValue); + var preType = type(preValue); + if (currentType != '[object Array]' && currentType != '[object Object]') { + if (currentValue != pre[key]) { + setResult(result, (path == '' ? '' : path + ".") + key, currentValue); + } + } else if (currentType == '[object Array]') { + if (preType != '[object Array]') { + setResult(result, (path == '' ? '' : path + ".") + key, currentValue); + } else { + if (currentValue.length < preValue.length) { + setResult(result, (path == '' ? '' : path + ".") + key, currentValue); + } else { + currentValue.forEach(function (item, index) { + _diff(item, preValue[index], (path == '' ? '' : path + ".") + key + '[' + index + ']', result); + }); + } + } + } else if (currentType == '[object Object]') { + if (preType != '[object Object]' || Object.keys(currentValue).length < Object.keys(preValue).length) { + setResult(result, (path == '' ? '' : path + ".") + key, currentValue); + } else { + for (var subKey in currentValue) { + _diff(currentValue[subKey], preValue[subKey], (path == '' ? '' : path + ".") + key + '.' + subKey, result); + } + } + } + }; + + for (var key in current) { + _loop(key); + } + } + } else if (rootCurrentType == '[object Array]') { + if (rootPreType != '[object Array]') { + setResult(result, path, current); + } else { + if (current.length < pre.length) { + setResult(result, path, current); + } else { + current.forEach(function (item, index) { + _diff(item, pre[index], path + '[' + index + ']', result); + }); + } + } + } else { + setResult(result, path, current); + } +} + +function setResult(result, k, v) { + if (type(v) != '[object Function]') { + result[k] = v; + } +} + +function type(obj) { + return Object.prototype.toString.call(obj); +} + +function render(vnode, parent, store) { + parent = typeof parent === 'string' ? document.querySelector(parent) : parent; + if (store) { + store.instances = []; + extendStoreUpate(store); + options.store = store; + store.originData = JSON.parse(JSON.stringify(store.data)); + } + diff(null, vnode, {}, false, parent, false); +} + +function extendStoreUpate(store) { + store.update = function () { + var _this = this; + + var diffResult = diff$1(this.data, this.originData); + if (Object.keys(diffResult)[0] == '') { + diffResult = diffResult['']; + } + var updateAll = matchGlobalData(this.globalData, diffResult); + if (Object.keys(diffResult).length > 0) { + this.instances.forEach(function (instance) { + if (updateAll || _this.updateAll || instance.constructor.updatePath && needUpdate(diffResult, instance.constructor.updatePath)) { + instance.update(); + } + }); + this.onChange && this.onChange(diffResult); + for (var key in diffResult) { + updateByPath(this.originData, key, typeof diffResult[key] === 'object' ? JSON.parse(JSON.stringify(diffResult[key])) : diffResult[key]); + } + } + }; +} + +function matchGlobalData(globalData, diffResult) { + if (!globalData) return false; + for (var keyA in diffResult) { + if (globalData.indexOf(keyA) > -1) { + return true; + } + for (var i = 0, len = globalData.length; i < len; i++) { + if (includePath(keyA, globalData[i])) { + return true; + } + } + } + return false; +} + +function needUpdate(diffResult, updatePath) { + for (var keyA in diffResult) { + if (updatePath[keyA]) { + return true; + } + for (var keyB in updatePath) { + if (includePath(keyA, keyB)) { + return true; + } + } + } + return false; +} + +function includePath(pathA, pathB) { + if (pathA.indexOf(pathB) === 0) { + var next = pathA.substr(pathB.length, 1); + if (next === '[' || next === '.') { + return true; + } + } + return false; +} + +function updateByPath(origin, path, value) { + var arr = path.replace(/]/g, '').replace(/\[/g, '.').split('.'); + var current = origin; + for (var i = 0, len = arr.length; i < len; i++) { + if (i === len - 1) { + current[arr[i]] = value; + } else { + current = current[arr[i]]; + } + } +} + +function define(name, ctor) { + customElements.define(name, ctor); + if (ctor.data) { + ctor.updatePath = getUpdatePath(ctor.data); + } +} + +function getUpdatePath(data) { + var result = {}; + dataToPath(data, result); + return result; +} + +function dataToPath(data, result) { + Object.keys(data).forEach(function (key) { + result[key] = true; + var type = Object.prototype.toString.call(data[key]); + if (type === '[object Object]') { + _dataToPath(data[key], key, result); + } + }); +} + +function _dataToPath(data, path, result) { + Object.keys(data).forEach(function (key) { + result[path + '.' + key] = true; + var type = Object.prototype.toString.call(data[key]); + if (type === '[object Object]') { + _dataToPath(data[key], path + '.' + key, result); + } + }); } var instances = []; @@ -716,7 +937,8 @@ options.root.Omi = { WeElement: WeElement, render: render, options: options, - instances: instances + instances: instances, + define: define }; options.root.Omi.version = '4.0.0'; @@ -727,9 +949,10 @@ var omi = { WeElement: WeElement, render: render, options: options, - instances: instances + instances: instances, + define: define }; export default omi; -export { h, h as createElement, WeElement, render, options, instances }; +export { h, h as createElement, WeElement, render, options, instances, define }; //# sourceMappingURL=omi.esm.js.map diff --git a/dist/omi.esm.js.map b/dist/omi.esm.js.map index 7f0ba0913..8b29d3034 100644 --- a/dist/omi.esm.js.map +++ b/dist/omi.esm.js.map @@ -1 +1 @@ -{"version":3,"file":"omi.esm.js","sources":["../src/vnode.js","../src/options.js","../src/h.js","../src/util.js","../src/constants.js","../src/vdom/index.js","../src/dom/index.js","../src/vdom/diff.js","../src/we-element.js","../src/render.js","../src/omi.js"],"sourcesContent":["/** Virtual DOM Node */\r\nexport function VNode() {}\r\n","function getGlobal() {\r\n\tif (typeof global !== 'object' || !global || global.Math !== Math || global.Array !== Array) {\r\n\t\tif (typeof self !== 'undefined') {\r\n\t\t\treturn self;\r\n\t\t} else if (typeof window !== 'undefined') {\r\n\t\t\treturn window;\r\n\t\t} else if (typeof global !== 'undefined') {\r\n\t\t\treturn global;\r\n\t\t}\r\n\t\treturn (function(){\r\n\t\t\treturn this;\r\n\t\t})();\r\n\t\t\r\n\t}\r\n\treturn global;\r\n}\r\n\r\n/** Global options\r\n *\t@public\r\n *\t@namespace options {Object}\r\n */\r\nexport default {\r\n\r\n\tstore: null,\r\n\t\r\n\troot: getGlobal()\r\n\t//componentChange(component, element) { },\r\n\t/** If `true`, `prop` changes trigger synchronous component updates.\r\n\t *\t@name syncComponentUpdates\r\n\t *\t@type Boolean\r\n\t *\t@default true\r\n\t */\r\n\t//syncComponentUpdates: true,\r\n\r\n\t/** Processes all created VNodes.\r\n\t *\t@param {VNode} vnode\tA newly-created VNode to normalize/process\r\n\t */\r\n\t//vnode(vnode) { }\r\n\r\n\t/** Hook invoked after a component is mounted. */\r\n\t//afterMount(component) { },\r\n\r\n\t/** Hook invoked after the DOM is updated with a component's latest render. */\r\n\t//afterUpdate(component) { }\r\n\r\n\t/** Hook invoked immediately before a component is unmounted. */\r\n\t// beforeUnmount(component) { }\r\n};\r\n","import { VNode } from './vnode';\r\nimport options from './options';\r\n\r\n\r\nconst stack = [];\r\n\r\nconst EMPTY_CHILDREN = [];\r\n\r\nexport function h(nodeName, attributes) {\r\n\tlet children=EMPTY_CHILDREN, lastSimple, child, simple, i;\r\n\tfor (i=arguments.length; i-- > 2; ) {\r\n\t\tstack.push(arguments[i]);\r\n\t}\r\n\tif (attributes && attributes.children!=null) {\r\n\t\tif (!stack.length) stack.push(attributes.children);\r\n\t\tdelete attributes.children;\r\n\t}\r\n\twhile (stack.length) {\r\n\t\tif ((child = stack.pop()) && child.pop!==undefined) {\r\n\t\t\tfor (i=child.length; i--; ) stack.push(child[i]);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tif (typeof child==='boolean') child = null;\r\n\r\n\t\t\tif ((simple = typeof nodeName!=='function')) {\r\n\t\t\t\tif (child==null) child = '';\r\n\t\t\t\telse if (typeof child==='number') child = String(child);\r\n\t\t\t\telse if (typeof child!=='string') simple = false;\r\n\t\t\t}\r\n\r\n\t\t\tif (simple && lastSimple) {\r\n\t\t\t\tchildren[children.length-1] += child;\r\n\t\t\t}\r\n\t\t\telse if (children===EMPTY_CHILDREN) {\r\n\t\t\t\tchildren = [child];\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tchildren.push(child);\r\n\t\t\t}\r\n\r\n\t\t\tlastSimple = simple;\r\n\t\t}\r\n\t}\r\n\r\n\tlet p = new VNode();\r\n\tp.nodeName = nodeName;\r\n\tp.children = children;\r\n\tp.attributes = attributes==null ? undefined : attributes;\r\n\tp.key = attributes==null ? undefined : attributes.key;\r\n\r\n\t// if a \"vnode hook\" is defined, pass every created VNode to it\r\n\tif (options.vnode!==undefined) options.vnode(p);\r\n\r\n\treturn p;\r\n}","/**\r\n * @license\r\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\r\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\r\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\r\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\r\n * Code distributed by Google as part of the polymer project is also\r\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\r\n */\r\n\r\n/**\r\n * This shim allows elements written in, or compiled to, ES5 to work on native\r\n * implementations of Custom Elements v1. It sets new.target to the value of\r\n * this.constructor so that the native HTMLElement constructor can access the\r\n * current under-construction element's definition.\r\n */\r\n(function() {\r\n if (\r\n // No Reflect, no classes, no need for shim because native custom elements\r\n // require ES2015 classes or Reflect.\r\n window.Reflect === undefined ||\r\n window.customElements === undefined ||\r\n // The webcomponentsjs custom elements polyfill doesn't require\r\n // ES2015-compatible construction (`super()` or `Reflect.construct`).\r\n window.customElements.hasOwnProperty('polyfillWrapFlushCallback')\r\n ) {\r\n return;\r\n }\r\n const BuiltInHTMLElement = HTMLElement;\r\n window.HTMLElement = function HTMLElement() {\r\n return Reflect.construct(BuiltInHTMLElement, [], this.constructor);\r\n };\r\n HTMLElement.prototype = BuiltInHTMLElement.prototype;\r\n HTMLElement.prototype.constructor = HTMLElement;\r\n Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement);\r\n })();\r\n\r\n\r\n\r\nexport function cssToDom(css) {\r\n const node = document.createElement('style')\r\n node.innerText = css\r\n return node\r\n}\r\n\r\n\r\nexport function npn(str) {\r\n return str.replace(/-(\\w)/g, function ($, $1) {\r\n return $1.toUpperCase();\r\n });\r\n}\r\n\r\nexport function extend(obj, props) {\r\n\tfor (let i in props) obj[i] = props[i];\r\n\treturn obj;\r\n}\r\n\r\n/** Invoke or update a ref, depending on whether it is a function or object ref.\r\n * @param {object|function} [ref=null]\r\n * @param {any} [value]\r\n */\r\nexport function applyRef(ref, value) {\r\n\tif (ref!=null) {\r\n\t\tif (typeof ref=='function') ref(value);\r\n\t\telse ref.current = value;\r\n\t}\r\n}\r\n\r\n/**\r\n * Call a function asynchronously, as soon as possible. Makes\r\n * use of HTML Promise to schedule the callback if available,\r\n * otherwise falling back to `setTimeout` (mainly for IE<11).\r\n * @type {(callback: function) => void}\r\n */\r\nexport const defer = typeof Promise=='function' ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout;\r\n\r\nexport function isArray(obj){\r\n return Object.prototype.toString.call(obj) === '[object Array]'\r\n}\r\n\r\nexport function nProps(props){\r\n if(!props || isArray(props)) return {}\r\n const result = {}\r\n Object.keys(props).forEach(key =>{\r\n result[key] = props[key].value \r\n })\r\n return result\r\n}\r\n","// render modes\r\n\r\nexport const NO_RENDER = 0;\r\nexport const SYNC_RENDER = 1;\r\nexport const FORCE_RENDER = 2;\r\nexport const ASYNC_RENDER = 3;\r\n\r\n\r\nexport const ATTR_KEY = '__preactattr_';\r\n\r\n// DOM properties that should NOT have \"px\" added when numeric\r\nexport const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i;\r\n\r\n","import { extend } from '../util';\r\n\r\n\r\n/**\r\n * Check if two nodes are equivalent.\r\n *\r\n * @param {Node} node\t\t\tDOM Node to compare\r\n * @param {VNode} vnode\t\t\tVirtual DOM node to compare\r\n * @param {boolean} [hydrating=false]\tIf true, ignores component constructors when comparing.\r\n * @private\r\n */\r\nexport function isSameNodeType(node, vnode, hydrating) {\r\n\tif (typeof vnode==='string' || typeof vnode==='number') {\r\n\t\treturn node.splitText!==undefined;\r\n\t}\r\n\tif (typeof vnode.nodeName==='string') {\r\n\t\treturn !node._componentConstructor && isNamedNode(node, vnode.nodeName);\r\n\t}\r\n\treturn hydrating || node._componentConstructor===vnode.nodeName;\r\n}\r\n\r\n\r\n/**\r\n * Check if an Element has a given nodeName, case-insensitively.\r\n *\r\n * @param {Element} node\tA DOM Element to inspect the name of.\r\n * @param {String} nodeName\tUnnormalized name to compare against.\r\n */\r\nexport function isNamedNode(node, nodeName) {\r\n\treturn node.normalizedNodeName===nodeName || node.nodeName.toLowerCase()===nodeName.toLowerCase();\r\n}\r\n\r\n\r\n/**\r\n * Reconstruct Component-style `props` from a VNode.\r\n * Ensures default/fallback values from `defaultProps`:\r\n * Own-properties of `defaultProps` not present in `vnode.attributes` are added.\r\n *\r\n * @param {VNode} vnode\r\n * @returns {Object} props\r\n */\r\nexport function getNodeProps(vnode) {\r\n\tlet props = extend({}, vnode.attributes);\r\n\tprops.children = vnode.children;\r\n\r\n\tlet defaultProps = vnode.nodeName.defaultProps;\r\n\tif (defaultProps!==undefined) {\r\n\t\tfor (let i in defaultProps) {\r\n\t\t\tif (props[i]===undefined) {\r\n\t\t\t\tprops[i] = defaultProps[i];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn props;\r\n}\r\n","import { IS_NON_DIMENSIONAL } from '../constants';\r\nimport { applyRef } from '../util';\r\nimport options from '../options';\r\nimport { npn } from '../util'\r\n\r\n/**\r\n * A DOM event listener\r\n * @typedef {(e: Event) => void} EventListner\r\n */\r\n\r\n/**\r\n * A mapping of event types to event listeners\r\n * @typedef {Object.} EventListenerMap\r\n */\r\n\r\n/**\r\n * Properties Preact adds to elements it creates\r\n * @typedef PreactElementExtensions\r\n * @property {string} [normalizedNodeName] A normalized node name to use in diffing\r\n * @property {EventListenerMap} [_listeners] A map of event listeners added by components to this DOM node\r\n * @property {import('../component').Component} [_component] The component that rendered this DOM node\r\n * @property {function} [_componentConstructor] The constructor of the component that rendered this DOM node\r\n */\r\n\r\n/**\r\n * A DOM element that has been extended with Preact properties\r\n * @typedef {Element & ElementCSSInlineStyle & PreactElementExtensions} PreactElement\r\n */\r\n\r\n/**\r\n * Create an element with the given nodeName.\r\n * @param {string} nodeName The DOM node to create\r\n * @param {boolean} [isSvg=false] If `true`, creates an element within the SVG\r\n * namespace.\r\n * @returns {PreactElement} The created DOM node\r\n */\r\nexport function createNode(nodeName, isSvg) {\r\n\t/** @type {PreactElement} */\r\n\tlet node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName);\r\n\tnode.normalizedNodeName = nodeName;\r\n\treturn node;\r\n}\r\n\r\n\r\n/**\r\n * Remove a child node from its parent if attached.\r\n * @param {Node} node The node to remove\r\n */\r\nexport function removeNode(node) {\r\n\tlet parentNode = node.parentNode;\r\n\tif (parentNode) parentNode.removeChild(node);\r\n}\r\n\r\n\r\n/**\r\n * Set a named attribute on the given Node, with special behavior for some names\r\n * and event handlers. If `value` is `null`, the attribute/handler will be\r\n * removed.\r\n * @param {PreactElement} node An element to mutate\r\n * @param {string} name The name/key to set, such as an event or attribute name\r\n * @param {*} old The last value that was set for this name/node pair\r\n * @param {*} value An attribute value, such as a function to be used as an\r\n * event handler\r\n * @param {boolean} isSvg Are we currently diffing inside an svg?\r\n * @private\r\n */\r\nexport function setAccessor(node, name, old, value, isSvg) {\r\n\tif (name==='className') name = 'class';\r\n\r\n\r\n\tif (name==='key') {\r\n\t\t// ignore\r\n\t}\r\n\telse if (name==='ref') {\r\n\t\tapplyRef(old, null);\r\n\t\tapplyRef(value, node);\r\n\t}\r\n\telse if (name==='class' && !isSvg) {\r\n\t\tnode.className = value || '';\r\n\t}\r\n\telse if (name==='style') {\r\n\t\tif (!value || typeof value==='string' || typeof old==='string') {\r\n\t\t\tnode.style.cssText = value || '';\r\n\t\t}\r\n\t\tif (value && typeof value==='object') {\r\n\t\t\tif (typeof old!=='string') {\r\n\t\t\t\tfor (let i in old) if (!(i in value)) node.style[i] = '';\r\n\t\t\t}\r\n\t\t\tfor (let i in value) {\r\n\t\t\t\tnode.style[i] = typeof value[i]==='number' && IS_NON_DIMENSIONAL.test(i)===false ? (value[i]+'px') : value[i];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\telse if (name==='dangerouslySetInnerHTML') {\r\n\t\tif (value) node.innerHTML = value.__html || '';\r\n\t}\r\n\telse if (name[0]=='o' && name[1]=='n') {\r\n\t\tlet useCapture = name !== (name=name.replace(/Capture$/, ''));\r\n\t\tname = name.toLowerCase().substring(2);\r\n\t\tif (value) {\r\n\t\t\tif (!old) node.addEventListener(name, eventProxy, useCapture);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tnode.removeEventListener(name, eventProxy, useCapture);\r\n\t\t}\r\n\t\t(node._listeners || (node._listeners = {}))[name] = value;\r\n\t}\r\n\telse if (name!=='list' && name!=='type' && !isSvg && name in node) {\r\n\t\t// Attempt to set a DOM property to the given value.\r\n\t\t// IE & FF throw for certain property-value combinations.\r\n\t\ttry {\r\n\t\t\tnode[name] = value==null ? '' : value;\r\n\t\t} catch (e) { }\r\n\t\tif ((value==null || value===false) && name!='spellcheck') node.removeAttribute(name);\r\n\t}\r\n\telse {\r\n\t\tlet ns = isSvg && (name !== (name = name.replace(/^xlink:?/, '')));\r\n\t\t// spellcheck is treated differently than all other boolean values and\r\n\t\t// should not be removed when the value is `false`. See:\r\n\t\t// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-spellcheck\r\n\t\tif (value==null || value===false) {\r\n\t\t\tif (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());\r\n\t\t\telse node.removeAttribute(name);\r\n\t\t}\r\n\t\telse if (typeof value!=='function') {\r\n\t\t\tif (ns) {\r\n\t\t\t\tnode.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);\r\n\t\t\t\tnode.props[npn(name.toLowerCase())] = value;\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tnode.setAttribute(name, value);\r\n\t\t\t\tnode.props[npn(name)] = value;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\n/**\r\n * Proxy an event to hooked event handlers\r\n * @param {Event} e The event object from the browser\r\n * @private\r\n */\r\nfunction eventProxy(e) {\r\n\treturn this._listeners[e.type](options.event && options.event(e) || e);\r\n}","import { ATTR_KEY } from '../constants';\r\nimport { isSameNodeType, isNamedNode } from './index';\r\nimport { createNode, setAccessor } from '../dom/index';\r\nimport { npn } from '../util'\r\nimport { removeNode } from '../dom/index';\r\n\r\n/** Queue of components that have been mounted and are awaiting componentDidMount */\r\nexport const mounts = [];\r\n\r\n/** Diff recursion count, used to track the end of the diff cycle. */\r\nexport let diffLevel = 0;\r\n\r\n/** Global flag indicating if the diff is currently within an SVG */\r\nlet isSvgMode = false;\r\n\r\n/** Global flag indicating if the diff is performing hydration */\r\nlet hydrating = false;\r\n\r\n\r\n\r\n\r\n/** Apply differences in a given vnode (and it's deep children) to a real DOM Node.\r\n *\t@param {Element} [dom=null]\t\tA DOM node to mutate into the shape of the `vnode`\r\n *\t@param {VNode} vnode\t\t\tA VNode (with descendants forming a tree) representing the desired DOM structure\r\n *\t@returns {Element} dom\t\t\tThe created/mutated element\r\n *\t@private\r\n */\r\nexport function diff(dom, vnode, context, mountAll, parent, componentRoot) {\r\n\t// diffLevel having been 0 here indicates initial entry into the diff (not a subdiff)\r\n\tif (!diffLevel++) {\r\n\t\t// when first starting the diff, check if we're diffing an SVG or within an SVG\r\n\t\tisSvgMode = parent!=null && parent.ownerSVGElement!==undefined;\r\n\r\n\t\t// hydration is indicated by the existing element to be diffed not having a prop cache\r\n\t\thydrating = dom!=null && !(ATTR_KEY in dom);\r\n\t}\r\n\r\n\tlet ret = idiff(dom, vnode, context, mountAll, componentRoot);\r\n\r\n\t// append the element if its a new parent\r\n\tif (parent && ret.parentNode!==parent) parent.appendChild(ret);\r\n\r\n\t// diffLevel being reduced to 0 means we're exiting the diff\r\n\tif (!--diffLevel) {\r\n\t\thydrating = false;\r\n\t\t// invoke queued componentDidMount lifecycle methods\r\n\t\t\r\n\t}\r\n\r\n\treturn ret;\r\n}\r\n\r\n\r\n/** Internals of `diff()`, separated to allow bypassing diffLevel / mount flushing. */\r\nfunction idiff(dom, vnode, context, mountAll, componentRoot) {\r\n\tlet out = dom,\r\n\t\tprevSvgMode = isSvgMode;\r\n\r\n\t// empty values (null, undefined, booleans) render as empty Text nodes\r\n\tif (vnode==null || typeof vnode==='boolean') vnode = '';\r\n\r\n\r\n\t// Fast case: Strings & Numbers create/update Text nodes.\r\n\tif (typeof vnode==='string' || typeof vnode==='number') {\r\n\r\n\t\t// update if it's already a Text node:\r\n\t\tif (dom && dom.splitText!==undefined && dom.parentNode && (!dom._component || componentRoot)) {\r\n\t\t\t/* istanbul ignore if */ /* Browser quirk that can't be covered: https://github.com/developit/preact/commit/fd4f21f5c45dfd75151bd27b4c217d8003aa5eb9 */\r\n\t\t\tif (dom.nodeValue!=vnode) {\r\n\t\t\t\tdom.nodeValue = vnode;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse {\r\n\t\t\t// it wasn't a Text node: replace it with one and recycle the old Element\r\n\t\t\tout = document.createTextNode(vnode);\r\n\t\t\tif (dom) {\r\n\t\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\r\n\t\t\t\trecollectNodeTree(dom, true);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tout[ATTR_KEY] = true;\r\n\r\n\t\treturn out;\r\n\t}\r\n\r\n\r\n\t// If the VNode represents a Component, perform a component diff:\r\n\tlet vnodeName = vnode.nodeName;\r\n\t\r\n\r\n\t// Tracks entering and exiting SVG namespace when descending through the tree.\r\n\tisSvgMode = vnodeName==='svg' ? true : vnodeName==='foreignObject' ? false : isSvgMode;\r\n\r\n\r\n\t// If there's no existing element or it's the wrong type, create a new one:\r\n\tvnodeName = String(vnodeName);\r\n\tif (!dom || !isNamedNode(dom, vnodeName)) {\r\n\t\tout = createNode(vnodeName, isSvgMode);\r\n\r\n\t\tif (dom) {\r\n\t\t\t// move children into the replacement node\r\n\t\t\twhile (dom.firstChild) out.appendChild(dom.firstChild);\r\n\r\n\t\t\t// if the previous Element was mounted into the DOM, replace it inline\r\n\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\r\n\r\n\t\t\t// recycle the old element (skips non-Element node types)\r\n\t\t\trecollectNodeTree(dom, true);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tlet fc = out.firstChild,\r\n\t\tprops = out[ATTR_KEY],\r\n\t\tvchildren = vnode.children;\r\n\r\n\tif (props==null) {\r\n\t\tprops = out[ATTR_KEY] = {};\r\n\t\tfor (let a=out.attributes, i=a.length; i--; ) props[a[i].name] = a[i].value;\r\n\t}\r\n\r\n\t// Optimization: fast-path for elements containing a single TextNode:\r\n\tif (!hydrating && vchildren && vchildren.length===1 && typeof vchildren[0]==='string' && fc!=null && fc.splitText!==undefined && fc.nextSibling==null) {\r\n\t\tif (fc.nodeValue!=vchildren[0]) {\r\n\t\t\tfc.nodeValue = vchildren[0];\r\n\t\t}\r\n\t}\r\n\t// otherwise, if there are existing or new children, diff them:\r\n\telse if (vchildren && vchildren.length || fc!=null) {\r\n\t\tinnerDiffNode(out, vchildren, context, mountAll, hydrating || props.dangerouslySetInnerHTML!=null);\r\n\t}\r\n\r\n\r\n\t// Apply attributes/props from VNode to the DOM Element:\r\n\tdiffAttributes(out, vnode.attributes, props);\r\n\r\n\r\n\t// restore previous SVG mode: (in case we're exiting an SVG namespace)\r\n\tisSvgMode = prevSvgMode;\r\n\r\n\treturn out;\r\n}\r\n\r\n\r\n/** Apply child and attribute changes between a VNode and a DOM Node to the DOM.\r\n *\t@param {Element} dom\t\t\tElement whose children should be compared & mutated\r\n *\t@param {Array} vchildren\t\tArray of VNodes to compare to `dom.childNodes`\r\n *\t@param {Object} context\t\t\tImplicitly descendant context object (from most recent `getChildContext()`)\r\n *\t@param {Boolean} mountAll\r\n *\t@param {Boolean} isHydrating\tIf `true`, consumes externally created elements similar to hydration\r\n */\r\nfunction innerDiffNode(dom, vchildren, context, mountAll, isHydrating) {\r\n\tlet originalChildren = dom.childNodes,\r\n\t\tchildren = [],\r\n\t\tkeyed = {},\r\n\t\tkeyedLen = 0,\r\n\t\tmin = 0,\r\n\t\tlen = originalChildren.length,\r\n\t\tchildrenLen = 0,\r\n\t\tvlen = vchildren ? vchildren.length : 0,\r\n\t\tj, c, f, vchild, child;\r\n\r\n\t// Build up a map of keyed children and an Array of unkeyed children:\r\n\tif (len!==0) {\r\n\t\tfor (let i=0; i 2; ) {\r\n\t\tstack.push(arguments[i]);\r\n\t}\r\n\tif (attributes && attributes.children!=null) {\r\n\t\tif (!stack.length) stack.push(attributes.children);\r\n\t\tdelete attributes.children;\r\n\t}\r\n\twhile (stack.length) {\r\n\t\tif ((child = stack.pop()) && child.pop!==undefined) {\r\n\t\t\tfor (i=child.length; i--; ) stack.push(child[i]);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tif (typeof child==='boolean') child = null;\r\n\r\n\t\t\tif ((simple = typeof nodeName!=='function')) {\r\n\t\t\t\tif (child==null) child = '';\r\n\t\t\t\telse if (typeof child==='number') child = String(child);\r\n\t\t\t\telse if (typeof child!=='string') simple = false;\r\n\t\t\t}\r\n\r\n\t\t\tif (simple && lastSimple) {\r\n\t\t\t\tchildren[children.length-1] += child;\r\n\t\t\t}\r\n\t\t\telse if (children===EMPTY_CHILDREN) {\r\n\t\t\t\tchildren = [child];\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tchildren.push(child);\r\n\t\t\t}\r\n\r\n\t\t\tlastSimple = simple;\r\n\t\t}\r\n\t}\r\n\r\n\tlet p = new VNode();\r\n\tp.nodeName = nodeName;\r\n\tp.children = children;\r\n\tp.attributes = attributes==null ? undefined : attributes;\r\n\tp.key = attributes==null ? undefined : attributes.key;\r\n\r\n\t// if a \"vnode hook\" is defined, pass every created VNode to it\r\n\tif (options.vnode!==undefined) options.vnode(p);\r\n\r\n\treturn p;\r\n}","/**\r\n * @license\r\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\r\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\r\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\r\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\r\n * Code distributed by Google as part of the polymer project is also\r\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\r\n */\r\n\r\n/**\r\n * This shim allows elements written in, or compiled to, ES5 to work on native\r\n * implementations of Custom Elements v1. It sets new.target to the value of\r\n * this.constructor so that the native HTMLElement constructor can access the\r\n * current under-construction element's definition.\r\n */\r\n(function() {\r\n if (\r\n // No Reflect, no classes, no need for shim because native custom elements\r\n // require ES2015 classes or Reflect.\r\n window.Reflect === undefined ||\r\n window.customElements === undefined ||\r\n // The webcomponentsjs custom elements polyfill doesn't require\r\n // ES2015-compatible construction (`super()` or `Reflect.construct`).\r\n window.customElements.hasOwnProperty('polyfillWrapFlushCallback')\r\n ) {\r\n return;\r\n }\r\n const BuiltInHTMLElement = HTMLElement;\r\n window.HTMLElement = function HTMLElement() {\r\n return Reflect.construct(BuiltInHTMLElement, [], this.constructor);\r\n };\r\n HTMLElement.prototype = BuiltInHTMLElement.prototype;\r\n HTMLElement.prototype.constructor = HTMLElement;\r\n Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement);\r\n })();\r\n\r\n\r\n\r\nexport function cssToDom(css) {\r\n const node = document.createElement('style')\r\n node.innerText = css\r\n return node\r\n}\r\n\r\n\r\nexport function npn(str) {\r\n return str.replace(/-(\\w)/g, function ($, $1) {\r\n return $1.toUpperCase();\r\n });\r\n}\r\n\r\nexport function extend(obj, props) {\r\n\tfor (let i in props) obj[i] = props[i];\r\n\treturn obj;\r\n}\r\n\r\n/** Invoke or update a ref, depending on whether it is a function or object ref.\r\n * @param {object|function} [ref=null]\r\n * @param {any} [value]\r\n */\r\nexport function applyRef(ref, value) {\r\n\tif (ref!=null) {\r\n\t\tif (typeof ref=='function') ref(value);\r\n\t\telse ref.current = value;\r\n\t}\r\n}\r\n\r\n/**\r\n * Call a function asynchronously, as soon as possible. Makes\r\n * use of HTML Promise to schedule the callback if available,\r\n * otherwise falling back to `setTimeout` (mainly for IE<11).\r\n * @type {(callback: function) => void}\r\n */\r\nexport const defer = typeof Promise=='function' ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout;\r\n\r\nexport function isArray(obj){\r\n return Object.prototype.toString.call(obj) === '[object Array]'\r\n}\r\n\r\nexport function nProps(props){\r\n if(!props || isArray(props)) return {}\r\n const result = {}\r\n Object.keys(props).forEach(key =>{\r\n result[key] = props[key].value \r\n })\r\n return result\r\n}\r\n","// render modes\r\n\r\nexport const NO_RENDER = 0;\r\nexport const SYNC_RENDER = 1;\r\nexport const FORCE_RENDER = 2;\r\nexport const ASYNC_RENDER = 3;\r\n\r\n\r\nexport const ATTR_KEY = '__preactattr_';\r\n\r\n// DOM properties that should NOT have \"px\" added when numeric\r\nexport const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i;\r\n\r\n","import { extend } from '../util';\r\n\r\n\r\n/**\r\n * Check if two nodes are equivalent.\r\n *\r\n * @param {Node} node\t\t\tDOM Node to compare\r\n * @param {VNode} vnode\t\t\tVirtual DOM node to compare\r\n * @param {boolean} [hydrating=false]\tIf true, ignores component constructors when comparing.\r\n * @private\r\n */\r\nexport function isSameNodeType(node, vnode, hydrating) {\r\n\tif (typeof vnode==='string' || typeof vnode==='number') {\r\n\t\treturn node.splitText!==undefined;\r\n\t}\r\n\tif (typeof vnode.nodeName==='string') {\r\n\t\treturn !node._componentConstructor && isNamedNode(node, vnode.nodeName);\r\n\t}\r\n\treturn hydrating || node._componentConstructor===vnode.nodeName;\r\n}\r\n\r\n\r\n/**\r\n * Check if an Element has a given nodeName, case-insensitively.\r\n *\r\n * @param {Element} node\tA DOM Element to inspect the name of.\r\n * @param {String} nodeName\tUnnormalized name to compare against.\r\n */\r\nexport function isNamedNode(node, nodeName) {\r\n\treturn node.normalizedNodeName===nodeName || node.nodeName.toLowerCase()===nodeName.toLowerCase();\r\n}\r\n\r\n\r\n/**\r\n * Reconstruct Component-style `props` from a VNode.\r\n * Ensures default/fallback values from `defaultProps`:\r\n * Own-properties of `defaultProps` not present in `vnode.attributes` are added.\r\n *\r\n * @param {VNode} vnode\r\n * @returns {Object} props\r\n */\r\nexport function getNodeProps(vnode) {\r\n\tlet props = extend({}, vnode.attributes);\r\n\tprops.children = vnode.children;\r\n\r\n\tlet defaultProps = vnode.nodeName.defaultProps;\r\n\tif (defaultProps!==undefined) {\r\n\t\tfor (let i in defaultProps) {\r\n\t\t\tif (props[i]===undefined) {\r\n\t\t\t\tprops[i] = defaultProps[i];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn props;\r\n}\r\n","import { IS_NON_DIMENSIONAL } from '../constants';\r\nimport { applyRef } from '../util';\r\nimport options from '../options';\r\nimport { npn } from '../util'\r\n\r\n/**\r\n * A DOM event listener\r\n * @typedef {(e: Event) => void} EventListner\r\n */\r\n\r\n/**\r\n * A mapping of event types to event listeners\r\n * @typedef {Object.} EventListenerMap\r\n */\r\n\r\n/**\r\n * Properties Preact adds to elements it creates\r\n * @typedef PreactElementExtensions\r\n * @property {string} [normalizedNodeName] A normalized node name to use in diffing\r\n * @property {EventListenerMap} [_listeners] A map of event listeners added by components to this DOM node\r\n * @property {import('../component').Component} [_component] The component that rendered this DOM node\r\n * @property {function} [_componentConstructor] The constructor of the component that rendered this DOM node\r\n */\r\n\r\n/**\r\n * A DOM element that has been extended with Preact properties\r\n * @typedef {Element & ElementCSSInlineStyle & PreactElementExtensions} PreactElement\r\n */\r\n\r\n/**\r\n * Create an element with the given nodeName.\r\n * @param {string} nodeName The DOM node to create\r\n * @param {boolean} [isSvg=false] If `true`, creates an element within the SVG\r\n * namespace.\r\n * @returns {PreactElement} The created DOM node\r\n */\r\nexport function createNode(nodeName, isSvg) {\r\n\t/** @type {PreactElement} */\r\n\tlet node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName);\r\n\tnode.normalizedNodeName = nodeName;\r\n\treturn node;\r\n}\r\n\r\n\r\n/**\r\n * Remove a child node from its parent if attached.\r\n * @param {Node} node The node to remove\r\n */\r\nexport function removeNode(node) {\r\n\tlet parentNode = node.parentNode;\r\n\tif (parentNode) parentNode.removeChild(node);\r\n}\r\n\r\n\r\n/**\r\n * Set a named attribute on the given Node, with special behavior for some names\r\n * and event handlers. If `value` is `null`, the attribute/handler will be\r\n * removed.\r\n * @param {PreactElement} node An element to mutate\r\n * @param {string} name The name/key to set, such as an event or attribute name\r\n * @param {*} old The last value that was set for this name/node pair\r\n * @param {*} value An attribute value, such as a function to be used as an\r\n * event handler\r\n * @param {boolean} isSvg Are we currently diffing inside an svg?\r\n * @private\r\n */\r\nexport function setAccessor(node, name, old, value, isSvg) {\r\n\tif (name==='className') name = 'class';\r\n\r\n\r\n\tif (name==='key') {\r\n\t\t// ignore\r\n\t}\r\n\telse if (name==='ref') {\r\n\t\tapplyRef(old, null);\r\n\t\tapplyRef(value, node);\r\n\t}\r\n\telse if (name==='class' && !isSvg) {\r\n\t\tnode.className = value || '';\r\n\t}\r\n\telse if (name==='style') {\r\n\t\tif (!value || typeof value==='string' || typeof old==='string') {\r\n\t\t\tnode.style.cssText = value || '';\r\n\t\t}\r\n\t\tif (value && typeof value==='object') {\r\n\t\t\tif (typeof old!=='string') {\r\n\t\t\t\tfor (let i in old) if (!(i in value)) node.style[i] = '';\r\n\t\t\t}\r\n\t\t\tfor (let i in value) {\r\n\t\t\t\tnode.style[i] = typeof value[i]==='number' && IS_NON_DIMENSIONAL.test(i)===false ? (value[i]+'px') : value[i];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\telse if (name==='dangerouslySetInnerHTML') {\r\n\t\tif (value) node.innerHTML = value.__html || '';\r\n\t}\r\n\telse if (name[0]=='o' && name[1]=='n') {\r\n\t\tlet useCapture = name !== (name=name.replace(/Capture$/, ''));\r\n\t\tname = name.toLowerCase().substring(2);\r\n\t\tif (value) {\r\n\t\t\tif (!old) node.addEventListener(name, eventProxy, useCapture);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tnode.removeEventListener(name, eventProxy, useCapture);\r\n\t\t}\r\n\t\t(node._listeners || (node._listeners = {}))[name] = value;\r\n\t}\r\n\telse if (name!=='list' && name!=='type' && !isSvg && name in node) {\r\n\t\t// Attempt to set a DOM property to the given value.\r\n\t\t// IE & FF throw for certain property-value combinations.\r\n\t\ttry {\r\n\t\t\tnode[name] = value==null ? '' : value;\r\n\t\t} catch (e) { }\r\n\t\tif ((value==null || value===false) && name!='spellcheck') node.removeAttribute(name);\r\n\t}\r\n\telse {\r\n\t\tlet ns = isSvg && (name !== (name = name.replace(/^xlink:?/, '')));\r\n\t\t// spellcheck is treated differently than all other boolean values and\r\n\t\t// should not be removed when the value is `false`. See:\r\n\t\t// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-spellcheck\r\n\t\tif (value==null || value===false) {\r\n\t\t\tif (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());\r\n\t\t\telse node.removeAttribute(name);\r\n\t\t}\r\n\t\telse if (typeof value!=='function') {\r\n\t\t\tif (ns) {\r\n\t\t\t\tnode.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);\r\n\t\t\t\tnode.props[npn(name.toLowerCase())] = value;\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tnode.setAttribute(name, value);\r\n\t\t\t\tnode.props[npn(name)] = value;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\n/**\r\n * Proxy an event to hooked event handlers\r\n * @param {Event} e The event object from the browser\r\n * @private\r\n */\r\nfunction eventProxy(e) {\r\n\treturn this._listeners[e.type](options.event && options.event(e) || e);\r\n}","import { ATTR_KEY } from '../constants';\r\nimport { isSameNodeType, isNamedNode } from './index';\r\nimport { createNode, setAccessor } from '../dom/index';\r\nimport { npn } from '../util'\r\nimport { removeNode } from '../dom/index';\r\n\r\n/** Queue of components that have been mounted and are awaiting componentDidMount */\r\nexport const mounts = [];\r\n\r\n/** Diff recursion count, used to track the end of the diff cycle. */\r\nexport let diffLevel = 0;\r\n\r\n/** Global flag indicating if the diff is currently within an SVG */\r\nlet isSvgMode = false;\r\n\r\n/** Global flag indicating if the diff is performing hydration */\r\nlet hydrating = false;\r\n\r\n\r\n\r\n\r\n/** Apply differences in a given vnode (and it's deep children) to a real DOM Node.\r\n *\t@param {Element} [dom=null]\t\tA DOM node to mutate into the shape of the `vnode`\r\n *\t@param {VNode} vnode\t\t\tA VNode (with descendants forming a tree) representing the desired DOM structure\r\n *\t@returns {Element} dom\t\t\tThe created/mutated element\r\n *\t@private\r\n */\r\nexport function diff(dom, vnode, context, mountAll, parent, componentRoot) {\r\n\t// diffLevel having been 0 here indicates initial entry into the diff (not a subdiff)\r\n\tif (!diffLevel++) {\r\n\t\t// when first starting the diff, check if we're diffing an SVG or within an SVG\r\n\t\tisSvgMode = parent!=null && parent.ownerSVGElement!==undefined;\r\n\r\n\t\t// hydration is indicated by the existing element to be diffed not having a prop cache\r\n\t\thydrating = dom!=null && !(ATTR_KEY in dom);\r\n\t}\r\n\r\n\tlet ret = idiff(dom, vnode, context, mountAll, componentRoot);\r\n\r\n\t// append the element if its a new parent\r\n\tif (parent && ret.parentNode!==parent) parent.appendChild(ret);\r\n\r\n\t// diffLevel being reduced to 0 means we're exiting the diff\r\n\tif (!--diffLevel) {\r\n\t\thydrating = false;\r\n\t\t// invoke queued componentDidMount lifecycle methods\r\n\t\t\r\n\t}\r\n\r\n\treturn ret;\r\n}\r\n\r\n\r\n/** Internals of `diff()`, separated to allow bypassing diffLevel / mount flushing. */\r\nfunction idiff(dom, vnode, context, mountAll, componentRoot) {\r\n\tlet out = dom,\r\n\t\tprevSvgMode = isSvgMode;\r\n\r\n\t// empty values (null, undefined, booleans) render as empty Text nodes\r\n\tif (vnode==null || typeof vnode==='boolean') vnode = '';\r\n\r\n\r\n\t// Fast case: Strings & Numbers create/update Text nodes.\r\n\tif (typeof vnode==='string' || typeof vnode==='number') {\r\n\r\n\t\t// update if it's already a Text node:\r\n\t\tif (dom && dom.splitText!==undefined && dom.parentNode && (!dom._component || componentRoot)) {\r\n\t\t\t/* istanbul ignore if */ /* Browser quirk that can't be covered: https://github.com/developit/preact/commit/fd4f21f5c45dfd75151bd27b4c217d8003aa5eb9 */\r\n\t\t\tif (dom.nodeValue!=vnode) {\r\n\t\t\t\tdom.nodeValue = vnode;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse {\r\n\t\t\t// it wasn't a Text node: replace it with one and recycle the old Element\r\n\t\t\tout = document.createTextNode(vnode);\r\n\t\t\tif (dom) {\r\n\t\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\r\n\t\t\t\trecollectNodeTree(dom, true);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tout[ATTR_KEY] = true;\r\n\r\n\t\treturn out;\r\n\t}\r\n\r\n\r\n\t// If the VNode represents a Component, perform a component diff:\r\n\tlet vnodeName = vnode.nodeName;\r\n\t\r\n\r\n\t// Tracks entering and exiting SVG namespace when descending through the tree.\r\n\tisSvgMode = vnodeName==='svg' ? true : vnodeName==='foreignObject' ? false : isSvgMode;\r\n\r\n\r\n\t// If there's no existing element or it's the wrong type, create a new one:\r\n\tvnodeName = String(vnodeName);\r\n\tif (!dom || !isNamedNode(dom, vnodeName)) {\r\n\t\tout = createNode(vnodeName, isSvgMode);\r\n\r\n\t\tif (dom) {\r\n\t\t\t// move children into the replacement node\r\n\t\t\twhile (dom.firstChild) out.appendChild(dom.firstChild);\r\n\r\n\t\t\t// if the previous Element was mounted into the DOM, replace it inline\r\n\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\r\n\r\n\t\t\t// recycle the old element (skips non-Element node types)\r\n\t\t\trecollectNodeTree(dom, true);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tlet fc = out.firstChild,\r\n\t\tprops = out[ATTR_KEY],\r\n\t\tvchildren = vnode.children;\r\n\r\n\tif (props==null) {\r\n\t\tprops = out[ATTR_KEY] = {};\r\n\t\tfor (let a=out.attributes, i=a.length; i--; ) props[a[i].name] = a[i].value;\r\n\t}\r\n\r\n\t// Optimization: fast-path for elements containing a single TextNode:\r\n\tif (!hydrating && vchildren && vchildren.length===1 && typeof vchildren[0]==='string' && fc!=null && fc.splitText!==undefined && fc.nextSibling==null) {\r\n\t\tif (fc.nodeValue!=vchildren[0]) {\r\n\t\t\tfc.nodeValue = vchildren[0];\r\n\t\t}\r\n\t}\r\n\t// otherwise, if there are existing or new children, diff them:\r\n\telse if (vchildren && vchildren.length || fc!=null) {\r\n\t\tinnerDiffNode(out, vchildren, context, mountAll, hydrating || props.dangerouslySetInnerHTML!=null);\r\n\t}\r\n\r\n\r\n\t// Apply attributes/props from VNode to the DOM Element:\r\n\tdiffAttributes(out, vnode.attributes, props);\r\n\r\n\r\n\t// restore previous SVG mode: (in case we're exiting an SVG namespace)\r\n\tisSvgMode = prevSvgMode;\r\n\r\n\treturn out;\r\n}\r\n\r\n\r\n/** Apply child and attribute changes between a VNode and a DOM Node to the DOM.\r\n *\t@param {Element} dom\t\t\tElement whose children should be compared & mutated\r\n *\t@param {Array} vchildren\t\tArray of VNodes to compare to `dom.childNodes`\r\n *\t@param {Object} context\t\t\tImplicitly descendant context object (from most recent `getChildContext()`)\r\n *\t@param {Boolean} mountAll\r\n *\t@param {Boolean} isHydrating\tIf `true`, consumes externally created elements similar to hydration\r\n */\r\nfunction innerDiffNode(dom, vchildren, context, mountAll, isHydrating) {\r\n\tlet originalChildren = dom.childNodes,\r\n\t\tchildren = [],\r\n\t\tkeyed = {},\r\n\t\tkeyedLen = 0,\r\n\t\tmin = 0,\r\n\t\tlen = originalChildren.length,\r\n\t\tchildrenLen = 0,\r\n\t\tvlen = vchildren ? vchildren.length : 0,\r\n\t\tj, c, f, vchild, child;\r\n\r\n\t// Build up a map of keyed children and an Array of unkeyed children:\r\n\tif (len!==0) {\r\n\t\tfor (let i=0; i= Object.keys(pre).length){\n for (let key in pre) {\n const currentValue = current[key]\n if (currentValue === undefined) {\n current[key] = null\n } else {\n syncKeys(currentValue, pre[key])\n }\n }\n }\n } else if (rootCurrentType == ARRAYTYPE && rootPreType == ARRAYTYPE) {\n if (current.length >= pre.length) {\n pre.forEach((item, index) => {\n syncKeys(current[index], item)\n })\n }\n }\n}\n\nfunction _diff(current, pre, path, result) {\n if (current === pre) return\n const rootCurrentType = type(current)\n const rootPreType = type(pre)\n if (rootCurrentType == OBJECTTYPE) {\n if (rootPreType != OBJECTTYPE || Object.keys(current).length < Object.keys(pre).length) {\n setResult(result, path, current)\n } else {\n for (let key in current) {\n const currentValue = current[key]\n const preValue = pre[key]\n const currentType = type(currentValue)\n const preType = type(preValue)\n if (currentType != ARRAYTYPE && currentType != OBJECTTYPE) {\n if (currentValue != pre[key]) {\n setResult(result, (path == '' ? '' : path + \".\") + key, currentValue)\n }\n } else if (currentType == ARRAYTYPE) {\n if (preType != ARRAYTYPE) {\n setResult(result, (path == '' ? '' : path + \".\") + key, currentValue)\n } else {\n if (currentValue.length < preValue.length) {\n setResult(result, (path == '' ? '' : path + \".\") + key, currentValue)\n } else {\n currentValue.forEach((item, index) => {\n _diff(item, preValue[index], (path == '' ? '' : path + \".\") + key + '[' + index + ']', result)\n })\n }\n }\n } else if (currentType == OBJECTTYPE) {\n if (preType != OBJECTTYPE || Object.keys(currentValue).length < Object.keys(preValue).length) {\n setResult(result, (path == '' ? '' : path + \".\") + key, currentValue)\n } else {\n for (let subKey in currentValue) {\n _diff(currentValue[subKey], preValue[subKey], (path == '' ? '' : path + \".\") + key + '.' + subKey, result)\n }\n }\n }\n }\n }\n } else if (rootCurrentType == ARRAYTYPE) {\n if (rootPreType != ARRAYTYPE) {\n setResult(result, path, current)\n } else {\n if (current.length < pre.length) {\n setResult(result, path, current)\n } else {\n current.forEach((item, index) => {\n _diff(item, pre[index], path + '[' + index + ']', result)\n })\n }\n }\n } else {\n setResult(result, path, current)\n }\n}\n\nfunction setResult(result, k, v) {\n if (type(v) != FUNCTIONTYPE) {\n result[k] = v\n }\n}\n\nfunction type(obj) {\n return Object.prototype.toString.call(obj)\n}","\r\nimport { diff } from './vdom/diff'\r\nimport options from './options'\r\nimport jsonDiff from './json-diff'\r\n\r\nexport function render(vnode, parent, store) {\r\n\tparent = typeof parent === 'string' ? document.querySelector(parent) : parent\r\n\tif(store){\r\n\t\tstore.instances = []\r\n\t\textendStoreUpate(store)\r\n\t\toptions.store = store\r\n\t\tstore.originData = JSON.parse(JSON.stringify(store.data))\t\r\n\t}\r\n\tdiff(null, vnode, {}, false, parent, false)\r\n} \r\n\r\nfunction extendStoreUpate(store){\r\n\tstore.update = function(){\r\n\t\tlet diffResult = jsonDiff(this.data, this.originData)\r\n\t\tif (Object.keys(diffResult)[0] == '') {\r\n\t\t\tdiffResult = diffResult['']\r\n\t\t}\r\n\t\tconst updateAll = matchGlobalData(this.globalData, diffResult)\r\n\t\tif (Object.keys(diffResult).length > 0) {\r\n\t\t\tthis.instances.forEach(instance => {\r\n\t\t\t\tif(updateAll || this.updateAll || instance.constructor.updatePath && needUpdate(diffResult, instance.constructor.updatePath)){\r\n\t\t\t\t\tinstance.update()\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t\tthis.onChange && this.onChange(diffResult)\r\n\t\t\tfor (let key in diffResult) {\r\n\t\t\t\tupdateByPath(this.originData, key, typeof diffResult[key] === 'object' ? JSON.parse(JSON.stringify(diffResult[key])) : diffResult[key])\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunction matchGlobalData(globalData, diffResult) {\r\n\tif(!globalData) return false\r\n for (let keyA in diffResult) {\r\n if (globalData.indexOf(keyA) > -1) {\r\n return true\r\n }\r\n for (let i = 0, len = globalData.length; i < len; i++) {\r\n if (includePath(keyA, globalData[i])) {\r\n return true\r\n }\r\n }\r\n }\r\n return false\r\n}\r\n\r\nfunction needUpdate(diffResult, updatePath){\r\n for(let keyA in diffResult){\r\n if(updatePath[keyA]){\r\n return true\r\n }\r\n for(let keyB in updatePath){\r\n if(includePath(keyA, keyB)){\r\n return true\r\n }\r\n }\r\n }\r\n return false\r\n}\r\n\r\nfunction includePath(pathA, pathB){\r\n if(pathA.indexOf(pathB)===0){\r\n const next = pathA.substr(pathB.length, 1)\r\n if(next === '['||next === '.'){\r\n return true\r\n }\r\n }\r\n return false\r\n}\r\n\r\nfunction updateByPath(origin, path, value) {\r\n const arr = path.replace(/]/g, '').replace(/\\[/g, '.').split('.')\r\n let current = origin\r\n for (let i = 0, len = arr.length; i < len; i++) {\r\n if (i === len - 1) {\r\n current[arr[i]] = value\r\n } else {\r\n current = current[arr[i]]\r\n }\r\n }\r\n}\r\n","const OBJECTTYPE = '[object Object]'\r\n\r\nexport function define(name, ctor) {\r\n customElements.define(name, ctor)\r\n if (ctor.data) {\r\n ctor.updatePath = getUpdatePath(ctor.data)\r\n }\r\n}\r\n\r\nfunction getUpdatePath(data) {\r\n const result = {}\r\n dataToPath(data, result)\r\n return result\r\n}\r\n\r\nfunction dataToPath(data, result) {\r\n Object.keys(data).forEach(key => {\r\n result[key] = true\r\n const type = Object.prototype.toString.call(data[key])\r\n if (type === OBJECTTYPE) {\r\n _dataToPath(data[key], key, result)\r\n }\r\n })\r\n}\r\n\r\nfunction _dataToPath(data, path, result) {\r\n Object.keys(data).forEach(key => {\r\n result[path + '.' + key] = true\r\n const type = Object.prototype.toString.call(data[key])\r\n if (type === OBJECTTYPE) {\r\n _dataToPath(data[key], path + '.' + key, result)\r\n }\r\n })\r\n}","import { h, h as createElement } from './h';\r\nimport options from './options';\r\nimport WeElement from './we-element';\r\nimport { render } from './render';\r\nimport { define } from './define'\r\n\r\nconst instances = [];\r\n\r\noptions.root.Omi = {\r\n\th,\r\n\tcreateElement,\r\n\tWeElement,\r\n\trender,\r\n\toptions,\r\n\tinstances,\r\n\tdefine\r\n};\r\n\r\noptions.root.Omi.version = '4.0.0';\r\n\r\nexport default {\r\n\th,\r\n\tcreateElement,\r\n\tWeElement,\r\n\trender,\r\n\toptions,\r\n\tinstances,\r\n\tdefine\r\n};\r\n\r\nexport {\r\n\th,\r\n\tcreateElement,\r\n\tWeElement,\r\n\trender,\r\n\toptions,\r\n\tinstances,\r\n\tdefine\r\n};\r\n"],"names":["VNode","getGlobal","global","Math","Array","self","window","stack","EMPTY_CHILDREN","h","nodeName","attributes","children","lastSimple","child","simple","i","arguments","length","push","pop","undefined","String","p","key","options","vnode","Reflect","customElements","hasOwnProperty","BuiltInHTMLElement","HTMLElement","construct","constructor","prototype","setPrototypeOf","cssToDom","css","node","document","createElement","innerText","npn","str","replace","$","$1","toUpperCase","applyRef","ref","value","current","defer","Promise","resolve","then","bind","setTimeout","isArray","obj","Object","toString","call","nProps","props","result","keys","forEach","ATTR_KEY","IS_NON_DIMENSIONAL","isSameNodeType","hydrating","splitText","_componentConstructor","isNamedNode","normalizedNodeName","toLowerCase","createNode","isSvg","createElementNS","removeNode","parentNode","removeChild","setAccessor","name","old","className","style","cssText","test","innerHTML","__html","useCapture","substring","addEventListener","eventProxy","removeEventListener","_listeners","e","removeAttribute","ns","removeAttributeNS","setAttributeNS","setAttribute","type","event","diffLevel","isSvgMode","diff","dom","context","mountAll","parent","componentRoot","ownerSVGElement","ret","idiff","appendChild","out","prevSvgMode","_component","nodeValue","createTextNode","replaceChild","vnodeName","firstChild","fc","vchildren","a","nextSibling","dangerouslySetInnerHTML","innerDiffNode","isHydrating","originalChildren","childNodes","keyed","keyedLen","min","len","childrenLen","vlen","j","c","f","vchild","__key","trim","insertBefore","recollectNodeTree","unmountOnly","removeChildren","lastChild","next","previousSibling","diffAttributes","attrs","update","WeElement","data","connectedCallback","store","instances","install","shadowRoot","attachShadow","mode","host","render","installed","attributeChangedCallback","pre","disconnectedCallback","uninstall","beforeUpdate","afterUpdate","fire","dispatchEvent","CustomEvent","detail","ARRAYTYPE","OBJECTTYPE","FUNCTIONTYPE","syncKeys","rootCurrentType","rootPreType","currentValue","item","index","_diff","path","preValue","currentType","preType","subKey","setResult","k","v","querySelector","originData","JSON","parse","stringify","extendStoreUpate","diffResult","jsonDiff","updateAll","matchGlobalData","globalData","instance","updatePath","needUpdate","onChange","keyA","indexOf","includePath","keyB","pathA","pathB","substr","updateByPath","origin","arr","split","define","ctor","getUpdatePath","dataToPath","_dataToPath","root","Omi","version"],"mappings":";;;;;;;;AAAA;AACA,SAAgBA,KAAT,GAAiB;;ACDxB,SAASC,SAAT,GAAqB;KAChB,OAAOC,MAAP,KAAkB,QAAlB,IAA8B,CAACA,MAA/B,IAAyCA,OAAOC,IAAP,KAAgBA,IAAzD,IAAiED,OAAOE,KAAP,KAAiBA,KAAtF,EAA6F;MACxF,OAAOC,IAAP,KAAgB,WAApB,EAAiC;UACzBA,IAAP;GADD,MAEO,IAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;UAClCA,MAAP;GADM,MAEA,IAAI,OAAOJ,MAAP,KAAkB,WAAtB,EAAmC;UAClCA,MAAP;;SAEO,YAAU;UACV,IAAP;GADM,EAAP;;QAKMA,MAAP;;;;;;;AAOD,cAAe;;QAEP,IAFO;;OAIRD;;;;;;;;;;;;;;;;;;;;;;CAJP;;ICjBMM,QAAQ,EAAd;;AAEA,IAAMC,iBAAiB,EAAvB;;AAEA,SAAgBC,CAAT,CAAWC,QAAX,EAAqBC,UAArB,EAAiC;KACnCC,WAASJ,cAAb;KAA6BK,mBAA7B;KAAyCC,cAAzC;KAAgDC,eAAhD;KAAwDC,UAAxD;MACKA,IAAEC,UAAUC,MAAjB,EAAyBF,MAAM,CAA/B,GAAoC;QAC7BG,IAAN,CAAWF,UAAUD,CAAV,CAAX;;KAEGL,cAAcA,WAAWC,QAAX,IAAqB,IAAvC,EAA6C;MACxC,CAACL,MAAMW,MAAX,EAAmBX,MAAMY,IAAN,CAAWR,WAAWC,QAAtB;SACZD,WAAWC,QAAlB;;QAEML,MAAMW,MAAb,EAAqB;MAChB,CAACJ,QAAQP,MAAMa,GAAN,EAAT,KAAyBN,MAAMM,GAAN,KAAYC,SAAzC,EAAoD;QAC9CL,IAAEF,MAAMI,MAAb,EAAqBF,GAArB;UAAkCG,IAAN,CAAWL,MAAME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E,aAAT,CAAuBnE,IAAvB,EAA6B;MACrB7F,SAAS,EAAf;aACW6F,IAAX,EAAiB7F,MAAjB;SACOA,MAAP;;;AAGF,SAASiK,UAAT,CAAoBpE,IAApB,EAA0B7F,MAA1B,EAAkC;SACzBC,IAAP,CAAY4F,IAAZ,EAAkB3F,OAAlB,CAA0B,eAAO;WACxB3C,GAAP,IAAc,IAAd;QACMgF,OAAO5C,OAAO1B,SAAP,CAAiB2B,QAAjB,CAA0BC,IAA1B,CAA+BgG,KAAKtI,GAAL,CAA/B,CAAb;QACIgF,SAAS4E,YAAb,EAAyB;kBACXtB,KAAKtI,GAAL,CAAZ,EAAuBA,GAAvB,EAA4ByC,MAA5B;;GAJJ;;;AASF,SAASkK,WAAT,CAAqBrE,IAArB,EAA2B+B,IAA3B,EAAiC5H,MAAjC,EAAyC;SAChCC,IAAP,CAAY4F,IAAZ,EAAkB3F,OAAlB,CAA0B,eAAO;WACxB0H,OAAO,GAAP,GAAarK,GAApB,IAA2B,IAA3B;QACMgF,OAAO5C,OAAO1B,SAAP,CAAiB2B,QAAjB,CAA0BC,IAA1B,CAA+BgG,KAAKtI,GAAL,CAA/B,CAAb;QACIgF,SAAS4E,YAAb,EAAyB;kBACXtB,KAAKtI,GAAL,CAAZ,EAAuBqK,OAAO,GAAP,GAAarK,GAApC,EAAyCyC,MAAzC;;GAJJ;;;ICpBIgG,YAAY,EAAlB;;AAEAxI,QAAQ2M,IAAR,CAAaC,GAAb,GAAmB;KAAA;iBAAA;qBAAA;eAAA;iBAAA;qBAAA;;CAAnB;;AAUA5M,QAAQ2M,IAAR,CAAaC,GAAb,CAAiBC,OAAjB,GAA2B,OAA3B;;AAEA,UAAe;KAAA;iBAAA;qBAAA;eAAA;iBAAA;qBAAA;;CAAf;;;"} \ No newline at end of file diff --git a/dist/omi.js b/dist/omi.js index 62387d857..5a689158a 100644 --- a/dist/omi.js +++ b/dist/omi.js @@ -205,7 +205,7 @@ var update = !1; for (name in attrs) if ('object' == typeof attrs[name]) { dom.props[npn(name)] = attrs[name]; - update = !0; + 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(); } @@ -228,10 +228,128 @@ }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - function render(vnode, parent) { + function diff$1(current, pre) { + var result = {}; + syncKeys(current, pre); + _diff(current, pre, '', result); + return result; + } + function syncKeys(current, pre) { + if (current !== pre) { + var rootCurrentType = type(current); + var rootPreType = type(pre); + if ('[object Object]' == rootCurrentType && '[object Object]' == rootPreType) { + if (Object.keys(current).length >= Object.keys(pre).length) for (var key in pre) { + var currentValue = current[key]; + if (void 0 === currentValue) current[key] = null; else syncKeys(currentValue, pre[key]); + } + } else if ('[object Array]' == rootCurrentType && '[object Array]' == rootPreType) if (current.length >= pre.length) pre.forEach(function(item, index) { + syncKeys(current[index], item); + }); + } + } + function _diff(current, pre, path, result) { + if (current !== pre) { + var rootCurrentType = type(current); + var rootPreType = type(pre); + if ('[object Object]' == rootCurrentType) if ('[object Object]' != rootPreType || Object.keys(current).length < Object.keys(pre).length) setResult(result, path, current); else { + for (var key in current) !function(key) { + var currentValue = current[key]; + var preValue = pre[key]; + var currentType = type(currentValue); + var preType = type(preValue); + if ('[object Array]' != currentType && '[object Object]' != currentType) { + if (currentValue != pre[key]) setResult(result, ('' == path ? '' : path + ".") + key, currentValue); + } else if ('[object Array]' == currentType) if ('[object Array]' != preType) setResult(result, ('' == path ? '' : path + ".") + key, currentValue); else if (currentValue.length < preValue.length) setResult(result, ('' == path ? '' : path + ".") + key, currentValue); else currentValue.forEach(function(item, index) { + _diff(item, preValue[index], ('' == path ? '' : path + ".") + key + '[' + index + ']', result); + }); else if ('[object Object]' == currentType) if ('[object Object]' != preType || Object.keys(currentValue).length < Object.keys(preValue).length) setResult(result, ('' == path ? '' : path + ".") + key, currentValue); else for (var subKey in currentValue) _diff(currentValue[subKey], preValue[subKey], ('' == path ? '' : path + ".") + key + '.' + subKey, result); + }(key); + } else if ('[object Array]' == rootCurrentType) if ('[object Array]' != rootPreType) setResult(result, path, current); else if (current.length < pre.length) setResult(result, path, current); else current.forEach(function(item, index) { + _diff(item, pre[index], path + '[' + index + ']', result); + }); else setResult(result, path, current); + } + } + function setResult(result, k, v) { + if ('[object Function]' != type(v)) result[k] = v; + } + function type(obj) { + return Object.prototype.toString.call(obj); + } + function render(vnode, parent, store) { parent = 'string' == typeof parent ? document.querySelector(parent) : parent; + if (store) { + store.instances = []; + extendStoreUpate(store); + options.store = store; + store.originData = JSON.parse(JSON.stringify(store.data)); + } diff(null, vnode, {}, !1, parent, !1); } + function extendStoreUpate(store) { + store.update = function() { + var _this = this; + var diffResult = diff$1(this.data, this.originData); + if ('' == Object.keys(diffResult)[0]) diffResult = diffResult['']; + var updateAll = matchGlobalData(this.globalData, diffResult); + if (Object.keys(diffResult).length > 0) { + this.instances.forEach(function(instance) { + if (updateAll || _this.updateAll || instance.constructor.updatePath && needUpdate(diffResult, instance.constructor.updatePath)) instance.update(); + }); + this.onChange && this.onChange(diffResult); + for (var key in diffResult) updateByPath(this.originData, key, 'object' == typeof diffResult[key] ? JSON.parse(JSON.stringify(diffResult[key])) : diffResult[key]); + } + }; + } + function matchGlobalData(globalData, diffResult) { + if (!globalData) return !1; + for (var keyA in diffResult) { + if (globalData.indexOf(keyA) > -1) return !0; + for (var i = 0, len = globalData.length; i < len; i++) if (includePath(keyA, globalData[i])) return !0; + } + return !1; + } + function needUpdate(diffResult, updatePath) { + for (var keyA in diffResult) { + if (updatePath[keyA]) return !0; + for (var keyB in updatePath) if (includePath(keyA, keyB)) return !0; + } + return !1; + } + function includePath(pathA, pathB) { + if (0 === pathA.indexOf(pathB)) { + var next = pathA.substr(pathB.length, 1); + if ('[' === next || '.' === next) return !0; + } + return !1; + } + function updateByPath(origin, path, value) { + var arr = path.replace(/]/g, '').replace(/\[/g, '.').split('.'); + var current = origin; + for (var i = 0, len = arr.length; i < len; i++) if (i === len - 1) current[arr[i]] = value; else current = current[arr[i]]; + } + function define(name, ctor) { + customElements.define(name, ctor); + if (ctor.data) ctor.updatePath = getUpdatePath(ctor.data); + } + function getUpdatePath(data) { + var result = {}; + dataToPath(data, result); + return result; + } + function dataToPath(data, result) { + Object.keys(data).forEach(function(key) { + result[key] = !0; + var type = Object.prototype.toString.call(data[key]); + if ('[object Object]' === type) _dataToPath(data[key], key, result); + }); + } + function _dataToPath(data, path, result) { + Object.keys(data).forEach(function(key) { + result[path + '.' + key] = !0; + var type = Object.prototype.toString.call(data[key]); + if ('[object Object]' === type) _dataToPath(data[key], path + '.' + key, result); + }); + } var options = { store: null, root: function() { @@ -288,6 +406,8 @@ } _inherits(WeElement, _HTMLElement); WeElement.prototype.connectedCallback = function() { + this.store = options.store; + if (this.store) this.store.instances.push(this); this.install(); var shadowRoot = this.attachShadow({ mode: 'open' @@ -333,7 +453,8 @@ WeElement: WeElement, render: render, options: options, - instances: instances + instances: instances, + define: define }; options.root.Omi.version = '4.0.0'; var Omi = { @@ -342,7 +463,8 @@ WeElement: WeElement, render: render, options: options, - instances: instances + instances: instances, + define: define }; if ('undefined' != typeof module) module.exports = Omi; else self.Omi = Omi; }(); diff --git a/dist/omi.js.map b/dist/omi.js.map index 7ff50a235..0fa948dfc 100644 --- a/dist/omi.js.map +++ b/dist/omi.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/vnode.js","../src/h.js","../src/util.js","../src/vdom/index.js","../src/dom/index.js","../src/vdom/diff.js","../src/we-element.js","../src/options.js","../src/render.js","../src/omi.js"],"names":["VNode","nodeName","attributes","lastSimple","child","simple","i","children","EMPTY_CHILDREN","arguments","length","stack","push","pop","undefined","String","p","key","options","vnode","cssToDom","css","node","document","createElement","innerText","npn","str","replace","$","$1","toUpperCase","applyRef","ref","value","current","isArray","obj","Object","prototype","toString","call","nProps","props","result","keys","forEach","isSameNodeType","hydrating","_componentConstructor","removeNode","name","isSvg","className","old","style","cssText","IS_NON_DIMENSIONAL","test","innerHTML","__html","useCapture","substring","addEventListener","eventProxy","e","removeAttribute","ns","removeAttributeNS","toLowerCase","setAttribute","setAttributeNS","isSvgMode","dom","componentRoot","context","mountAll","ret","idiff","diffLevel","parent","out","splitText","parentNode","_component","nodeValue","createTextNode","replaceChild","recollectNodeTree","vnodeName","createNode","vchildren","firstChild","fc","a","nextSibling","innerDiffNode","dangerouslySetInnerHTML","prevSvgMode","min","len","childrenLen","vlen","j","keyedLen","originalChildren","keyed","vchild","_child","__key","trim","isHydrating","c","f","appendChild","unmountOnly","removeChildren","diffAttributes","setAccessor","attrs","update","_classCallCheck","instance","Constructor","TypeError","HTMLElement","store","root","global","Math","Array","self","window","this","Reflect","customElements","hasOwnProperty","BuiltInHTMLElement","construct","constructor","setPrototypeOf","Promise","resolve","then","bind","setTimeout","_listeners","WeElement","_this","data","connectedCallback","install","shadowRoot","attachShadow","disconnectedCallback","uninstall","diff","host","render","fire","afterUpdate","CustomEvent","detail","installed","beforeUpdate","Omi","h","version","module","exports"],"mappings":";;IACO,SAASA;ICOT,SAAWC,EAAAA,UAAUC;QAC3B,IAA6BC,YAAYC,OAAOC,QAAQC,GAApDC,WAASC;QACb,KAAKF,IAAEG,UAAUC,QAAQJ,MAAM,KAC9BK,MAAMC,KAAKH,UAAUH;QAEtB,IAAIJ,cAAmC,QAArBA,WAAWK,UAAgB;YAC5C,KAAKI,MAAMD,QAAQC,MAAMC,KAAKV,WAAWK;mBAClCL,WAAWK;;QAEnB,OAAOI,MAAMD,QACZ,KAAKN,QAAQO,MAAME,eAAsBC,MAAZV,MAAMS,KAClC,KAAKP,IAAEF,MAAMM,QAAQJ,OAAOK,MAAMC,KAAKR,MAAME,UAEzC;YACJ,IAAmB,oBAARF,OAAmBA,QAAQ;YAEtC,IAAKC,SAA2B,qBAAXJ,UACpB,IAAW,QAAPG,OAAaA,QAAQ,SACpB,IA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AAvB,KAAAwB,MAAAxB,KAAAyB,OAAAzB,KAAA1F,OAAA0F,KAAAgB;;;QAIGO,UAAKrH,UAAWwH,OAAKD,SAAYnH,MAAO0G;YACxChB,KAAK2B,cAAL,IAAAC,YAAA9G;gBAAA+G,QAAAb;;;4BAGJU,UAAAA;QAECZ,UAAA5G,UAAA4H,YAAA;4BAEDZ,eAAAA;4BAIAY,cAAAA;gCAIAC;;;iFAhDO,OAAMzH,OAAOE,KAAAwF,KAAA1F;;;QAKf,OAAAwG;MACJtB;IEdJ7C,IAAAA;IAEA9D,QAAA6G,KAAAsC;;uBCDiBC;;QAElBpJ,QAAQ6G;QACPuC,SADkBpJ;QAElBM,WAAAA;;IAGAN,QAAAA,KAAAA,IALkBqJ,UAAA;IAAnB,IAAAF;;QASAnJ,eAAAoJ;;QAEAR,QAAAA;QACCQ,SADcpJ;QAEdM,WAAAA;;IAGAN,IALc,sBAKdA,QALcsJ,OAAAC,UAAAJ,UAAAlC,KAAAkC,MAAAA","file":"omi.js","sourcesContent":["/** Virtual DOM Node */\r\nexport function VNode() {}\r\n","import { VNode } from './vnode';\r\nimport options from './options';\r\n\r\n\r\nconst stack = [];\r\n\r\nconst EMPTY_CHILDREN = [];\r\n\r\nexport function h(nodeName, attributes) {\r\n\tlet children=EMPTY_CHILDREN, lastSimple, child, simple, i;\r\n\tfor (i=arguments.length; i-- > 2; ) {\r\n\t\tstack.push(arguments[i]);\r\n\t}\r\n\tif (attributes && attributes.children!=null) {\r\n\t\tif (!stack.length) stack.push(attributes.children);\r\n\t\tdelete attributes.children;\r\n\t}\r\n\twhile (stack.length) {\r\n\t\tif ((child = stack.pop()) && child.pop!==undefined) {\r\n\t\t\tfor (i=child.length; i--; ) stack.push(child[i]);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tif (typeof child==='boolean') child = null;\r\n\r\n\t\t\tif ((simple = typeof nodeName!=='function')) {\r\n\t\t\t\tif (child==null) child = '';\r\n\t\t\t\telse if (typeof child==='number') child = String(child);\r\n\t\t\t\telse if (typeof child!=='string') simple = false;\r\n\t\t\t}\r\n\r\n\t\t\tif (simple && lastSimple) {\r\n\t\t\t\tchildren[children.length-1] += child;\r\n\t\t\t}\r\n\t\t\telse if (children===EMPTY_CHILDREN) {\r\n\t\t\t\tchildren = [child];\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tchildren.push(child);\r\n\t\t\t}\r\n\r\n\t\t\tlastSimple = simple;\r\n\t\t}\r\n\t}\r\n\r\n\tlet p = new VNode();\r\n\tp.nodeName = nodeName;\r\n\tp.children = children;\r\n\tp.attributes = attributes==null ? undefined : attributes;\r\n\tp.key = attributes==null ? undefined : attributes.key;\r\n\r\n\t// if a \"vnode hook\" is defined, pass every created VNode to it\r\n\tif (options.vnode!==undefined) options.vnode(p);\r\n\r\n\treturn p;\r\n}","/**\r\n * @license\r\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\r\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\r\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\r\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\r\n * Code distributed by Google as part of the polymer project is also\r\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\r\n */\r\n\r\n/**\r\n * This shim allows elements written in, or compiled to, ES5 to work on native\r\n * implementations of Custom Elements v1. It sets new.target to the value of\r\n * this.constructor so that the native HTMLElement constructor can access the\r\n * current under-construction element's definition.\r\n */\r\n(function() {\r\n if (\r\n // No Reflect, no classes, no need for shim because native custom elements\r\n // require ES2015 classes or Reflect.\r\n window.Reflect === undefined ||\r\n window.customElements === undefined ||\r\n // The webcomponentsjs custom elements polyfill doesn't require\r\n // ES2015-compatible construction (`super()` or `Reflect.construct`).\r\n window.customElements.hasOwnProperty('polyfillWrapFlushCallback')\r\n ) {\r\n return;\r\n }\r\n const BuiltInHTMLElement = HTMLElement;\r\n window.HTMLElement = function HTMLElement() {\r\n return Reflect.construct(BuiltInHTMLElement, [], this.constructor);\r\n };\r\n HTMLElement.prototype = BuiltInHTMLElement.prototype;\r\n HTMLElement.prototype.constructor = HTMLElement;\r\n Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement);\r\n })();\r\n\r\n\r\n\r\nexport function cssToDom(css) {\r\n const node = document.createElement('style')\r\n node.innerText = css\r\n return node\r\n}\r\n\r\n\r\nexport function npn(str) {\r\n return str.replace(/-(\\w)/g, function ($, $1) {\r\n return $1.toUpperCase();\r\n });\r\n}\r\n\r\nexport function extend(obj, props) {\r\n\tfor (let i in props) obj[i] = props[i];\r\n\treturn obj;\r\n}\r\n\r\n/** Invoke or update a ref, depending on whether it is a function or object ref.\r\n * @param {object|function} [ref=null]\r\n * @param {any} [value]\r\n */\r\nexport function applyRef(ref, value) {\r\n\tif (ref!=null) {\r\n\t\tif (typeof ref=='function') ref(value);\r\n\t\telse ref.current = value;\r\n\t}\r\n}\r\n\r\n/**\r\n * Call a function asynchronously, as soon as possible. Makes\r\n * use of HTML Promise to schedule the callback if available,\r\n * otherwise falling back to `setTimeout` (mainly for IE<11).\r\n * @type {(callback: function) => void}\r\n */\r\nexport const defer = typeof Promise=='function' ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout;\r\n\r\nexport function isArray(obj){\r\n return Object.prototype.toString.call(obj) === '[object Array]'\r\n}\r\n\r\nexport function nProps(props){\r\n if(!props || isArray(props)) return {}\r\n const result = {}\r\n Object.keys(props).forEach(key =>{\r\n result[key] = props[key].value \r\n })\r\n return result\r\n}\r\n","import { extend } from '../util';\r\n\r\n\r\n/**\r\n * Check if two nodes are equivalent.\r\n *\r\n * @param {Node} node\t\t\tDOM Node to compare\r\n * @param {VNode} vnode\t\t\tVirtual DOM node to compare\r\n * @param {boolean} [hydrating=false]\tIf true, ignores component constructors when comparing.\r\n * @private\r\n */\r\nexport function isSameNodeType(node, vnode, hydrating) {\r\n\tif (typeof vnode==='string' || typeof vnode==='number') {\r\n\t\treturn node.splitText!==undefined;\r\n\t}\r\n\tif (typeof vnode.nodeName==='string') {\r\n\t\treturn !node._componentConstructor && isNamedNode(node, vnode.nodeName);\r\n\t}\r\n\treturn hydrating || node._componentConstructor===vnode.nodeName;\r\n}\r\n\r\n\r\n/**\r\n * Check if an Element has a given nodeName, case-insensitively.\r\n *\r\n * @param {Element} node\tA DOM Element to inspect the name of.\r\n * @param {String} nodeName\tUnnormalized name to compare against.\r\n */\r\nexport function isNamedNode(node, nodeName) {\r\n\treturn node.normalizedNodeName===nodeName || node.nodeName.toLowerCase()===nodeName.toLowerCase();\r\n}\r\n\r\n\r\n/**\r\n * Reconstruct Component-style `props` from a VNode.\r\n * Ensures default/fallback values from `defaultProps`:\r\n * Own-properties of `defaultProps` not present in `vnode.attributes` are added.\r\n *\r\n * @param {VNode} vnode\r\n * @returns {Object} props\r\n */\r\nexport function getNodeProps(vnode) {\r\n\tlet props = extend({}, vnode.attributes);\r\n\tprops.children = vnode.children;\r\n\r\n\tlet defaultProps = vnode.nodeName.defaultProps;\r\n\tif (defaultProps!==undefined) {\r\n\t\tfor (let i in defaultProps) {\r\n\t\t\tif (props[i]===undefined) {\r\n\t\t\t\tprops[i] = defaultProps[i];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn props;\r\n}\r\n","import { IS_NON_DIMENSIONAL } from '../constants';\r\nimport { applyRef } from '../util';\r\nimport options from '../options';\r\nimport { npn } from '../util'\r\n\r\n/**\r\n * A DOM event listener\r\n * @typedef {(e: Event) => void} EventListner\r\n */\r\n\r\n/**\r\n * A mapping of event types to event listeners\r\n * @typedef {Object.} EventListenerMap\r\n */\r\n\r\n/**\r\n * Properties Preact adds to elements it creates\r\n * @typedef PreactElementExtensions\r\n * @property {string} [normalizedNodeName] A normalized node name to use in diffing\r\n * @property {EventListenerMap} [_listeners] A map of event listeners added by components to this DOM node\r\n * @property {import('../component').Component} [_component] The component that rendered this DOM node\r\n * @property {function} [_componentConstructor] The constructor of the component that rendered this DOM node\r\n */\r\n\r\n/**\r\n * A DOM element that has been extended with Preact properties\r\n * @typedef {Element & ElementCSSInlineStyle & PreactElementExtensions} PreactElement\r\n */\r\n\r\n/**\r\n * Create an element with the given nodeName.\r\n * @param {string} nodeName The DOM node to create\r\n * @param {boolean} [isSvg=false] If `true`, creates an element within the SVG\r\n * namespace.\r\n * @returns {PreactElement} The created DOM node\r\n */\r\nexport function createNode(nodeName, isSvg) {\r\n\t/** @type {PreactElement} */\r\n\tlet node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName);\r\n\tnode.normalizedNodeName = nodeName;\r\n\treturn node;\r\n}\r\n\r\n\r\n/**\r\n * Remove a child node from its parent if attached.\r\n * @param {Node} node The node to remove\r\n */\r\nexport function removeNode(node) {\r\n\tlet parentNode = node.parentNode;\r\n\tif (parentNode) parentNode.removeChild(node);\r\n}\r\n\r\n\r\n/**\r\n * Set a named attribute on the given Node, with special behavior for some names\r\n * and event handlers. If `value` is `null`, the attribute/handler will be\r\n * removed.\r\n * @param {PreactElement} node An element to mutate\r\n * @param {string} name The name/key to set, such as an event or attribute name\r\n * @param {*} old The last value that was set for this name/node pair\r\n * @param {*} value An attribute value, such as a function to be used as an\r\n * event handler\r\n * @param {boolean} isSvg Are we currently diffing inside an svg?\r\n * @private\r\n */\r\nexport function setAccessor(node, name, old, value, isSvg) {\r\n\tif (name==='className') name = 'class';\r\n\r\n\r\n\tif (name==='key') {\r\n\t\t// ignore\r\n\t}\r\n\telse if (name==='ref') {\r\n\t\tapplyRef(old, null);\r\n\t\tapplyRef(value, node);\r\n\t}\r\n\telse if (name==='class' && !isSvg) {\r\n\t\tnode.className = value || '';\r\n\t}\r\n\telse if (name==='style') {\r\n\t\tif (!value || typeof value==='string' || typeof old==='string') {\r\n\t\t\tnode.style.cssText = value || '';\r\n\t\t}\r\n\t\tif (value && typeof value==='object') {\r\n\t\t\tif (typeof old!=='string') {\r\n\t\t\t\tfor (let i in old) if (!(i in value)) node.style[i] = '';\r\n\t\t\t}\r\n\t\t\tfor (let i in value) {\r\n\t\t\t\tnode.style[i] = typeof value[i]==='number' && IS_NON_DIMENSIONAL.test(i)===false ? (value[i]+'px') : value[i];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\telse if (name==='dangerouslySetInnerHTML') {\r\n\t\tif (value) node.innerHTML = value.__html || '';\r\n\t}\r\n\telse if (name[0]=='o' && name[1]=='n') {\r\n\t\tlet useCapture = name !== (name=name.replace(/Capture$/, ''));\r\n\t\tname = name.toLowerCase().substring(2);\r\n\t\tif (value) {\r\n\t\t\tif (!old) node.addEventListener(name, eventProxy, useCapture);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tnode.removeEventListener(name, eventProxy, useCapture);\r\n\t\t}\r\n\t\t(node._listeners || (node._listeners = {}))[name] = value;\r\n\t}\r\n\telse if (name!=='list' && name!=='type' && !isSvg && name in node) {\r\n\t\t// Attempt to set a DOM property to the given value.\r\n\t\t// IE & FF throw for certain property-value combinations.\r\n\t\ttry {\r\n\t\t\tnode[name] = value==null ? '' : value;\r\n\t\t} catch (e) { }\r\n\t\tif ((value==null || value===false) && name!='spellcheck') node.removeAttribute(name);\r\n\t}\r\n\telse {\r\n\t\tlet ns = isSvg && (name !== (name = name.replace(/^xlink:?/, '')));\r\n\t\t// spellcheck is treated differently than all other boolean values and\r\n\t\t// should not be removed when the value is `false`. See:\r\n\t\t// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-spellcheck\r\n\t\tif (value==null || value===false) {\r\n\t\t\tif (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());\r\n\t\t\telse node.removeAttribute(name);\r\n\t\t}\r\n\t\telse if (typeof value!=='function') {\r\n\t\t\tif (ns) {\r\n\t\t\t\tnode.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);\r\n\t\t\t\tnode.props[npn(name.toLowerCase())] = value;\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tnode.setAttribute(name, value);\r\n\t\t\t\tnode.props[npn(name)] = value;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\n/**\r\n * Proxy an event to hooked event handlers\r\n * @param {Event} e The event object from the browser\r\n * @private\r\n */\r\nfunction eventProxy(e) {\r\n\treturn this._listeners[e.type](options.event && options.event(e) || e);\r\n}","import { ATTR_KEY } from '../constants';\r\nimport { isSameNodeType, isNamedNode } from './index';\r\nimport { createNode, setAccessor } from '../dom/index';\r\nimport { npn } from '../util'\r\nimport { removeNode } from '../dom/index';\r\n\r\n/** Queue of components that have been mounted and are awaiting componentDidMount */\r\nexport const mounts = [];\r\n\r\n/** Diff recursion count, used to track the end of the diff cycle. */\r\nexport let diffLevel = 0;\r\n\r\n/** Global flag indicating if the diff is currently within an SVG */\r\nlet isSvgMode = false;\r\n\r\n/** Global flag indicating if the diff is performing hydration */\r\nlet hydrating = false;\r\n\r\n\r\n\r\n\r\n/** Apply differences in a given vnode (and it's deep children) to a real DOM Node.\r\n *\t@param {Element} [dom=null]\t\tA DOM node to mutate into the shape of the `vnode`\r\n *\t@param {VNode} vnode\t\t\tA VNode (with descendants forming a tree) representing the desired DOM structure\r\n *\t@returns {Element} dom\t\t\tThe created/mutated element\r\n *\t@private\r\n */\r\nexport function diff(dom, vnode, context, mountAll, parent, componentRoot) {\r\n\t// diffLevel having been 0 here indicates initial entry into the diff (not a subdiff)\r\n\tif (!diffLevel++) {\r\n\t\t// when first starting the diff, check if we're diffing an SVG or within an SVG\r\n\t\tisSvgMode = parent!=null && parent.ownerSVGElement!==undefined;\r\n\r\n\t\t// hydration is indicated by the existing element to be diffed not having a prop cache\r\n\t\thydrating = dom!=null && !(ATTR_KEY in dom);\r\n\t}\r\n\r\n\tlet ret = idiff(dom, vnode, context, mountAll, componentRoot);\r\n\r\n\t// append the element if its a new parent\r\n\tif (parent && ret.parentNode!==parent) parent.appendChild(ret);\r\n\r\n\t// diffLevel being reduced to 0 means we're exiting the diff\r\n\tif (!--diffLevel) {\r\n\t\thydrating = false;\r\n\t\t// invoke queued componentDidMount lifecycle methods\r\n\t\t\r\n\t}\r\n\r\n\treturn ret;\r\n}\r\n\r\n\r\n/** Internals of `diff()`, separated to allow bypassing diffLevel / mount flushing. */\r\nfunction idiff(dom, vnode, context, mountAll, componentRoot) {\r\n\tlet out = dom,\r\n\t\tprevSvgMode = isSvgMode;\r\n\r\n\t// empty values (null, undefined, booleans) render as empty Text nodes\r\n\tif (vnode==null || typeof vnode==='boolean') vnode = '';\r\n\r\n\r\n\t// Fast case: Strings & Numbers create/update Text nodes.\r\n\tif (typeof vnode==='string' || typeof vnode==='number') {\r\n\r\n\t\t// update if it's already a Text node:\r\n\t\tif (dom && dom.splitText!==undefined && dom.parentNode && (!dom._component || componentRoot)) {\r\n\t\t\t/* istanbul ignore if */ /* Browser quirk that can't be covered: https://github.com/developit/preact/commit/fd4f21f5c45dfd75151bd27b4c217d8003aa5eb9 */\r\n\t\t\tif (dom.nodeValue!=vnode) {\r\n\t\t\t\tdom.nodeValue = vnode;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse {\r\n\t\t\t// it wasn't a Text node: replace it with one and recycle the old Element\r\n\t\t\tout = document.createTextNode(vnode);\r\n\t\t\tif (dom) {\r\n\t\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\r\n\t\t\t\trecollectNodeTree(dom, true);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tout[ATTR_KEY] = true;\r\n\r\n\t\treturn out;\r\n\t}\r\n\r\n\r\n\t// If the VNode represents a Component, perform a component diff:\r\n\tlet vnodeName = vnode.nodeName;\r\n\t\r\n\r\n\t// Tracks entering and exiting SVG namespace when descending through the tree.\r\n\tisSvgMode = vnodeName==='svg' ? true : vnodeName==='foreignObject' ? false : isSvgMode;\r\n\r\n\r\n\t// If there's no existing element or it's the wrong type, create a new one:\r\n\tvnodeName = String(vnodeName);\r\n\tif (!dom || !isNamedNode(dom, vnodeName)) {\r\n\t\tout = createNode(vnodeName, isSvgMode);\r\n\r\n\t\tif (dom) {\r\n\t\t\t// move children into the replacement node\r\n\t\t\twhile (dom.firstChild) out.appendChild(dom.firstChild);\r\n\r\n\t\t\t// if the previous Element was mounted into the DOM, replace it inline\r\n\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\r\n\r\n\t\t\t// recycle the old element (skips non-Element node types)\r\n\t\t\trecollectNodeTree(dom, true);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tlet fc = out.firstChild,\r\n\t\tprops = out[ATTR_KEY],\r\n\t\tvchildren = vnode.children;\r\n\r\n\tif (props==null) {\r\n\t\tprops = out[ATTR_KEY] = {};\r\n\t\tfor (let a=out.attributes, i=a.length; i--; ) props[a[i].name] = a[i].value;\r\n\t}\r\n\r\n\t// Optimization: fast-path for elements containing a single TextNode:\r\n\tif (!hydrating && vchildren && vchildren.length===1 && typeof vchildren[0]==='string' && fc!=null && fc.splitText!==undefined && fc.nextSibling==null) {\r\n\t\tif (fc.nodeValue!=vchildren[0]) {\r\n\t\t\tfc.nodeValue = vchildren[0];\r\n\t\t}\r\n\t}\r\n\t// otherwise, if there are existing or new children, diff them:\r\n\telse if (vchildren && vchildren.length || fc!=null) {\r\n\t\tinnerDiffNode(out, vchildren, context, mountAll, hydrating || props.dangerouslySetInnerHTML!=null);\r\n\t}\r\n\r\n\r\n\t// Apply attributes/props from VNode to the DOM Element:\r\n\tdiffAttributes(out, vnode.attributes, props);\r\n\r\n\r\n\t// restore previous SVG mode: (in case we're exiting an SVG namespace)\r\n\tisSvgMode = prevSvgMode;\r\n\r\n\treturn out;\r\n}\r\n\r\n\r\n/** Apply child and attribute changes between a VNode and a DOM Node to the DOM.\r\n *\t@param {Element} dom\t\t\tElement whose children should be compared & mutated\r\n *\t@param {Array} vchildren\t\tArray of VNodes to compare to `dom.childNodes`\r\n *\t@param {Object} context\t\t\tImplicitly descendant context object (from most recent `getChildContext()`)\r\n *\t@param {Boolean} mountAll\r\n *\t@param {Boolean} isHydrating\tIf `true`, consumes externally created elements similar to hydration\r\n */\r\nfunction innerDiffNode(dom, vchildren, context, mountAll, isHydrating) {\r\n\tlet originalChildren = dom.childNodes,\r\n\t\tchildren = [],\r\n\t\tkeyed = {},\r\n\t\tkeyedLen = 0,\r\n\t\tmin = 0,\r\n\t\tlen = originalChildren.length,\r\n\t\tchildrenLen = 0,\r\n\t\tvlen = vchildren ? vchildren.length : 0,\r\n\t\tj, c, f, vchild, child;\r\n\r\n\t// Build up a map of keyed children and an Array of unkeyed children:\r\n\tif (len!==0) {\r\n\t\tfor (let i=0; i 2; ) {\r\n\t\tstack.push(arguments[i]);\r\n\t}\r\n\tif (attributes && attributes.children!=null) {\r\n\t\tif (!stack.length) stack.push(attributes.children);\r\n\t\tdelete attributes.children;\r\n\t}\r\n\twhile (stack.length) {\r\n\t\tif ((child = stack.pop()) && child.pop!==undefined) {\r\n\t\t\tfor (i=child.length; i--; ) stack.push(child[i]);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tif (typeof child==='boolean') child = null;\r\n\r\n\t\t\tif ((simple = typeof nodeName!=='function')) {\r\n\t\t\t\tif (child==null) child = '';\r\n\t\t\t\telse if (typeof child==='number') child = String(child);\r\n\t\t\t\telse if (typeof child!=='string') simple = false;\r\n\t\t\t}\r\n\r\n\t\t\tif (simple && lastSimple) {\r\n\t\t\t\tchildren[children.length-1] += child;\r\n\t\t\t}\r\n\t\t\telse if (children===EMPTY_CHILDREN) {\r\n\t\t\t\tchildren = [child];\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tchildren.push(child);\r\n\t\t\t}\r\n\r\n\t\t\tlastSimple = simple;\r\n\t\t}\r\n\t}\r\n\r\n\tlet p = new VNode();\r\n\tp.nodeName = nodeName;\r\n\tp.children = children;\r\n\tp.attributes = attributes==null ? undefined : attributes;\r\n\tp.key = attributes==null ? undefined : attributes.key;\r\n\r\n\t// if a \"vnode hook\" is defined, pass every created VNode to it\r\n\tif (options.vnode!==undefined) options.vnode(p);\r\n\r\n\treturn p;\r\n}","/**\r\n * @license\r\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\r\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\r\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\r\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\r\n * Code distributed by Google as part of the polymer project is also\r\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\r\n */\r\n\r\n/**\r\n * This shim allows elements written in, or compiled to, ES5 to work on native\r\n * implementations of Custom Elements v1. It sets new.target to the value of\r\n * this.constructor so that the native HTMLElement constructor can access the\r\n * current under-construction element's definition.\r\n */\r\n(function() {\r\n if (\r\n // No Reflect, no classes, no need for shim because native custom elements\r\n // require ES2015 classes or Reflect.\r\n window.Reflect === undefined ||\r\n window.customElements === undefined ||\r\n // The webcomponentsjs custom elements polyfill doesn't require\r\n // ES2015-compatible construction (`super()` or `Reflect.construct`).\r\n window.customElements.hasOwnProperty('polyfillWrapFlushCallback')\r\n ) {\r\n return;\r\n }\r\n const BuiltInHTMLElement = HTMLElement;\r\n window.HTMLElement = function HTMLElement() {\r\n return Reflect.construct(BuiltInHTMLElement, [], this.constructor);\r\n };\r\n HTMLElement.prototype = BuiltInHTMLElement.prototype;\r\n HTMLElement.prototype.constructor = HTMLElement;\r\n Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement);\r\n })();\r\n\r\n\r\n\r\nexport function cssToDom(css) {\r\n const node = document.createElement('style')\r\n node.innerText = css\r\n return node\r\n}\r\n\r\n\r\nexport function npn(str) {\r\n return str.replace(/-(\\w)/g, function ($, $1) {\r\n return $1.toUpperCase();\r\n });\r\n}\r\n\r\nexport function extend(obj, props) {\r\n\tfor (let i in props) obj[i] = props[i];\r\n\treturn obj;\r\n}\r\n\r\n/** Invoke or update a ref, depending on whether it is a function or object ref.\r\n * @param {object|function} [ref=null]\r\n * @param {any} [value]\r\n */\r\nexport function applyRef(ref, value) {\r\n\tif (ref!=null) {\r\n\t\tif (typeof ref=='function') ref(value);\r\n\t\telse ref.current = value;\r\n\t}\r\n}\r\n\r\n/**\r\n * Call a function asynchronously, as soon as possible. Makes\r\n * use of HTML Promise to schedule the callback if available,\r\n * otherwise falling back to `setTimeout` (mainly for IE<11).\r\n * @type {(callback: function) => void}\r\n */\r\nexport const defer = typeof Promise=='function' ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout;\r\n\r\nexport function isArray(obj){\r\n return Object.prototype.toString.call(obj) === '[object Array]'\r\n}\r\n\r\nexport function nProps(props){\r\n if(!props || isArray(props)) return {}\r\n const result = {}\r\n Object.keys(props).forEach(key =>{\r\n result[key] = props[key].value \r\n })\r\n return result\r\n}\r\n","import { extend } from '../util';\r\n\r\n\r\n/**\r\n * Check if two nodes are equivalent.\r\n *\r\n * @param {Node} node\t\t\tDOM Node to compare\r\n * @param {VNode} vnode\t\t\tVirtual DOM node to compare\r\n * @param {boolean} [hydrating=false]\tIf true, ignores component constructors when comparing.\r\n * @private\r\n */\r\nexport function isSameNodeType(node, vnode, hydrating) {\r\n\tif (typeof vnode==='string' || typeof vnode==='number') {\r\n\t\treturn node.splitText!==undefined;\r\n\t}\r\n\tif (typeof vnode.nodeName==='string') {\r\n\t\treturn !node._componentConstructor && isNamedNode(node, vnode.nodeName);\r\n\t}\r\n\treturn hydrating || node._componentConstructor===vnode.nodeName;\r\n}\r\n\r\n\r\n/**\r\n * Check if an Element has a given nodeName, case-insensitively.\r\n *\r\n * @param {Element} node\tA DOM Element to inspect the name of.\r\n * @param {String} nodeName\tUnnormalized name to compare against.\r\n */\r\nexport function isNamedNode(node, nodeName) {\r\n\treturn node.normalizedNodeName===nodeName || node.nodeName.toLowerCase()===nodeName.toLowerCase();\r\n}\r\n\r\n\r\n/**\r\n * Reconstruct Component-style `props` from a VNode.\r\n * Ensures default/fallback values from `defaultProps`:\r\n * Own-properties of `defaultProps` not present in `vnode.attributes` are added.\r\n *\r\n * @param {VNode} vnode\r\n * @returns {Object} props\r\n */\r\nexport function getNodeProps(vnode) {\r\n\tlet props = extend({}, vnode.attributes);\r\n\tprops.children = vnode.children;\r\n\r\n\tlet defaultProps = vnode.nodeName.defaultProps;\r\n\tif (defaultProps!==undefined) {\r\n\t\tfor (let i in defaultProps) {\r\n\t\t\tif (props[i]===undefined) {\r\n\t\t\t\tprops[i] = defaultProps[i];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn props;\r\n}\r\n","import { IS_NON_DIMENSIONAL } from '../constants';\r\nimport { applyRef } from '../util';\r\nimport options from '../options';\r\nimport { npn } from '../util'\r\n\r\n/**\r\n * A DOM event listener\r\n * @typedef {(e: Event) => void} EventListner\r\n */\r\n\r\n/**\r\n * A mapping of event types to event listeners\r\n * @typedef {Object.} EventListenerMap\r\n */\r\n\r\n/**\r\n * Properties Preact adds to elements it creates\r\n * @typedef PreactElementExtensions\r\n * @property {string} [normalizedNodeName] A normalized node name to use in diffing\r\n * @property {EventListenerMap} [_listeners] A map of event listeners added by components to this DOM node\r\n * @property {import('../component').Component} [_component] The component that rendered this DOM node\r\n * @property {function} [_componentConstructor] The constructor of the component that rendered this DOM node\r\n */\r\n\r\n/**\r\n * A DOM element that has been extended with Preact properties\r\n * @typedef {Element & ElementCSSInlineStyle & PreactElementExtensions} PreactElement\r\n */\r\n\r\n/**\r\n * Create an element with the given nodeName.\r\n * @param {string} nodeName The DOM node to create\r\n * @param {boolean} [isSvg=false] If `true`, creates an element within the SVG\r\n * namespace.\r\n * @returns {PreactElement} The created DOM node\r\n */\r\nexport function createNode(nodeName, isSvg) {\r\n\t/** @type {PreactElement} */\r\n\tlet node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName);\r\n\tnode.normalizedNodeName = nodeName;\r\n\treturn node;\r\n}\r\n\r\n\r\n/**\r\n * Remove a child node from its parent if attached.\r\n * @param {Node} node The node to remove\r\n */\r\nexport function removeNode(node) {\r\n\tlet parentNode = node.parentNode;\r\n\tif (parentNode) parentNode.removeChild(node);\r\n}\r\n\r\n\r\n/**\r\n * Set a named attribute on the given Node, with special behavior for some names\r\n * and event handlers. If `value` is `null`, the attribute/handler will be\r\n * removed.\r\n * @param {PreactElement} node An element to mutate\r\n * @param {string} name The name/key to set, such as an event or attribute name\r\n * @param {*} old The last value that was set for this name/node pair\r\n * @param {*} value An attribute value, such as a function to be used as an\r\n * event handler\r\n * @param {boolean} isSvg Are we currently diffing inside an svg?\r\n * @private\r\n */\r\nexport function setAccessor(node, name, old, value, isSvg) {\r\n\tif (name==='className') name = 'class';\r\n\r\n\r\n\tif (name==='key') {\r\n\t\t// ignore\r\n\t}\r\n\telse if (name==='ref') {\r\n\t\tapplyRef(old, null);\r\n\t\tapplyRef(value, node);\r\n\t}\r\n\telse if (name==='class' && !isSvg) {\r\n\t\tnode.className = value || '';\r\n\t}\r\n\telse if (name==='style') {\r\n\t\tif (!value || typeof value==='string' || typeof old==='string') {\r\n\t\t\tnode.style.cssText = value || '';\r\n\t\t}\r\n\t\tif (value && typeof value==='object') {\r\n\t\t\tif (typeof old!=='string') {\r\n\t\t\t\tfor (let i in old) if (!(i in value)) node.style[i] = '';\r\n\t\t\t}\r\n\t\t\tfor (let i in value) {\r\n\t\t\t\tnode.style[i] = typeof value[i]==='number' && IS_NON_DIMENSIONAL.test(i)===false ? (value[i]+'px') : value[i];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\telse if (name==='dangerouslySetInnerHTML') {\r\n\t\tif (value) node.innerHTML = value.__html || '';\r\n\t}\r\n\telse if (name[0]=='o' && name[1]=='n') {\r\n\t\tlet useCapture = name !== (name=name.replace(/Capture$/, ''));\r\n\t\tname = name.toLowerCase().substring(2);\r\n\t\tif (value) {\r\n\t\t\tif (!old) node.addEventListener(name, eventProxy, useCapture);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tnode.removeEventListener(name, eventProxy, useCapture);\r\n\t\t}\r\n\t\t(node._listeners || (node._listeners = {}))[name] = value;\r\n\t}\r\n\telse if (name!=='list' && name!=='type' && !isSvg && name in node) {\r\n\t\t// Attempt to set a DOM property to the given value.\r\n\t\t// IE & FF throw for certain property-value combinations.\r\n\t\ttry {\r\n\t\t\tnode[name] = value==null ? '' : value;\r\n\t\t} catch (e) { }\r\n\t\tif ((value==null || value===false) && name!='spellcheck') node.removeAttribute(name);\r\n\t}\r\n\telse {\r\n\t\tlet ns = isSvg && (name !== (name = name.replace(/^xlink:?/, '')));\r\n\t\t// spellcheck is treated differently than all other boolean values and\r\n\t\t// should not be removed when the value is `false`. See:\r\n\t\t// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-spellcheck\r\n\t\tif (value==null || value===false) {\r\n\t\t\tif (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());\r\n\t\t\telse node.removeAttribute(name);\r\n\t\t}\r\n\t\telse if (typeof value!=='function') {\r\n\t\t\tif (ns) {\r\n\t\t\t\tnode.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);\r\n\t\t\t\tnode.props[npn(name.toLowerCase())] = value;\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tnode.setAttribute(name, value);\r\n\t\t\t\tnode.props[npn(name)] = value;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\n/**\r\n * Proxy an event to hooked event handlers\r\n * @param {Event} e The event object from the browser\r\n * @private\r\n */\r\nfunction eventProxy(e) {\r\n\treturn this._listeners[e.type](options.event && options.event(e) || e);\r\n}","import { ATTR_KEY } from '../constants';\r\nimport { isSameNodeType, isNamedNode } from './index';\r\nimport { createNode, setAccessor } from '../dom/index';\r\nimport { npn } from '../util'\r\nimport { removeNode } from '../dom/index';\r\n\r\n/** Queue of components that have been mounted and are awaiting componentDidMount */\r\nexport const mounts = [];\r\n\r\n/** Diff recursion count, used to track the end of the diff cycle. */\r\nexport let diffLevel = 0;\r\n\r\n/** Global flag indicating if the diff is currently within an SVG */\r\nlet isSvgMode = false;\r\n\r\n/** Global flag indicating if the diff is performing hydration */\r\nlet hydrating = false;\r\n\r\n\r\n\r\n\r\n/** Apply differences in a given vnode (and it's deep children) to a real DOM Node.\r\n *\t@param {Element} [dom=null]\t\tA DOM node to mutate into the shape of the `vnode`\r\n *\t@param {VNode} vnode\t\t\tA VNode (with descendants forming a tree) representing the desired DOM structure\r\n *\t@returns {Element} dom\t\t\tThe created/mutated element\r\n *\t@private\r\n */\r\nexport function diff(dom, vnode, context, mountAll, parent, componentRoot) {\r\n\t// diffLevel having been 0 here indicates initial entry into the diff (not a subdiff)\r\n\tif (!diffLevel++) {\r\n\t\t// when first starting the diff, check if we're diffing an SVG or within an SVG\r\n\t\tisSvgMode = parent!=null && parent.ownerSVGElement!==undefined;\r\n\r\n\t\t// hydration is indicated by the existing element to be diffed not having a prop cache\r\n\t\thydrating = dom!=null && !(ATTR_KEY in dom);\r\n\t}\r\n\r\n\tlet ret = idiff(dom, vnode, context, mountAll, componentRoot);\r\n\r\n\t// append the element if its a new parent\r\n\tif (parent && ret.parentNode!==parent) parent.appendChild(ret);\r\n\r\n\t// diffLevel being reduced to 0 means we're exiting the diff\r\n\tif (!--diffLevel) {\r\n\t\thydrating = false;\r\n\t\t// invoke queued componentDidMount lifecycle methods\r\n\t\t\r\n\t}\r\n\r\n\treturn ret;\r\n}\r\n\r\n\r\n/** Internals of `diff()`, separated to allow bypassing diffLevel / mount flushing. */\r\nfunction idiff(dom, vnode, context, mountAll, componentRoot) {\r\n\tlet out = dom,\r\n\t\tprevSvgMode = isSvgMode;\r\n\r\n\t// empty values (null, undefined, booleans) render as empty Text nodes\r\n\tif (vnode==null || typeof vnode==='boolean') vnode = '';\r\n\r\n\r\n\t// Fast case: Strings & Numbers create/update Text nodes.\r\n\tif (typeof vnode==='string' || typeof vnode==='number') {\r\n\r\n\t\t// update if it's already a Text node:\r\n\t\tif (dom && dom.splitText!==undefined && dom.parentNode && (!dom._component || componentRoot)) {\r\n\t\t\t/* istanbul ignore if */ /* Browser quirk that can't be covered: https://github.com/developit/preact/commit/fd4f21f5c45dfd75151bd27b4c217d8003aa5eb9 */\r\n\t\t\tif (dom.nodeValue!=vnode) {\r\n\t\t\t\tdom.nodeValue = vnode;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse {\r\n\t\t\t// it wasn't a Text node: replace it with one and recycle the old Element\r\n\t\t\tout = document.createTextNode(vnode);\r\n\t\t\tif (dom) {\r\n\t\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\r\n\t\t\t\trecollectNodeTree(dom, true);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tout[ATTR_KEY] = true;\r\n\r\n\t\treturn out;\r\n\t}\r\n\r\n\r\n\t// If the VNode represents a Component, perform a component diff:\r\n\tlet vnodeName = vnode.nodeName;\r\n\t\r\n\r\n\t// Tracks entering and exiting SVG namespace when descending through the tree.\r\n\tisSvgMode = vnodeName==='svg' ? true : vnodeName==='foreignObject' ? false : isSvgMode;\r\n\r\n\r\n\t// If there's no existing element or it's the wrong type, create a new one:\r\n\tvnodeName = String(vnodeName);\r\n\tif (!dom || !isNamedNode(dom, vnodeName)) {\r\n\t\tout = createNode(vnodeName, isSvgMode);\r\n\r\n\t\tif (dom) {\r\n\t\t\t// move children into the replacement node\r\n\t\t\twhile (dom.firstChild) out.appendChild(dom.firstChild);\r\n\r\n\t\t\t// if the previous Element was mounted into the DOM, replace it inline\r\n\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\r\n\r\n\t\t\t// recycle the old element (skips non-Element node types)\r\n\t\t\trecollectNodeTree(dom, true);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tlet fc = out.firstChild,\r\n\t\tprops = out[ATTR_KEY],\r\n\t\tvchildren = vnode.children;\r\n\r\n\tif (props==null) {\r\n\t\tprops = out[ATTR_KEY] = {};\r\n\t\tfor (let a=out.attributes, i=a.length; i--; ) props[a[i].name] = a[i].value;\r\n\t}\r\n\r\n\t// Optimization: fast-path for elements containing a single TextNode:\r\n\tif (!hydrating && vchildren && vchildren.length===1 && typeof vchildren[0]==='string' && fc!=null && fc.splitText!==undefined && fc.nextSibling==null) {\r\n\t\tif (fc.nodeValue!=vchildren[0]) {\r\n\t\t\tfc.nodeValue = vchildren[0];\r\n\t\t}\r\n\t}\r\n\t// otherwise, if there are existing or new children, diff them:\r\n\telse if (vchildren && vchildren.length || fc!=null) {\r\n\t\tinnerDiffNode(out, vchildren, context, mountAll, hydrating || props.dangerouslySetInnerHTML!=null);\r\n\t}\r\n\r\n\r\n\t// Apply attributes/props from VNode to the DOM Element:\r\n\tdiffAttributes(out, vnode.attributes, props);\r\n\r\n\r\n\t// restore previous SVG mode: (in case we're exiting an SVG namespace)\r\n\tisSvgMode = prevSvgMode;\r\n\r\n\treturn out;\r\n}\r\n\r\n\r\n/** Apply child and attribute changes between a VNode and a DOM Node to the DOM.\r\n *\t@param {Element} dom\t\t\tElement whose children should be compared & mutated\r\n *\t@param {Array} vchildren\t\tArray of VNodes to compare to `dom.childNodes`\r\n *\t@param {Object} context\t\t\tImplicitly descendant context object (from most recent `getChildContext()`)\r\n *\t@param {Boolean} mountAll\r\n *\t@param {Boolean} isHydrating\tIf `true`, consumes externally created elements similar to hydration\r\n */\r\nfunction innerDiffNode(dom, vchildren, context, mountAll, isHydrating) {\r\n\tlet originalChildren = dom.childNodes,\r\n\t\tchildren = [],\r\n\t\tkeyed = {},\r\n\t\tkeyedLen = 0,\r\n\t\tmin = 0,\r\n\t\tlen = originalChildren.length,\r\n\t\tchildrenLen = 0,\r\n\t\tvlen = vchildren ? vchildren.length : 0,\r\n\t\tj, c, f, vchild, child;\r\n\r\n\t// Build up a map of keyed children and an Array of unkeyed children:\r\n\tif (len!==0) {\r\n\t\tfor (let i=0; i= Object.keys(pre).length){\n for (let key in pre) {\n const currentValue = current[key]\n if (currentValue === undefined) {\n current[key] = null\n } else {\n syncKeys(currentValue, pre[key])\n }\n }\n }\n } else if (rootCurrentType == ARRAYTYPE && rootPreType == ARRAYTYPE) {\n if (current.length >= pre.length) {\n pre.forEach((item, index) => {\n syncKeys(current[index], item)\n })\n }\n }\n}\n\nfunction _diff(current, pre, path, result) {\n if (current === pre) return\n const rootCurrentType = type(current)\n const rootPreType = type(pre)\n if (rootCurrentType == OBJECTTYPE) {\n if (rootPreType != OBJECTTYPE || Object.keys(current).length < Object.keys(pre).length) {\n setResult(result, path, current)\n } else {\n for (let key in current) {\n const currentValue = current[key]\n const preValue = pre[key]\n const currentType = type(currentValue)\n const preType = type(preValue)\n if (currentType != ARRAYTYPE && currentType != OBJECTTYPE) {\n if (currentValue != pre[key]) {\n setResult(result, (path == '' ? '' : path + \".\") + key, currentValue)\n }\n } else if (currentType == ARRAYTYPE) {\n if (preType != ARRAYTYPE) {\n setResult(result, (path == '' ? '' : path + \".\") + key, currentValue)\n } else {\n if (currentValue.length < preValue.length) {\n setResult(result, (path == '' ? '' : path + \".\") + key, currentValue)\n } else {\n currentValue.forEach((item, index) => {\n _diff(item, preValue[index], (path == '' ? '' : path + \".\") + key + '[' + index + ']', result)\n })\n }\n }\n } else if (currentType == OBJECTTYPE) {\n if (preType != OBJECTTYPE || Object.keys(currentValue).length < Object.keys(preValue).length) {\n setResult(result, (path == '' ? '' : path + \".\") + key, currentValue)\n } else {\n for (let subKey in currentValue) {\n _diff(currentValue[subKey], preValue[subKey], (path == '' ? '' : path + \".\") + key + '.' + subKey, result)\n }\n }\n }\n }\n }\n } else if (rootCurrentType == ARRAYTYPE) {\n if (rootPreType != ARRAYTYPE) {\n setResult(result, path, current)\n } else {\n if (current.length < pre.length) {\n setResult(result, path, current)\n } else {\n current.forEach((item, index) => {\n _diff(item, pre[index], path + '[' + index + ']', result)\n })\n }\n }\n } else {\n setResult(result, path, current)\n }\n}\n\nfunction setResult(result, k, v) {\n if (type(v) != FUNCTIONTYPE) {\n result[k] = v\n }\n}\n\nfunction type(obj) {\n return Object.prototype.toString.call(obj)\n}","\r\nimport { diff } from './vdom/diff'\r\nimport options from './options'\r\nimport jsonDiff from './json-diff'\r\n\r\nexport function render(vnode, parent, store) {\r\n\tparent = typeof parent === 'string' ? document.querySelector(parent) : parent\r\n\tif(store){\r\n\t\tstore.instances = []\r\n\t\textendStoreUpate(store)\r\n\t\toptions.store = store\r\n\t\tstore.originData = JSON.parse(JSON.stringify(store.data))\t\r\n\t}\r\n\tdiff(null, vnode, {}, false, parent, false)\r\n} \r\n\r\nfunction extendStoreUpate(store){\r\n\tstore.update = function(){\r\n\t\tlet diffResult = jsonDiff(this.data, this.originData)\r\n\t\tif (Object.keys(diffResult)[0] == '') {\r\n\t\t\tdiffResult = diffResult['']\r\n\t\t}\r\n\t\tconst updateAll = matchGlobalData(this.globalData, diffResult)\r\n\t\tif (Object.keys(diffResult).length > 0) {\r\n\t\t\tthis.instances.forEach(instance => {\r\n\t\t\t\tif(updateAll || this.updateAll || instance.constructor.updatePath && needUpdate(diffResult, instance.constructor.updatePath)){\r\n\t\t\t\t\tinstance.update()\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t\tthis.onChange && this.onChange(diffResult)\r\n\t\t\tfor (let key in diffResult) {\r\n\t\t\t\tupdateByPath(this.originData, key, typeof diffResult[key] === 'object' ? JSON.parse(JSON.stringify(diffResult[key])) : diffResult[key])\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunction matchGlobalData(globalData, diffResult) {\r\n\tif(!globalData) return false\r\n for (let keyA in diffResult) {\r\n if (globalData.indexOf(keyA) > -1) {\r\n return true\r\n }\r\n for (let i = 0, len = globalData.length; i < len; i++) {\r\n if (includePath(keyA, globalData[i])) {\r\n return true\r\n }\r\n }\r\n }\r\n return false\r\n}\r\n\r\nfunction needUpdate(diffResult, updatePath){\r\n for(let keyA in diffResult){\r\n if(updatePath[keyA]){\r\n return true\r\n }\r\n for(let keyB in updatePath){\r\n if(includePath(keyA, keyB)){\r\n return true\r\n }\r\n }\r\n }\r\n return false\r\n}\r\n\r\nfunction includePath(pathA, pathB){\r\n if(pathA.indexOf(pathB)===0){\r\n const next = pathA.substr(pathB.length, 1)\r\n if(next === '['||next === '.'){\r\n return true\r\n }\r\n }\r\n return false\r\n}\r\n\r\nfunction updateByPath(origin, path, value) {\r\n const arr = path.replace(/]/g, '').replace(/\\[/g, '.').split('.')\r\n let current = origin\r\n for (let i = 0, len = arr.length; i < len; i++) {\r\n if (i === len - 1) {\r\n current[arr[i]] = value\r\n } else {\r\n current = current[arr[i]]\r\n }\r\n }\r\n}\r\n","const OBJECTTYPE = '[object Object]'\r\n\r\nexport function define(name, ctor) {\r\n customElements.define(name, ctor)\r\n if (ctor.data) {\r\n ctor.updatePath = getUpdatePath(ctor.data)\r\n }\r\n}\r\n\r\nfunction getUpdatePath(data) {\r\n const result = {}\r\n dataToPath(data, result)\r\n return result\r\n}\r\n\r\nfunction dataToPath(data, result) {\r\n Object.keys(data).forEach(key => {\r\n result[key] = true\r\n const type = Object.prototype.toString.call(data[key])\r\n if (type === OBJECTTYPE) {\r\n _dataToPath(data[key], key, result)\r\n }\r\n })\r\n}\r\n\r\nfunction _dataToPath(data, path, result) {\r\n Object.keys(data).forEach(key => {\r\n result[path + '.' + key] = true\r\n const type = Object.prototype.toString.call(data[key])\r\n if (type === OBJECTTYPE) {\r\n _dataToPath(data[key], path + '.' + key, result)\r\n }\r\n })\r\n}","function getGlobal() {\r\n\tif (typeof global !== 'object' || !global || global.Math !== Math || global.Array !== Array) {\r\n\t\tif (typeof self !== 'undefined') {\r\n\t\t\treturn self;\r\n\t\t} else if (typeof window !== 'undefined') {\r\n\t\t\treturn window;\r\n\t\t} else if (typeof global !== 'undefined') {\r\n\t\t\treturn global;\r\n\t\t}\r\n\t\treturn (function(){\r\n\t\t\treturn this;\r\n\t\t})();\r\n\t\t\r\n\t}\r\n\treturn global;\r\n}\r\n\r\n/** Global options\r\n *\t@public\r\n *\t@namespace options {Object}\r\n */\r\nexport default {\r\n\r\n\tstore: null,\r\n\t\r\n\troot: getGlobal()\r\n\t//componentChange(component, element) { },\r\n\t/** If `true`, `prop` changes trigger synchronous component updates.\r\n\t *\t@name syncComponentUpdates\r\n\t *\t@type Boolean\r\n\t *\t@default true\r\n\t */\r\n\t//syncComponentUpdates: true,\r\n\r\n\t/** Processes all created VNodes.\r\n\t *\t@param {VNode} vnode\tA newly-created VNode to normalize/process\r\n\t */\r\n\t//vnode(vnode) { }\r\n\r\n\t/** Hook invoked after a component is mounted. */\r\n\t//afterMount(component) { },\r\n\r\n\t/** Hook invoked after the DOM is updated with a component's latest render. */\r\n\t//afterUpdate(component) { }\r\n\r\n\t/** Hook invoked immediately before a component is unmounted. */\r\n\t// beforeUnmount(component) { }\r\n};\r\n","import { h, h as createElement } from './h';\r\nimport options from './options';\r\nimport WeElement from './we-element';\r\nimport { render } from './render';\r\nimport { define } from './define'\r\n\r\nconst instances = [];\r\n\r\noptions.root.Omi = {\r\n\th,\r\n\tcreateElement,\r\n\tWeElement,\r\n\trender,\r\n\toptions,\r\n\tinstances,\r\n\tdefine\r\n};\r\n\r\noptions.root.Omi.version = '4.0.0';\r\n\r\nexport default {\r\n\th,\r\n\tcreateElement,\r\n\tWeElement,\r\n\trender,\r\n\toptions,\r\n\tinstances,\r\n\tdefine\r\n};\r\n\r\nexport {\r\n\th,\r\n\tcreateElement,\r\n\tWeElement,\r\n\trender,\r\n\toptions,\r\n\tinstances,\r\n\tdefine\r\n};\r\n"]} \ No newline at end of file diff --git a/dist/omi.min.js b/dist/omi.min.js index 4c7ef7664..385184fee 100644 --- a/dist/omi.min.js +++ b/dist/omi.min.js @@ -1,2 +1,2 @@ -!function(){"use strict";function e(){}function t(t,n){var o,r,i,l,s=N;for(l=arguments.length;l-- >2;)T.push(arguments[l]);n&&null!=n.children&&(T.length||T.push(n.children),delete n.children);while(T.length)if((r=T.pop())&&void 0!==r.pop)for(l=r.length;l--;)T.push(r[l]);else"boolean"==typeof r&&(r=null),(i="function"!=typeof t)&&(null==r?r="":"number"==typeof r?r+="":"string"!=typeof r&&(i=!1)),i&&o?s[s.length-1]+=r:s===N?s=[r]:s.push(r),o=i;var u=new e;return u.nodeName=t,u.children=s,u.attributes=null==n?void 0:n,u.key=null==n?void 0:n.key,void 0!==E.vnode&&E.vnode(u),u}function n(e){var t=document.createElement("style");return t.innerText=e,t}function o(e){return e.replace(/-(\w)/g,function(e,t){return t.toUpperCase()})}function r(e,t){null!=e&&("function"==typeof e?e(t):e.current=t)}function i(e){return"[object Array]"===Object.prototype.toString.call(e)}function l(e){if(!e||i(e))return{};var t={};return Object.keys(e).forEach(function(n){t[n]=e[n].value}),t}function s(e,t,n){return"string"==typeof t||"number"==typeof t?void 0!==e.splitText:"string"==typeof t.nodeName?!e._componentConstructor&&u(e,t.nodeName):n||e._componentConstructor===t.nodeName}function u(e,t){return e.__n===t||e.nodeName.toLowerCase()===t.toLowerCase()}function a(e,t){var n=t?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e);return n.__n=e,n}function p(e){var t=e.parentNode;t&&t.removeChild(e)}function c(e,t,n,i,l){if("className"===t&&(t="class"),"key"===t);else if("ref"===t)r(n,null),r(i,e);else if("class"!==t||l)if("style"===t){if(i&&"string"!=typeof i&&"string"!=typeof n||(e.style.cssText=i||""),i&&"object"==typeof i){if("string"!=typeof n)for(var s in n)s in i||(e.style[s]="");for(var s in i)e.style[s]="number"==typeof i[s]&&!1===k.test(s)?i[s]+"px":i[s]}}else if("dangerouslySetInnerHTML"===t)i&&(e.innerHTML=i.__html||"");else if("o"==t[0]&&"n"==t[1]){var u=t!==(t=t.replace(/Capture$/,""));t=t.toLowerCase().substring(2),i?n||e.addEventListener(t,f,u):e.removeEventListener(t,f,u),(e.__l||(e.__l={}))[t]=i}else if("list"!==t&&"type"!==t&&!l&&t in e){try{e[t]=null==i?"":i}catch(e){}null!=i&&!1!==i||"spellcheck"==t||e.removeAttribute(t)}else{var a=l&&t!==(t=t.replace(/^xlink:?/,""));null==i||!1===i?a?e.removeAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase()):e.removeAttribute(t):"function"!=typeof i&&(a?(e.setAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase(),i),e.props[o(t.toLowerCase())]=i):(e.setAttribute(t,i),e.props[o(t)]=i))}else e.className=i||""}function f(e){return this.__l[e.type](E.event&&E.event(e)||e)}function d(e,t,n,o,r,i){L++||(x=null!=r&&void 0!==r.ownerSVGElement,O=null!=e&&!("__preactattr_"in e));var l=h(e,t,n,o,i);return r&&l.parentNode!==r&&r.appendChild(l),--L||(O=!1),l}function h(e,t,n,o,r){var i=e,l=x;if(null!=t&&"boolean"!=typeof t||(t=""),"string"==typeof t||"number"==typeof t)return e&&void 0!==e.splitText&&e.parentNode&&(!e._component||r)?e.nodeValue!=t&&(e.nodeValue=t):(i=document.createTextNode(t),e&&(e.parentNode&&e.parentNode.replaceChild(i,e),y(e,!0))),i.t=!0,i;var s=t.nodeName;if(x="svg"===s||"foreignObject"!==s&&x,s+="",(!e||!u(e,s))&&(i=a(s,x),e)){while(e.firstChild)i.appendChild(e.firstChild);e.parentNode&&e.parentNode.replaceChild(i,e),y(e,!0)}var p=i.firstChild,c=i.t,f=t.children;if(null==c){c=i.t={};for(var d=i.attributes,h=d.length;h--;)c[d[h].name]=d[h].value}return!O&&f&&1===f.length&&"string"==typeof f[0]&&null!=p&&void 0!==p.splitText&&null==p.nextSibling?p.nodeValue!=f[0]&&(p.nodeValue=f[0]):(f&&f.length||null!=p)&&v(i,f,n,o,O||null!=c.dangerouslySetInnerHTML),b(i,t.attributes,c),x=l,i}function v(e,t,n,o,r){var i,l,u,a,c,f=e.childNodes,d=[],v={},m=0,b=0,w=f.length,g=0,C=t?t.length:0;if(0!==w)for(var _=0;_2;)D.push(arguments[l]);n&&null!=n.children&&(D.length||D.push(n.children),delete n.children);while(D.length)if((r=D.pop())&&void 0!==r.pop)for(l=r.length;l--;)D.push(r[l]);else"boolean"==typeof r&&(r=null),(i="function"!=typeof t)&&(null==r?r="":"number"==typeof r?r+="":"string"!=typeof r&&(i=!1)),i&&o?a[a.length-1]+=r:a===J?a=[r]:a.push(r),o=i;var c=new e;return c.nodeName=t,c.children=a,c.attributes=null==n?void 0:n,c.key=null==n?void 0:n.key,void 0!==U.vnode&&U.vnode(c),c}function n(e){var t=document.createElement("style");return t.innerText=e,t}function o(e){return e.replace(/-(\w)/g,function(e,t){return t.toUpperCase()})}function r(e,t){null!=e&&("function"==typeof e?e(t):e.current=t)}function i(e){return"[object Array]"===Object.prototype.toString.call(e)}function l(e){if(!e||i(e))return{};var t={};return Object.keys(e).forEach(function(n){t[n]=e[n].value}),t}function a(e,t,n){return"string"==typeof t||"number"==typeof t?void 0!==e.splitText:"string"==typeof t.nodeName?!e._componentConstructor&&c(e,t.nodeName):n||e._componentConstructor===t.nodeName}function c(e,t){return e.__n===t||e.nodeName.toLowerCase()===t.toLowerCase()}function s(e,t){var n=t?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e);return n.__n=e,n}function u(e){var t=e.parentNode;t&&t.removeChild(e)}function f(e,t,n,i,l){if("className"===t&&(t="class"),"key"===t);else if("ref"===t)r(n,null),r(i,e);else if("class"!==t||l)if("style"===t){if(i&&"string"!=typeof i&&"string"!=typeof n||(e.style.cssText=i||""),i&&"object"==typeof i){if("string"!=typeof n)for(var a in n)a in i||(e.style[a]="");for(var a in i)e.style[a]="number"==typeof i[a]&&!1===R.test(a)?i[a]+"px":i[a]}}else if("dangerouslySetInnerHTML"===t)i&&(e.innerHTML=i.__html||"");else if("o"==t[0]&&"n"==t[1]){var c=t!==(t=t.replace(/Capture$/,""));t=t.toLowerCase().substring(2),i?n||e.addEventListener(t,p,c):e.removeEventListener(t,p,c),(e.__l||(e.__l={}))[t]=i}else if("list"!==t&&"type"!==t&&!l&&t in e){try{e[t]=null==i?"":i}catch(e){}null!=i&&!1!==i||"spellcheck"==t||e.removeAttribute(t)}else{var s=l&&t!==(t=t.replace(/^xlink:?/,""));null==i||!1===i?s?e.removeAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase()):e.removeAttribute(t):"function"!=typeof i&&(s?(e.setAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase(),i),e.props[o(t.toLowerCase())]=i):(e.setAttribute(t,i),e.props[o(t)]=i))}else e.className=i||""}function p(e){return this.__l[e.type](U.event&&U.event(e)||e)}function d(e,t,n,o,r,i){W++||(F=null!=r&&void 0!==r.ownerSVGElement,I=null!=e&&!("__preactattr_"in e));var l=h(e,t,n,o,i);return r&&l.parentNode!==r&&r.appendChild(l),--W||(I=!1),l}function h(e,t,n,o,r){var i=e,l=F;if(null!=t&&"boolean"!=typeof t||(t=""),"string"==typeof t||"number"==typeof t)return e&&void 0!==e.splitText&&e.parentNode&&(!e._component||r)?e.nodeValue!=t&&(e.nodeValue=t):(i=document.createTextNode(t),e&&(e.parentNode&&e.parentNode.replaceChild(i,e),y(e,!0))),i.t=!0,i;var a=t.nodeName;if(F="svg"===a||"foreignObject"!==a&&F,a+="",(!e||!c(e,a))&&(i=s(a,F),e)){while(e.firstChild)i.appendChild(e.firstChild);e.parentNode&&e.parentNode.replaceChild(i,e),y(e,!0)}var u=i.firstChild,f=i.t,p=t.children;if(null==f){f=i.t={};for(var d=i.attributes,h=d.length;h--;)f[d[h].name]=d[h].value}return!I&&p&&1===p.length&&"string"==typeof p[0]&&null!=u&&void 0!==u.splitText&&null==u.nextSibling?u.nodeValue!=p[0]&&(u.nodeValue=p[0]):(p&&p.length||null!=u)&&b(i,p,n,o,I||null!=f.dangerouslySetInnerHTML),g(i,t.attributes,f),F=l,i}function b(e,t,n,o,r){var i,l,c,s,f,p=e.childNodes,d=[],b={},v=0,g=0,m=p.length,j=0,w=t?t.length:0;if(0!==m)for(var O=0;O=Object.keys(t).length)for(var r in t){var i=e[r];void 0===i?e[r]=null:E(i,t[r])}}else"[object Array]"==n&&"[object Array]"==o&&e.length>=t.length&&t.forEach(function(t,n){E(e[n],t)})}}function C(e,t,n,o){if(e!==t){var r=_(e),i=_(t);if("[object Object]"==r)if("[object Object]"!=i||Object.keys(e).length0){this.instances.forEach(function(o){(n||e.updateAll||o.constructor.updatePath&&L(t,o.constructor.updatePath))&&o.update()}),this.onChange&&this.onChange(t);for(var o in t)A(this.originData,o,"object"==typeof t[o]?JSON.parse(JSON.stringify(t[o])):t[o])}}}function S(e,t){if(!e)return!1;for(var n in t){if(e.indexOf(n)>-1)return!0;for(var o=0,r=e.length;o 2; ) {\r\n\t\tstack.push(arguments[i]);\r\n\t}\r\n\tif (attributes && attributes.children!=null) {\r\n\t\tif (!stack.length) stack.push(attributes.children);\r\n\t\tdelete attributes.children;\r\n\t}\r\n\twhile (stack.length) {\r\n\t\tif ((child = stack.pop()) && child.pop!==undefined) {\r\n\t\t\tfor (i=child.length; i--; ) stack.push(child[i]);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tif (typeof child==='boolean') child = null;\r\n\r\n\t\t\tif ((simple = typeof nodeName!=='function')) {\r\n\t\t\t\tif (child==null) child = '';\r\n\t\t\t\telse if (typeof child==='number') child = String(child);\r\n\t\t\t\telse if (typeof child!=='string') simple = false;\r\n\t\t\t}\r\n\r\n\t\t\tif (simple && lastSimple) {\r\n\t\t\t\tchildren[children.length-1] += child;\r\n\t\t\t}\r\n\t\t\telse if (children===EMPTY_CHILDREN) {\r\n\t\t\t\tchildren = [child];\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tchildren.push(child);\r\n\t\t\t}\r\n\r\n\t\t\tlastSimple = simple;\r\n\t\t}\r\n\t}\r\n\r\n\tlet p = new VNode();\r\n\tp.nodeName = nodeName;\r\n\tp.children = children;\r\n\tp.attributes = attributes==null ? undefined : attributes;\r\n\tp.key = attributes==null ? undefined : attributes.key;\r\n\r\n\t// if a \"vnode hook\" is defined, pass every created VNode to it\r\n\tif (options.vnode!==undefined) options.vnode(p);\r\n\r\n\treturn p;\r\n}","/**\r\n * @license\r\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\r\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\r\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\r\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\r\n * Code distributed by Google as part of the polymer project is also\r\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\r\n */\r\n\r\n/**\r\n * This shim allows elements written in, or compiled to, ES5 to work on native\r\n * implementations of Custom Elements v1. It sets new.target to the value of\r\n * this.constructor so that the native HTMLElement constructor can access the\r\n * current under-construction element's definition.\r\n */\r\n(function() {\r\n if (\r\n // No Reflect, no classes, no need for shim because native custom elements\r\n // require ES2015 classes or Reflect.\r\n window.Reflect === undefined ||\r\n window.customElements === undefined ||\r\n // The webcomponentsjs custom elements polyfill doesn't require\r\n // ES2015-compatible construction (`super()` or `Reflect.construct`).\r\n window.customElements.hasOwnProperty('polyfillWrapFlushCallback')\r\n ) {\r\n return;\r\n }\r\n const BuiltInHTMLElement = HTMLElement;\r\n window.HTMLElement = function HTMLElement() {\r\n return Reflect.construct(BuiltInHTMLElement, [], this.constructor);\r\n };\r\n HTMLElement.prototype = BuiltInHTMLElement.prototype;\r\n HTMLElement.prototype.constructor = HTMLElement;\r\n Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement);\r\n })();\r\n\r\n\r\n\r\nexport function cssToDom(css) {\r\n const node = document.createElement('style')\r\n node.innerText = css\r\n return node\r\n}\r\n\r\n\r\nexport function npn(str) {\r\n return str.replace(/-(\\w)/g, function ($, $1) {\r\n return $1.toUpperCase();\r\n });\r\n}\r\n\r\nexport function extend(obj, props) {\r\n\tfor (let i in props) obj[i] = props[i];\r\n\treturn obj;\r\n}\r\n\r\n/** Invoke or update a ref, depending on whether it is a function or object ref.\r\n * @param {object|function} [ref=null]\r\n * @param {any} [value]\r\n */\r\nexport function applyRef(ref, value) {\r\n\tif (ref!=null) {\r\n\t\tif (typeof ref=='function') ref(value);\r\n\t\telse ref.current = value;\r\n\t}\r\n}\r\n\r\n/**\r\n * Call a function asynchronously, as soon as possible. Makes\r\n * use of HTML Promise to schedule the callback if available,\r\n * otherwise falling back to `setTimeout` (mainly for IE<11).\r\n * @type {(callback: function) => void}\r\n */\r\nexport const defer = typeof Promise=='function' ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout;\r\n\r\nexport function isArray(obj){\r\n return Object.prototype.toString.call(obj) === '[object Array]'\r\n}\r\n\r\nexport function nProps(props){\r\n if(!props || isArray(props)) return {}\r\n const result = {}\r\n Object.keys(props).forEach(key =>{\r\n result[key] = props[key].value \r\n })\r\n return result\r\n}\r\n","import { extend } from '../util';\r\n\r\n\r\n/**\r\n * Check if two nodes are equivalent.\r\n *\r\n * @param {Node} node\t\t\tDOM Node to compare\r\n * @param {VNode} vnode\t\t\tVirtual DOM node to compare\r\n * @param {boolean} [hydrating=false]\tIf true, ignores component constructors when comparing.\r\n * @private\r\n */\r\nexport function isSameNodeType(node, vnode, hydrating) {\r\n\tif (typeof vnode==='string' || typeof vnode==='number') {\r\n\t\treturn node.splitText!==undefined;\r\n\t}\r\n\tif (typeof vnode.nodeName==='string') {\r\n\t\treturn !node._componentConstructor && isNamedNode(node, vnode.nodeName);\r\n\t}\r\n\treturn hydrating || node._componentConstructor===vnode.nodeName;\r\n}\r\n\r\n\r\n/**\r\n * Check if an Element has a given nodeName, case-insensitively.\r\n *\r\n * @param {Element} node\tA DOM Element to inspect the name of.\r\n * @param {String} nodeName\tUnnormalized name to compare against.\r\n */\r\nexport function isNamedNode(node, nodeName) {\r\n\treturn node.normalizedNodeName===nodeName || node.nodeName.toLowerCase()===nodeName.toLowerCase();\r\n}\r\n\r\n\r\n/**\r\n * Reconstruct Component-style `props` from a VNode.\r\n * Ensures default/fallback values from `defaultProps`:\r\n * Own-properties of `defaultProps` not present in `vnode.attributes` are added.\r\n *\r\n * @param {VNode} vnode\r\n * @returns {Object} props\r\n */\r\nexport function getNodeProps(vnode) {\r\n\tlet props = extend({}, vnode.attributes);\r\n\tprops.children = vnode.children;\r\n\r\n\tlet defaultProps = vnode.nodeName.defaultProps;\r\n\tif (defaultProps!==undefined) {\r\n\t\tfor (let i in defaultProps) {\r\n\t\t\tif (props[i]===undefined) {\r\n\t\t\t\tprops[i] = defaultProps[i];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn props;\r\n}\r\n","import { IS_NON_DIMENSIONAL } from '../constants';\r\nimport { applyRef } from '../util';\r\nimport options from '../options';\r\nimport { npn } from '../util'\r\n\r\n/**\r\n * A DOM event listener\r\n * @typedef {(e: Event) => void} EventListner\r\n */\r\n\r\n/**\r\n * A mapping of event types to event listeners\r\n * @typedef {Object.} EventListenerMap\r\n */\r\n\r\n/**\r\n * Properties Preact adds to elements it creates\r\n * @typedef PreactElementExtensions\r\n * @property {string} [normalizedNodeName] A normalized node name to use in diffing\r\n * @property {EventListenerMap} [_listeners] A map of event listeners added by components to this DOM node\r\n * @property {import('../component').Component} [_component] The component that rendered this DOM node\r\n * @property {function} [_componentConstructor] The constructor of the component that rendered this DOM node\r\n */\r\n\r\n/**\r\n * A DOM element that has been extended with Preact properties\r\n * @typedef {Element & ElementCSSInlineStyle & PreactElementExtensions} PreactElement\r\n */\r\n\r\n/**\r\n * Create an element with the given nodeName.\r\n * @param {string} nodeName The DOM node to create\r\n * @param {boolean} [isSvg=false] If `true`, creates an element within the SVG\r\n * namespace.\r\n * @returns {PreactElement} The created DOM node\r\n */\r\nexport function createNode(nodeName, isSvg) {\r\n\t/** @type {PreactElement} */\r\n\tlet node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName);\r\n\tnode.normalizedNodeName = nodeName;\r\n\treturn node;\r\n}\r\n\r\n\r\n/**\r\n * Remove a child node from its parent if attached.\r\n * @param {Node} node The node to remove\r\n */\r\nexport function removeNode(node) {\r\n\tlet parentNode = node.parentNode;\r\n\tif (parentNode) parentNode.removeChild(node);\r\n}\r\n\r\n\r\n/**\r\n * Set a named attribute on the given Node, with special behavior for some names\r\n * and event handlers. If `value` is `null`, the attribute/handler will be\r\n * removed.\r\n * @param {PreactElement} node An element to mutate\r\n * @param {string} name The name/key to set, such as an event or attribute name\r\n * @param {*} old The last value that was set for this name/node pair\r\n * @param {*} value An attribute value, such as a function to be used as an\r\n * event handler\r\n * @param {boolean} isSvg Are we currently diffing inside an svg?\r\n * @private\r\n */\r\nexport function setAccessor(node, name, old, value, isSvg) {\r\n\tif (name==='className') name = 'class';\r\n\r\n\r\n\tif (name==='key') {\r\n\t\t// ignore\r\n\t}\r\n\telse if (name==='ref') {\r\n\t\tapplyRef(old, null);\r\n\t\tapplyRef(value, node);\r\n\t}\r\n\telse if (name==='class' && !isSvg) {\r\n\t\tnode.className = value || '';\r\n\t}\r\n\telse if (name==='style') {\r\n\t\tif (!value || typeof value==='string' || typeof old==='string') {\r\n\t\t\tnode.style.cssText = value || '';\r\n\t\t}\r\n\t\tif (value && typeof value==='object') {\r\n\t\t\tif (typeof old!=='string') {\r\n\t\t\t\tfor (let i in old) if (!(i in value)) node.style[i] = '';\r\n\t\t\t}\r\n\t\t\tfor (let i in value) {\r\n\t\t\t\tnode.style[i] = typeof value[i]==='number' && IS_NON_DIMENSIONAL.test(i)===false ? (value[i]+'px') : value[i];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\telse if (name==='dangerouslySetInnerHTML') {\r\n\t\tif (value) node.innerHTML = value.__html || '';\r\n\t}\r\n\telse if (name[0]=='o' && name[1]=='n') {\r\n\t\tlet useCapture = name !== (name=name.replace(/Capture$/, ''));\r\n\t\tname = name.toLowerCase().substring(2);\r\n\t\tif (value) {\r\n\t\t\tif (!old) node.addEventListener(name, eventProxy, useCapture);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tnode.removeEventListener(name, eventProxy, useCapture);\r\n\t\t}\r\n\t\t(node._listeners || (node._listeners = {}))[name] = value;\r\n\t}\r\n\telse if (name!=='list' && name!=='type' && !isSvg && name in node) {\r\n\t\t// Attempt to set a DOM property to the given value.\r\n\t\t// IE & FF throw for certain property-value combinations.\r\n\t\ttry {\r\n\t\t\tnode[name] = value==null ? '' : value;\r\n\t\t} catch (e) { }\r\n\t\tif ((value==null || value===false) && name!='spellcheck') node.removeAttribute(name);\r\n\t}\r\n\telse {\r\n\t\tlet ns = isSvg && (name !== (name = name.replace(/^xlink:?/, '')));\r\n\t\t// spellcheck is treated differently than all other boolean values and\r\n\t\t// should not be removed when the value is `false`. See:\r\n\t\t// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-spellcheck\r\n\t\tif (value==null || value===false) {\r\n\t\t\tif (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());\r\n\t\t\telse node.removeAttribute(name);\r\n\t\t}\r\n\t\telse if (typeof value!=='function') {\r\n\t\t\tif (ns) {\r\n\t\t\t\tnode.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);\r\n\t\t\t\tnode.props[npn(name.toLowerCase())] = value;\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tnode.setAttribute(name, value);\r\n\t\t\t\tnode.props[npn(name)] = value;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\n/**\r\n * Proxy an event to hooked event handlers\r\n * @param {Event} e The event object from the browser\r\n * @private\r\n */\r\nfunction eventProxy(e) {\r\n\treturn this._listeners[e.type](options.event && options.event(e) || e);\r\n}","import { ATTR_KEY } from '../constants';\r\nimport { isSameNodeType, isNamedNode } from './index';\r\nimport { createNode, setAccessor } from '../dom/index';\r\nimport { npn } from '../util'\r\nimport { removeNode } from '../dom/index';\r\n\r\n/** Queue of components that have been mounted and are awaiting componentDidMount */\r\nexport const mounts = [];\r\n\r\n/** Diff recursion count, used to track the end of the diff cycle. */\r\nexport let diffLevel = 0;\r\n\r\n/** Global flag indicating if the diff is currently within an SVG */\r\nlet isSvgMode = false;\r\n\r\n/** Global flag indicating if the diff is performing hydration */\r\nlet hydrating = false;\r\n\r\n\r\n\r\n\r\n/** Apply differences in a given vnode (and it's deep children) to a real DOM Node.\r\n *\t@param {Element} [dom=null]\t\tA DOM node to mutate into the shape of the `vnode`\r\n *\t@param {VNode} vnode\t\t\tA VNode (with descendants forming a tree) representing the desired DOM structure\r\n *\t@returns {Element} dom\t\t\tThe created/mutated element\r\n *\t@private\r\n */\r\nexport function diff(dom, vnode, context, mountAll, parent, componentRoot) {\r\n\t// diffLevel having been 0 here indicates initial entry into the diff (not a subdiff)\r\n\tif (!diffLevel++) {\r\n\t\t// when first starting the diff, check if we're diffing an SVG or within an SVG\r\n\t\tisSvgMode = parent!=null && parent.ownerSVGElement!==undefined;\r\n\r\n\t\t// hydration is indicated by the existing element to be diffed not having a prop cache\r\n\t\thydrating = dom!=null && !(ATTR_KEY in dom);\r\n\t}\r\n\r\n\tlet ret = idiff(dom, vnode, context, mountAll, componentRoot);\r\n\r\n\t// append the element if its a new parent\r\n\tif (parent && ret.parentNode!==parent) parent.appendChild(ret);\r\n\r\n\t// diffLevel being reduced to 0 means we're exiting the diff\r\n\tif (!--diffLevel) {\r\n\t\thydrating = false;\r\n\t\t// invoke queued componentDidMount lifecycle methods\r\n\t\t\r\n\t}\r\n\r\n\treturn ret;\r\n}\r\n\r\n\r\n/** Internals of `diff()`, separated to allow bypassing diffLevel / mount flushing. */\r\nfunction idiff(dom, vnode, context, mountAll, componentRoot) {\r\n\tlet out = dom,\r\n\t\tprevSvgMode = isSvgMode;\r\n\r\n\t// empty values (null, undefined, booleans) render as empty Text nodes\r\n\tif (vnode==null || typeof vnode==='boolean') vnode = '';\r\n\r\n\r\n\t// Fast case: Strings & Numbers create/update Text nodes.\r\n\tif (typeof vnode==='string' || typeof vnode==='number') {\r\n\r\n\t\t// update if it's already a Text node:\r\n\t\tif (dom && dom.splitText!==undefined && dom.parentNode && (!dom._component || componentRoot)) {\r\n\t\t\t/* istanbul ignore if */ /* Browser quirk that can't be covered: https://github.com/developit/preact/commit/fd4f21f5c45dfd75151bd27b4c217d8003aa5eb9 */\r\n\t\t\tif (dom.nodeValue!=vnode) {\r\n\t\t\t\tdom.nodeValue = vnode;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse {\r\n\t\t\t// it wasn't a Text node: replace it with one and recycle the old Element\r\n\t\t\tout = document.createTextNode(vnode);\r\n\t\t\tif (dom) {\r\n\t\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\r\n\t\t\t\trecollectNodeTree(dom, true);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tout[ATTR_KEY] = true;\r\n\r\n\t\treturn out;\r\n\t}\r\n\r\n\r\n\t// If the VNode represents a Component, perform a component diff:\r\n\tlet vnodeName = vnode.nodeName;\r\n\t\r\n\r\n\t// Tracks entering and exiting SVG namespace when descending through the tree.\r\n\tisSvgMode = vnodeName==='svg' ? true : vnodeName==='foreignObject' ? false : isSvgMode;\r\n\r\n\r\n\t// If there's no existing element or it's the wrong type, create a new one:\r\n\tvnodeName = String(vnodeName);\r\n\tif (!dom || !isNamedNode(dom, vnodeName)) {\r\n\t\tout = createNode(vnodeName, isSvgMode);\r\n\r\n\t\tif (dom) {\r\n\t\t\t// move children into the replacement node\r\n\t\t\twhile (dom.firstChild) out.appendChild(dom.firstChild);\r\n\r\n\t\t\t// if the previous Element was mounted into the DOM, replace it inline\r\n\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\r\n\r\n\t\t\t// recycle the old element (skips non-Element node types)\r\n\t\t\trecollectNodeTree(dom, true);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tlet fc = out.firstChild,\r\n\t\tprops = out[ATTR_KEY],\r\n\t\tvchildren = vnode.children;\r\n\r\n\tif (props==null) {\r\n\t\tprops = out[ATTR_KEY] = {};\r\n\t\tfor (let a=out.attributes, i=a.length; i--; ) props[a[i].name] = a[i].value;\r\n\t}\r\n\r\n\t// Optimization: fast-path for elements containing a single TextNode:\r\n\tif (!hydrating && vchildren && vchildren.length===1 && typeof vchildren[0]==='string' && fc!=null && fc.splitText!==undefined && fc.nextSibling==null) {\r\n\t\tif (fc.nodeValue!=vchildren[0]) {\r\n\t\t\tfc.nodeValue = vchildren[0];\r\n\t\t}\r\n\t}\r\n\t// otherwise, if there are existing or new children, diff them:\r\n\telse if (vchildren && vchildren.length || fc!=null) {\r\n\t\tinnerDiffNode(out, vchildren, context, mountAll, hydrating || props.dangerouslySetInnerHTML!=null);\r\n\t}\r\n\r\n\r\n\t// Apply attributes/props from VNode to the DOM Element:\r\n\tdiffAttributes(out, vnode.attributes, props);\r\n\r\n\r\n\t// restore previous SVG mode: (in case we're exiting an SVG namespace)\r\n\tisSvgMode = prevSvgMode;\r\n\r\n\treturn out;\r\n}\r\n\r\n\r\n/** Apply child and attribute changes between a VNode and a DOM Node to the DOM.\r\n *\t@param {Element} dom\t\t\tElement whose children should be compared & mutated\r\n *\t@param {Array} vchildren\t\tArray of VNodes to compare to `dom.childNodes`\r\n *\t@param {Object} context\t\t\tImplicitly descendant context object (from most recent `getChildContext()`)\r\n *\t@param {Boolean} mountAll\r\n *\t@param {Boolean} isHydrating\tIf `true`, consumes externally created elements similar to hydration\r\n */\r\nfunction innerDiffNode(dom, vchildren, context, mountAll, isHydrating) {\r\n\tlet originalChildren = dom.childNodes,\r\n\t\tchildren = [],\r\n\t\tkeyed = {},\r\n\t\tkeyedLen = 0,\r\n\t\tmin = 0,\r\n\t\tlen = originalChildren.length,\r\n\t\tchildrenLen = 0,\r\n\t\tvlen = vchildren ? vchildren.length : 0,\r\n\t\tj, c, f, vchild, child;\r\n\r\n\t// Build up a map of keyed children and an Array of unkeyed children:\r\n\tif (len!==0) {\r\n\t\tfor (let i=0; i 2; ) {\r\n\t\tstack.push(arguments[i]);\r\n\t}\r\n\tif (attributes && attributes.children!=null) {\r\n\t\tif (!stack.length) stack.push(attributes.children);\r\n\t\tdelete attributes.children;\r\n\t}\r\n\twhile (stack.length) {\r\n\t\tif ((child = stack.pop()) && child.pop!==undefined) {\r\n\t\t\tfor (i=child.length; i--; ) stack.push(child[i]);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tif (typeof child==='boolean') child = null;\r\n\r\n\t\t\tif ((simple = typeof nodeName!=='function')) {\r\n\t\t\t\tif (child==null) child = '';\r\n\t\t\t\telse if (typeof child==='number') child = String(child);\r\n\t\t\t\telse if (typeof child!=='string') simple = false;\r\n\t\t\t}\r\n\r\n\t\t\tif (simple && lastSimple) {\r\n\t\t\t\tchildren[children.length-1] += child;\r\n\t\t\t}\r\n\t\t\telse if (children===EMPTY_CHILDREN) {\r\n\t\t\t\tchildren = [child];\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tchildren.push(child);\r\n\t\t\t}\r\n\r\n\t\t\tlastSimple = simple;\r\n\t\t}\r\n\t}\r\n\r\n\tlet p = new VNode();\r\n\tp.nodeName = nodeName;\r\n\tp.children = children;\r\n\tp.attributes = attributes==null ? undefined : attributes;\r\n\tp.key = attributes==null ? undefined : attributes.key;\r\n\r\n\t// if a \"vnode hook\" is defined, pass every created VNode to it\r\n\tif (options.vnode!==undefined) options.vnode(p);\r\n\r\n\treturn p;\r\n}","/**\r\n * @license\r\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\r\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\r\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\r\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\r\n * Code distributed by Google as part of the polymer project is also\r\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\r\n */\r\n\r\n/**\r\n * This shim allows elements written in, or compiled to, ES5 to work on native\r\n * implementations of Custom Elements v1. It sets new.target to the value of\r\n * this.constructor so that the native HTMLElement constructor can access the\r\n * current under-construction element's definition.\r\n */\r\n(function() {\r\n if (\r\n // No Reflect, no classes, no need for shim because native custom elements\r\n // require ES2015 classes or Reflect.\r\n window.Reflect === undefined ||\r\n window.customElements === undefined ||\r\n // The webcomponentsjs custom elements polyfill doesn't require\r\n // ES2015-compatible construction (`super()` or `Reflect.construct`).\r\n window.customElements.hasOwnProperty('polyfillWrapFlushCallback')\r\n ) {\r\n return;\r\n }\r\n const BuiltInHTMLElement = HTMLElement;\r\n window.HTMLElement = function HTMLElement() {\r\n return Reflect.construct(BuiltInHTMLElement, [], this.constructor);\r\n };\r\n HTMLElement.prototype = BuiltInHTMLElement.prototype;\r\n HTMLElement.prototype.constructor = HTMLElement;\r\n Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement);\r\n })();\r\n\r\n\r\n\r\nexport function cssToDom(css) {\r\n const node = document.createElement('style')\r\n node.innerText = css\r\n return node\r\n}\r\n\r\n\r\nexport function npn(str) {\r\n return str.replace(/-(\\w)/g, function ($, $1) {\r\n return $1.toUpperCase();\r\n });\r\n}\r\n\r\nexport function extend(obj, props) {\r\n\tfor (let i in props) obj[i] = props[i];\r\n\treturn obj;\r\n}\r\n\r\n/** Invoke or update a ref, depending on whether it is a function or object ref.\r\n * @param {object|function} [ref=null]\r\n * @param {any} [value]\r\n */\r\nexport function applyRef(ref, value) {\r\n\tif (ref!=null) {\r\n\t\tif (typeof ref=='function') ref(value);\r\n\t\telse ref.current = value;\r\n\t}\r\n}\r\n\r\n/**\r\n * Call a function asynchronously, as soon as possible. Makes\r\n * use of HTML Promise to schedule the callback if available,\r\n * otherwise falling back to `setTimeout` (mainly for IE<11).\r\n * @type {(callback: function) => void}\r\n */\r\nexport const defer = typeof Promise=='function' ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout;\r\n\r\nexport function isArray(obj){\r\n return Object.prototype.toString.call(obj) === '[object Array]'\r\n}\r\n\r\nexport function nProps(props){\r\n if(!props || isArray(props)) return {}\r\n const result = {}\r\n Object.keys(props).forEach(key =>{\r\n result[key] = props[key].value \r\n })\r\n return result\r\n}\r\n","import { extend } from '../util';\r\n\r\n\r\n/**\r\n * Check if two nodes are equivalent.\r\n *\r\n * @param {Node} node\t\t\tDOM Node to compare\r\n * @param {VNode} vnode\t\t\tVirtual DOM node to compare\r\n * @param {boolean} [hydrating=false]\tIf true, ignores component constructors when comparing.\r\n * @private\r\n */\r\nexport function isSameNodeType(node, vnode, hydrating) {\r\n\tif (typeof vnode==='string' || typeof vnode==='number') {\r\n\t\treturn node.splitText!==undefined;\r\n\t}\r\n\tif (typeof vnode.nodeName==='string') {\r\n\t\treturn !node._componentConstructor && isNamedNode(node, vnode.nodeName);\r\n\t}\r\n\treturn hydrating || node._componentConstructor===vnode.nodeName;\r\n}\r\n\r\n\r\n/**\r\n * Check if an Element has a given nodeName, case-insensitively.\r\n *\r\n * @param {Element} node\tA DOM Element to inspect the name of.\r\n * @param {String} nodeName\tUnnormalized name to compare against.\r\n */\r\nexport function isNamedNode(node, nodeName) {\r\n\treturn node.normalizedNodeName===nodeName || node.nodeName.toLowerCase()===nodeName.toLowerCase();\r\n}\r\n\r\n\r\n/**\r\n * Reconstruct Component-style `props` from a VNode.\r\n * Ensures default/fallback values from `defaultProps`:\r\n * Own-properties of `defaultProps` not present in `vnode.attributes` are added.\r\n *\r\n * @param {VNode} vnode\r\n * @returns {Object} props\r\n */\r\nexport function getNodeProps(vnode) {\r\n\tlet props = extend({}, vnode.attributes);\r\n\tprops.children = vnode.children;\r\n\r\n\tlet defaultProps = vnode.nodeName.defaultProps;\r\n\tif (defaultProps!==undefined) {\r\n\t\tfor (let i in defaultProps) {\r\n\t\t\tif (props[i]===undefined) {\r\n\t\t\t\tprops[i] = defaultProps[i];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn props;\r\n}\r\n","import { IS_NON_DIMENSIONAL } from '../constants';\r\nimport { applyRef } from '../util';\r\nimport options from '../options';\r\nimport { npn } from '../util'\r\n\r\n/**\r\n * A DOM event listener\r\n * @typedef {(e: Event) => void} EventListner\r\n */\r\n\r\n/**\r\n * A mapping of event types to event listeners\r\n * @typedef {Object.} EventListenerMap\r\n */\r\n\r\n/**\r\n * Properties Preact adds to elements it creates\r\n * @typedef PreactElementExtensions\r\n * @property {string} [normalizedNodeName] A normalized node name to use in diffing\r\n * @property {EventListenerMap} [_listeners] A map of event listeners added by components to this DOM node\r\n * @property {import('../component').Component} [_component] The component that rendered this DOM node\r\n * @property {function} [_componentConstructor] The constructor of the component that rendered this DOM node\r\n */\r\n\r\n/**\r\n * A DOM element that has been extended with Preact properties\r\n * @typedef {Element & ElementCSSInlineStyle & PreactElementExtensions} PreactElement\r\n */\r\n\r\n/**\r\n * Create an element with the given nodeName.\r\n * @param {string} nodeName The DOM node to create\r\n * @param {boolean} [isSvg=false] If `true`, creates an element within the SVG\r\n * namespace.\r\n * @returns {PreactElement} The created DOM node\r\n */\r\nexport function createNode(nodeName, isSvg) {\r\n\t/** @type {PreactElement} */\r\n\tlet node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName);\r\n\tnode.normalizedNodeName = nodeName;\r\n\treturn node;\r\n}\r\n\r\n\r\n/**\r\n * Remove a child node from its parent if attached.\r\n * @param {Node} node The node to remove\r\n */\r\nexport function removeNode(node) {\r\n\tlet parentNode = node.parentNode;\r\n\tif (parentNode) parentNode.removeChild(node);\r\n}\r\n\r\n\r\n/**\r\n * Set a named attribute on the given Node, with special behavior for some names\r\n * and event handlers. If `value` is `null`, the attribute/handler will be\r\n * removed.\r\n * @param {PreactElement} node An element to mutate\r\n * @param {string} name The name/key to set, such as an event or attribute name\r\n * @param {*} old The last value that was set for this name/node pair\r\n * @param {*} value An attribute value, such as a function to be used as an\r\n * event handler\r\n * @param {boolean} isSvg Are we currently diffing inside an svg?\r\n * @private\r\n */\r\nexport function setAccessor(node, name, old, value, isSvg) {\r\n\tif (name==='className') name = 'class';\r\n\r\n\r\n\tif (name==='key') {\r\n\t\t// ignore\r\n\t}\r\n\telse if (name==='ref') {\r\n\t\tapplyRef(old, null);\r\n\t\tapplyRef(value, node);\r\n\t}\r\n\telse if (name==='class' && !isSvg) {\r\n\t\tnode.className = value || '';\r\n\t}\r\n\telse if (name==='style') {\r\n\t\tif (!value || typeof value==='string' || typeof old==='string') {\r\n\t\t\tnode.style.cssText = value || '';\r\n\t\t}\r\n\t\tif (value && typeof value==='object') {\r\n\t\t\tif (typeof old!=='string') {\r\n\t\t\t\tfor (let i in old) if (!(i in value)) node.style[i] = '';\r\n\t\t\t}\r\n\t\t\tfor (let i in value) {\r\n\t\t\t\tnode.style[i] = typeof value[i]==='number' && IS_NON_DIMENSIONAL.test(i)===false ? (value[i]+'px') : value[i];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\telse if (name==='dangerouslySetInnerHTML') {\r\n\t\tif (value) node.innerHTML = value.__html || '';\r\n\t}\r\n\telse if (name[0]=='o' && name[1]=='n') {\r\n\t\tlet useCapture = name !== (name=name.replace(/Capture$/, ''));\r\n\t\tname = name.toLowerCase().substring(2);\r\n\t\tif (value) {\r\n\t\t\tif (!old) node.addEventListener(name, eventProxy, useCapture);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tnode.removeEventListener(name, eventProxy, useCapture);\r\n\t\t}\r\n\t\t(node._listeners || (node._listeners = {}))[name] = value;\r\n\t}\r\n\telse if (name!=='list' && name!=='type' && !isSvg && name in node) {\r\n\t\t// Attempt to set a DOM property to the given value.\r\n\t\t// IE & FF throw for certain property-value combinations.\r\n\t\ttry {\r\n\t\t\tnode[name] = value==null ? '' : value;\r\n\t\t} catch (e) { }\r\n\t\tif ((value==null || value===false) && name!='spellcheck') node.removeAttribute(name);\r\n\t}\r\n\telse {\r\n\t\tlet ns = isSvg && (name !== (name = name.replace(/^xlink:?/, '')));\r\n\t\t// spellcheck is treated differently than all other boolean values and\r\n\t\t// should not be removed when the value is `false`. See:\r\n\t\t// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-spellcheck\r\n\t\tif (value==null || value===false) {\r\n\t\t\tif (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());\r\n\t\t\telse node.removeAttribute(name);\r\n\t\t}\r\n\t\telse if (typeof value!=='function') {\r\n\t\t\tif (ns) {\r\n\t\t\t\tnode.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);\r\n\t\t\t\tnode.props[npn(name.toLowerCase())] = value;\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tnode.setAttribute(name, value);\r\n\t\t\t\tnode.props[npn(name)] = value;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\n/**\r\n * Proxy an event to hooked event handlers\r\n * @param {Event} e The event object from the browser\r\n * @private\r\n */\r\nfunction eventProxy(e) {\r\n\treturn this._listeners[e.type](options.event && options.event(e) || e);\r\n}","import { ATTR_KEY } from '../constants';\r\nimport { isSameNodeType, isNamedNode } from './index';\r\nimport { createNode, setAccessor } from '../dom/index';\r\nimport { npn } from '../util'\r\nimport { removeNode } from '../dom/index';\r\n\r\n/** Queue of components that have been mounted and are awaiting componentDidMount */\r\nexport const mounts = [];\r\n\r\n/** Diff recursion count, used to track the end of the diff cycle. */\r\nexport let diffLevel = 0;\r\n\r\n/** Global flag indicating if the diff is currently within an SVG */\r\nlet isSvgMode = false;\r\n\r\n/** Global flag indicating if the diff is performing hydration */\r\nlet hydrating = false;\r\n\r\n\r\n\r\n\r\n/** Apply differences in a given vnode (and it's deep children) to a real DOM Node.\r\n *\t@param {Element} [dom=null]\t\tA DOM node to mutate into the shape of the `vnode`\r\n *\t@param {VNode} vnode\t\t\tA VNode (with descendants forming a tree) representing the desired DOM structure\r\n *\t@returns {Element} dom\t\t\tThe created/mutated element\r\n *\t@private\r\n */\r\nexport function diff(dom, vnode, context, mountAll, parent, componentRoot) {\r\n\t// diffLevel having been 0 here indicates initial entry into the diff (not a subdiff)\r\n\tif (!diffLevel++) {\r\n\t\t// when first starting the diff, check if we're diffing an SVG or within an SVG\r\n\t\tisSvgMode = parent!=null && parent.ownerSVGElement!==undefined;\r\n\r\n\t\t// hydration is indicated by the existing element to be diffed not having a prop cache\r\n\t\thydrating = dom!=null && !(ATTR_KEY in dom);\r\n\t}\r\n\r\n\tlet ret = idiff(dom, vnode, context, mountAll, componentRoot);\r\n\r\n\t// append the element if its a new parent\r\n\tif (parent && ret.parentNode!==parent) parent.appendChild(ret);\r\n\r\n\t// diffLevel being reduced to 0 means we're exiting the diff\r\n\tif (!--diffLevel) {\r\n\t\thydrating = false;\r\n\t\t// invoke queued componentDidMount lifecycle methods\r\n\t\t\r\n\t}\r\n\r\n\treturn ret;\r\n}\r\n\r\n\r\n/** Internals of `diff()`, separated to allow bypassing diffLevel / mount flushing. */\r\nfunction idiff(dom, vnode, context, mountAll, componentRoot) {\r\n\tlet out = dom,\r\n\t\tprevSvgMode = isSvgMode;\r\n\r\n\t// empty values (null, undefined, booleans) render as empty Text nodes\r\n\tif (vnode==null || typeof vnode==='boolean') vnode = '';\r\n\r\n\r\n\t// Fast case: Strings & Numbers create/update Text nodes.\r\n\tif (typeof vnode==='string' || typeof vnode==='number') {\r\n\r\n\t\t// update if it's already a Text node:\r\n\t\tif (dom && dom.splitText!==undefined && dom.parentNode && (!dom._component || componentRoot)) {\r\n\t\t\t/* istanbul ignore if */ /* Browser quirk that can't be covered: https://github.com/developit/preact/commit/fd4f21f5c45dfd75151bd27b4c217d8003aa5eb9 */\r\n\t\t\tif (dom.nodeValue!=vnode) {\r\n\t\t\t\tdom.nodeValue = vnode;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse {\r\n\t\t\t// it wasn't a Text node: replace it with one and recycle the old Element\r\n\t\t\tout = document.createTextNode(vnode);\r\n\t\t\tif (dom) {\r\n\t\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\r\n\t\t\t\trecollectNodeTree(dom, true);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tout[ATTR_KEY] = true;\r\n\r\n\t\treturn out;\r\n\t}\r\n\r\n\r\n\t// If the VNode represents a Component, perform a component diff:\r\n\tlet vnodeName = vnode.nodeName;\r\n\t\r\n\r\n\t// Tracks entering and exiting SVG namespace when descending through the tree.\r\n\tisSvgMode = vnodeName==='svg' ? true : vnodeName==='foreignObject' ? false : isSvgMode;\r\n\r\n\r\n\t// If there's no existing element or it's the wrong type, create a new one:\r\n\tvnodeName = String(vnodeName);\r\n\tif (!dom || !isNamedNode(dom, vnodeName)) {\r\n\t\tout = createNode(vnodeName, isSvgMode);\r\n\r\n\t\tif (dom) {\r\n\t\t\t// move children into the replacement node\r\n\t\t\twhile (dom.firstChild) out.appendChild(dom.firstChild);\r\n\r\n\t\t\t// if the previous Element was mounted into the DOM, replace it inline\r\n\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\r\n\r\n\t\t\t// recycle the old element (skips non-Element node types)\r\n\t\t\trecollectNodeTree(dom, true);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tlet fc = out.firstChild,\r\n\t\tprops = out[ATTR_KEY],\r\n\t\tvchildren = vnode.children;\r\n\r\n\tif (props==null) {\r\n\t\tprops = out[ATTR_KEY] = {};\r\n\t\tfor (let a=out.attributes, i=a.length; i--; ) props[a[i].name] = a[i].value;\r\n\t}\r\n\r\n\t// Optimization: fast-path for elements containing a single TextNode:\r\n\tif (!hydrating && vchildren && vchildren.length===1 && typeof vchildren[0]==='string' && fc!=null && fc.splitText!==undefined && fc.nextSibling==null) {\r\n\t\tif (fc.nodeValue!=vchildren[0]) {\r\n\t\t\tfc.nodeValue = vchildren[0];\r\n\t\t}\r\n\t}\r\n\t// otherwise, if there are existing or new children, diff them:\r\n\telse if (vchildren && vchildren.length || fc!=null) {\r\n\t\tinnerDiffNode(out, vchildren, context, mountAll, hydrating || props.dangerouslySetInnerHTML!=null);\r\n\t}\r\n\r\n\r\n\t// Apply attributes/props from VNode to the DOM Element:\r\n\tdiffAttributes(out, vnode.attributes, props);\r\n\r\n\r\n\t// restore previous SVG mode: (in case we're exiting an SVG namespace)\r\n\tisSvgMode = prevSvgMode;\r\n\r\n\treturn out;\r\n}\r\n\r\n\r\n/** Apply child and attribute changes between a VNode and a DOM Node to the DOM.\r\n *\t@param {Element} dom\t\t\tElement whose children should be compared & mutated\r\n *\t@param {Array} vchildren\t\tArray of VNodes to compare to `dom.childNodes`\r\n *\t@param {Object} context\t\t\tImplicitly descendant context object (from most recent `getChildContext()`)\r\n *\t@param {Boolean} mountAll\r\n *\t@param {Boolean} isHydrating\tIf `true`, consumes externally created elements similar to hydration\r\n */\r\nfunction innerDiffNode(dom, vchildren, context, mountAll, isHydrating) {\r\n\tlet originalChildren = dom.childNodes,\r\n\t\tchildren = [],\r\n\t\tkeyed = {},\r\n\t\tkeyedLen = 0,\r\n\t\tmin = 0,\r\n\t\tlen = originalChildren.length,\r\n\t\tchildrenLen = 0,\r\n\t\tvlen = vchildren ? vchildren.length : 0,\r\n\t\tj, c, f, vchild, child;\r\n\r\n\t// Build up a map of keyed children and an Array of unkeyed children:\r\n\tif (len!==0) {\r\n\t\tfor (let i=0; i= Object.keys(pre).length){\n for (let key in pre) {\n const currentValue = current[key]\n if (currentValue === undefined) {\n current[key] = null\n } else {\n syncKeys(currentValue, pre[key])\n }\n }\n }\n } else if (rootCurrentType == ARRAYTYPE && rootPreType == ARRAYTYPE) {\n if (current.length >= pre.length) {\n pre.forEach((item, index) => {\n syncKeys(current[index], item)\n })\n }\n }\n}\n\nfunction _diff(current, pre, path, result) {\n if (current === pre) return\n const rootCurrentType = type(current)\n const rootPreType = type(pre)\n if (rootCurrentType == OBJECTTYPE) {\n if (rootPreType != OBJECTTYPE || Object.keys(current).length < Object.keys(pre).length) {\n setResult(result, path, current)\n } else {\n for (let key in current) {\n const currentValue = current[key]\n const preValue = pre[key]\n const currentType = type(currentValue)\n const preType = type(preValue)\n if (currentType != ARRAYTYPE && currentType != OBJECTTYPE) {\n if (currentValue != pre[key]) {\n setResult(result, (path == '' ? '' : path + \".\") + key, currentValue)\n }\n } else if (currentType == ARRAYTYPE) {\n if (preType != ARRAYTYPE) {\n setResult(result, (path == '' ? '' : path + \".\") + key, currentValue)\n } else {\n if (currentValue.length < preValue.length) {\n setResult(result, (path == '' ? '' : path + \".\") + key, currentValue)\n } else {\n currentValue.forEach((item, index) => {\n _diff(item, preValue[index], (path == '' ? '' : path + \".\") + key + '[' + index + ']', result)\n })\n }\n }\n } else if (currentType == OBJECTTYPE) {\n if (preType != OBJECTTYPE || Object.keys(currentValue).length < Object.keys(preValue).length) {\n setResult(result, (path == '' ? '' : path + \".\") + key, currentValue)\n } else {\n for (let subKey in currentValue) {\n _diff(currentValue[subKey], preValue[subKey], (path == '' ? '' : path + \".\") + key + '.' + subKey, result)\n }\n }\n }\n }\n }\n } else if (rootCurrentType == ARRAYTYPE) {\n if (rootPreType != ARRAYTYPE) {\n setResult(result, path, current)\n } else {\n if (current.length < pre.length) {\n setResult(result, path, current)\n } else {\n current.forEach((item, index) => {\n _diff(item, pre[index], path + '[' + index + ']', result)\n })\n }\n }\n } else {\n setResult(result, path, current)\n }\n}\n\nfunction setResult(result, k, v) {\n if (type(v) != FUNCTIONTYPE) {\n result[k] = v\n }\n}\n\nfunction type(obj) {\n return Object.prototype.toString.call(obj)\n}","import { cssToDom, npn, isArray, nProps } from './util'\nimport { diff } from './vdom/diff';\nimport options from './options'\n\nexport default class WeElement extends HTMLElement {\n constructor() {\n super()\n this.props = nProps(this.constructor.props)\n this.data = this.constructor.data || {}\n }\n\n static get observedAttributes() { \n if(!this.props) return\n if(isArray(this.props)){\n return this.props\n } else {\n return Object.keys(this.props)\n }\n }\n\n connectedCallback() {\n this.store = options.store\n if(this.store){\n this.store.instances.push(this)\n }\n this.install()\n \n const shadowRoot = this.attachShadow({ mode: 'open' })\n\n this.css && shadowRoot.appendChild(cssToDom(this.css()))\n this.host = diff(null, this.render(this.props, this.data), {}, false, null, false)\n shadowRoot.appendChild(this.host)\n\n this.installed()\n }\n\n //chain transfer through this method\n attributeChangedCallback(name, pre, current) {\n this.props[npn(name)] = current\n this.update()\n }\n\n disconnectedCallback() {\n this.uninstall()\n }\n\n update() {\n this.beforeUpdate()\n diff(this.host, this.render(this.props, this.data))\n this.afterUpdate()\n }\n\n fire(name, data){\n this.dispatchEvent(new CustomEvent(name, { detail : data }))\n }\n\n install() {\n\n }\n\n installed() {\n\n }\n\n beforeUpdate() {\n\n }\n\n afterUpdate() {\n\n }\n}\n","\r\nimport { diff } from './vdom/diff'\r\nimport options from './options'\r\nimport jsonDiff from './json-diff'\r\n\r\nexport function render(vnode, parent, store) {\r\n\tparent = typeof parent === 'string' ? document.querySelector(parent) : parent\r\n\tif(store){\r\n\t\tstore.instances = []\r\n\t\textendStoreUpate(store)\r\n\t\toptions.store = store\r\n\t\tstore.originData = JSON.parse(JSON.stringify(store.data))\t\r\n\t}\r\n\tdiff(null, vnode, {}, false, parent, false)\r\n} \r\n\r\nfunction extendStoreUpate(store){\r\n\tstore.update = function(){\r\n\t\tlet diffResult = jsonDiff(this.data, this.originData)\r\n\t\tif (Object.keys(diffResult)[0] == '') {\r\n\t\t\tdiffResult = diffResult['']\r\n\t\t}\r\n\t\tconst updateAll = matchGlobalData(this.globalData, diffResult)\r\n\t\tif (Object.keys(diffResult).length > 0) {\r\n\t\t\tthis.instances.forEach(instance => {\r\n\t\t\t\tif(updateAll || this.updateAll || instance.constructor.updatePath && needUpdate(diffResult, instance.constructor.updatePath)){\r\n\t\t\t\t\tinstance.update()\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t\tthis.onChange && this.onChange(diffResult)\r\n\t\t\tfor (let key in diffResult) {\r\n\t\t\t\tupdateByPath(this.originData, key, typeof diffResult[key] === 'object' ? JSON.parse(JSON.stringify(diffResult[key])) : diffResult[key])\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunction matchGlobalData(globalData, diffResult) {\r\n\tif(!globalData) return false\r\n for (let keyA in diffResult) {\r\n if (globalData.indexOf(keyA) > -1) {\r\n return true\r\n }\r\n for (let i = 0, len = globalData.length; i < len; i++) {\r\n if (includePath(keyA, globalData[i])) {\r\n return true\r\n }\r\n }\r\n }\r\n return false\r\n}\r\n\r\nfunction needUpdate(diffResult, updatePath){\r\n for(let keyA in diffResult){\r\n if(updatePath[keyA]){\r\n return true\r\n }\r\n for(let keyB in updatePath){\r\n if(includePath(keyA, keyB)){\r\n return true\r\n }\r\n }\r\n }\r\n return false\r\n}\r\n\r\nfunction includePath(pathA, pathB){\r\n if(pathA.indexOf(pathB)===0){\r\n const next = pathA.substr(pathB.length, 1)\r\n if(next === '['||next === '.'){\r\n return true\r\n }\r\n }\r\n return false\r\n}\r\n\r\nfunction updateByPath(origin, path, value) {\r\n const arr = path.replace(/]/g, '').replace(/\\[/g, '.').split('.')\r\n let current = origin\r\n for (let i = 0, len = arr.length; i < len; i++) {\r\n if (i === len - 1) {\r\n current[arr[i]] = value\r\n } else {\r\n current = current[arr[i]]\r\n }\r\n }\r\n}\r\n","const OBJECTTYPE = '[object Object]'\r\n\r\nexport function define(name, ctor) {\r\n customElements.define(name, ctor)\r\n if (ctor.data) {\r\n ctor.updatePath = getUpdatePath(ctor.data)\r\n }\r\n}\r\n\r\nfunction getUpdatePath(data) {\r\n const result = {}\r\n dataToPath(data, result)\r\n return result\r\n}\r\n\r\nfunction dataToPath(data, result) {\r\n Object.keys(data).forEach(key => {\r\n result[key] = true\r\n const type = Object.prototype.toString.call(data[key])\r\n if (type === OBJECTTYPE) {\r\n _dataToPath(data[key], key, result)\r\n }\r\n })\r\n}\r\n\r\nfunction _dataToPath(data, path, result) {\r\n Object.keys(data).forEach(key => {\r\n result[path + '.' + key] = true\r\n const type = Object.prototype.toString.call(data[key])\r\n if (type === OBJECTTYPE) {\r\n _dataToPath(data[key], path + '.' + key, result)\r\n }\r\n })\r\n}","function getGlobal() {\r\n\tif (typeof global !== 'object' || !global || global.Math !== Math || global.Array !== Array) {\r\n\t\tif (typeof self !== 'undefined') {\r\n\t\t\treturn self;\r\n\t\t} else if (typeof window !== 'undefined') {\r\n\t\t\treturn window;\r\n\t\t} else if (typeof global !== 'undefined') {\r\n\t\t\treturn global;\r\n\t\t}\r\n\t\treturn (function(){\r\n\t\t\treturn this;\r\n\t\t})();\r\n\t\t\r\n\t}\r\n\treturn global;\r\n}\r\n\r\n/** Global options\r\n *\t@public\r\n *\t@namespace options {Object}\r\n */\r\nexport default {\r\n\r\n\tstore: null,\r\n\t\r\n\troot: getGlobal()\r\n\t//componentChange(component, element) { },\r\n\t/** If `true`, `prop` changes trigger synchronous component updates.\r\n\t *\t@name syncComponentUpdates\r\n\t *\t@type Boolean\r\n\t *\t@default true\r\n\t */\r\n\t//syncComponentUpdates: true,\r\n\r\n\t/** Processes all created VNodes.\r\n\t *\t@param {VNode} vnode\tA newly-created VNode to normalize/process\r\n\t */\r\n\t//vnode(vnode) { }\r\n\r\n\t/** Hook invoked after a component is mounted. */\r\n\t//afterMount(component) { },\r\n\r\n\t/** Hook invoked after the DOM is updated with a component's latest render. */\r\n\t//afterUpdate(component) { }\r\n\r\n\t/** Hook invoked immediately before a component is unmounted. */\r\n\t// beforeUnmount(component) { }\r\n};\r\n","import { h, h as createElement } from './h';\r\nimport options from './options';\r\nimport WeElement from './we-element';\r\nimport { render } from './render';\r\nimport { define } from './define'\r\n\r\nconst instances = [];\r\n\r\noptions.root.Omi = {\r\n\th,\r\n\tcreateElement,\r\n\tWeElement,\r\n\trender,\r\n\toptions,\r\n\tinstances,\r\n\tdefine\r\n};\r\n\r\noptions.root.Omi.version = '4.0.0';\r\n\r\nexport default {\r\n\th,\r\n\tcreateElement,\r\n\tWeElement,\r\n\trender,\r\n\toptions,\r\n\tinstances,\r\n\tdefine\r\n};\r\n\r\nexport {\r\n\th,\r\n\tcreateElement,\r\n\tWeElement,\r\n\trender,\r\n\toptions,\r\n\tinstances,\r\n\tdefine\r\n};\r\n"]} \ No newline at end of file diff --git a/examples/store/main.js b/examples/store/main.js index 1bcab1826..3d264322c 100644 --- a/examples/store/main.js +++ b/examples/store/main.js @@ -54,12 +54,12 @@ class TodoApp extends WeElement { define('todo-app', TodoApp) -const store = { +const store = { data: { items: [], text: '' }, - add:function(){ + add: function () { this.data.items.push({ - text:this.data.text, - id:Date.now() + text: this.data.text, + id: Date.now() }) this.data.text = '' this.update()