From 03d28d238dccfead641849c6126ec79edd3ace3d Mon Sep 17 00:00:00 2001 From: dntzhang Date: Sun, 14 Oct 2018 12:50:23 +0800 Subject: [PATCH] props default value supporting --- README.md | 1 - examples/simple/b.js | 103 +++++++++++++++++++------------ examples/simple/b.js.map | 2 +- examples/simple/hello-element.js | 37 +++++++++-- src/options.js | 11 +--- src/util.js | 36 ++++------- src/we-element.js | 8 +-- 7 files changed, 116 insertions(+), 82 deletions(-) diff --git a/README.md b/README.md index 2913ae209..21de93014 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,6 @@ class HelloElement extends WeElement { } onClick = (evt) => { - console.log(this) //trigger CustomEvent this.fire('abc', { name : 'dntzhang', age: 12 }) evt.stopPropagation() diff --git a/examples/simple/b.js b/examples/simple/b.js index 50ac5f012..2d0281634 100644 --- a/examples/simple/b.js +++ b/examples/simple/b.js @@ -26,14 +26,9 @@ */ var options = { - scopedStyle: true, - $store: null, - isWeb: true, - staticStyleMapping: {}, - doc: typeof document === 'object' ? document : null, - root: getGlobal(), - //styleCache :[{ctor:ctor,ctorName:ctorName,style:style}] - styleCache: [] + store: null, + + root: getGlobal() //componentChange(component, element) { }, /** If `true`, `prop` changes trigger synchronous component updates. * @name syncComponentUpdates @@ -175,31 +170,18 @@ */ var defer = typeof Promise == 'function' ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout; - // export function vdToDom(vd) { - // if(vd){ - // if (vd.nodeName) { - // const dom = document.createElement(vd.nodeName) - // Object.keys(vd.attributes).forEach(key=>{ - // dom.setAttribute(key,vd.attributes[key]) - // }) - // bind(vd, dom) - // vd.children && vd.children.forEach(child => { - // const n = vdToDom(child) - // n&&dom.appendChild(n) - // }) - // return dom - // } else { - // return document.createTextNode(vd) - // } - // } - // } + function isArray(obj) { + return Object.prototype.toString.call(obj) === '[object Array]'; + } - // function bind(vd, dom) { - // if (vd.attributes.onClick) { - - // dom.onclick = vd.attributes.onClick - // } - // } + function nProps(props) { + if (!props || isArray(props)) return {}; + var result = {}; + Object.keys(props).forEach(function (key) { + result[key] = props[key].value; + }); + return result; + } // render modes @@ -645,8 +627,8 @@ var _this = _possibleConstructorReturn(this, _HTMLElement.call(this)); - _this.props = {}; - _this.data = {}; + _this.props = nProps(_this.constructor.props); + _this.data = _this.constructor.data || {}; return _this; } @@ -703,7 +685,7 @@ key: 'observedAttributes', get: function get() { if (!this.props) return; - if (Object.prototype.toString.call(this.props) === '[object Array]') { + if (isArray(this.props)) { return this.props; } else { return Object.keys(this.props); @@ -753,18 +735,26 @@ } return _ret = (_temp = (_this = _possibleConstructorReturn$1(this, _WeElement.call.apply(_WeElement, [this].concat(args))), _this), _this.onClick = function (evt) { - console.log(_this); //trigger CustomEvent _this.fire('abc', { name: 'dntzhang', age: 12 }); evt.stopPropagation(); }, _temp), _possibleConstructorReturn$1(_this, _ret); } + HelloElement.prototype.installed = function installed() { + var _this2 = this; + + setTimeout(function () { + _this2.data.a = 2; + _this2.update(); + }, 1000); + }; + HelloElement.prototype.css = function css() { return '\n div{\n color: red;\n cursor: pointer;\n }'; }; - HelloElement.prototype.render = function render$$1(props) { + HelloElement.prototype.render = function render$$1(props, data) { return Omi.h( 'div', { onClick: this.onClick }, @@ -775,7 +765,20 @@ Omi.h( 'div', null, - 'Click Me!' + 'Click Me!', + props.num + ), + Omi.h( + 'div', + null, + 'data: ', + data.a + ), + Omi.h( + 'div', + null, + 'props ', + props.num ) ); }; @@ -783,7 +786,29 @@ _createClass$1(HelloElement, null, [{ key: 'props', get: function get() { - return ['prop-from-parent', 'msg']; + return { + propFromParent: { + value: '9' + }, + msg: { + value: '' + }, + num: { + value: 10 + } + //不需要默认值直接使用数组 + //return ['prop-from-parent', 'msg'] + }; + } + }, { + key: 'data', + get: function get() { + return { + a: 1, + b: { + c: 2 + } + }; } }]); diff --git a/examples/simple/b.js.map b/examples/simple/b.js.map index f36f1b47f..0efdfe060 100644 --- a/examples/simple/b.js.map +++ b/examples/simple/b.js.map @@ -1 +1 @@ -{"version":3,"file":"b.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","hello-element.js","main.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\tscopedStyle: true,\r\n\t$store: null,\r\n\tisWeb: true,\r\n\tstaticStyleMapping: {},\r\n\tdoc: typeof document === 'object' ? document : null,\r\n\troot: getGlobal(),\r\n\t//styleCache :[{ctor:ctor,ctorName:ctorName,style:style}]\r\n\tstyleCache: []\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\n\r\n// export function vdToDom(vd) {\r\n// if(vd){\r\n// if (vd.nodeName) {\r\n// const dom = document.createElement(vd.nodeName)\r\n// Object.keys(vd.attributes).forEach(key=>{\r\n// dom.setAttribute(key,vd.attributes[key])\r\n// })\r\n// bind(vd, dom)\r\n// vd.children && vd.children.forEach(child => {\r\n// const n = vdToDom(child)\r\n// n&&dom.appendChild(n)\r\n// })\r\n// return dom\r\n// } else {\r\n// return document.createTextNode(vd)\r\n// }\r\n// }\r\n// }\r\n\r\n// function bind(vd, dom) {\r\n// if (vd.attributes.onClick) {\r\n \r\n// dom.onclick = vd.attributes.onClick\r\n// }\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\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) node.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);\r\n\t\t\telse node.setAttribute(name, value);\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 options from '../options';\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 {\n this.props[npn(name)] = this.getAttribute(name)\n })\n\n const shadowRoot = this.attachShadow({ mode: 'open' })\n\n 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\n\r\nexport function render(vnode, parent) {\r\n\tparent = typeof parent === 'string' ? document.querySelector(parent) : parent\r\n\tdiff(null, vnode, {}, false, parent, false);\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\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};\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};\r\n\r\nexport {\r\n\th,\r\n\tcreateElement,\r\n\tWeElement,\r\n\trender,\r\n\toptions,\r\n\tinstances\r\n};\r\n","import { WeElement } from '../../src/omi'\n\nclass HelloElement extends WeElement {\n\n static get props(){\n return ['prop-from-parent', 'msg']\n }\n\n onClick = (evt) => {\n console.log(this)\n //trigger CustomEvent\n this.fire('abc', { name : 'dntzhang', age: 12 })\n evt.stopPropagation()\n }\n\n css() {\n return `\n div{\n color: red;\n cursor: pointer;\n }`\n }\n\n render(props) {\n return (\n
\n Hello {props.msg} {props.propFromParent}\n
Click Me!
\n
\n )\n }\n \n}\n\ncustomElements.define('hello-element', HelloElement)\n","import { render, WeElement } from '../../src/omi'\r\nimport './hello-element'\r\n\r\nclass MyApp extends WeElement {\r\n\r\n onClick = (evt) => {\r\n\r\n }\r\n\r\n onAbc = (evt) => {\r\n this.data.abc = ' by ' + evt.detail.name\r\n this.update() \r\n }\r\n\r\n install () {\r\n this.data.abc = 'abc'\r\n this.data.passToChild = '123'\r\n }\r\n\r\n installed(){\r\n this.data.passToChild = '12345'\r\n this.data.abc = 'abcde'\r\n this.update() \r\n }\r\n\r\n css() {\r\n return `\r\n div{\r\n color: green;\r\n }`\r\n }\r\n\r\n render(props, data) {\r\n return (\r\n
\r\n Hello {props.name} {data.abc}\r\n \r\n
\r\n )\r\n }\r\n}\r\n\r\n\r\ncustomElements.define('my-app', MyApp)\r\n\r\nrender(, 'body')\r\n"],"names":["VNode","getGlobal","global","Math","Array","self","window","scopedStyle","$store","isWeb","staticStyleMapping","doc","document","root","styleCache","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","createElement","innerText","npn","str","replace","$","$1","toUpperCase","applyRef","ref","value","current","defer","Promise","resolve","then","bind","setTimeout","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","props","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","WeElement","data","connectedCallback","install","names","getAttributeNames","forEach","getAttribute","shadowRoot","attachShadow","mode","host","render","installed","attributeChangedCallback","pre","update","disconnectedCallback","uninstall","beforeUpdate","afterUpdate","fire","dispatchEvent","CustomEvent","detail","toString","call","keys","querySelector","instances","Omi","version","HelloElement","onClick","evt","console","log","age","stopPropagation","msg","propFromParent","define","MyApp","onAbc","abc","passToChild"],"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,cAAa,IAFC;CAGdC,SAAQ,IAHM;CAIdC,QAAO,IAJO;CAKdC,qBAAoB,EALN;CAMdC,MAAK,OAAOC,QAAP,KAAoB,QAApB,GAA+BA,QAA/B,GAA0C,IANjC;CAOdC,OAAMZ,WAPQ;CAQd;CACAa,aAAY;CACZ;CACA;;;;;CAKA;;CAEA;;;CAGA;;CAEA;CACA;;CAEA;CACA;;CAEA;CACA;CA9Bc,CAAf;;CCjBA,IAAMC,QAAQ,EAAd;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;;;;;;;;KC/BMU;;;;;;;;;;;;mJAEFT,UAAU,UAACC,GAAD,EAAS,UAInBS,QAAQ,UAACT,GAAD,EAAS;CACb,kBAAKjC,IAAL,CAAU2C,GAAV,GAAgB,SAASV,IAAIV,MAAJ,CAAWjG,IAApC;CACA,kBAAKyF,MAAL;CACH;;;qBAEDb,6BAAW;CACP,aAAKF,IAAL,CAAU2C,GAAV,GAAgB,KAAhB;CACA,aAAK3C,IAAL,CAAU4C,WAAV,GAAwB,KAAxB;CACH;;qBAEDhC,iCAAW;CACP,aAAKZ,IAAL,CAAU4C,WAAV,GAAwB,OAAxB;CACA,aAAK5C,IAAL,CAAU2C,GAAV,GAAgB,OAAhB;CACA,aAAK5B,MAAL;CACH;;qBAED7H,qBAAM;CACF;CAIH;;qBAEDyH,4BAAOzC,OAAO8B,MAAM;CAChB,eACI;CAAA;CAAA,cAAK,SAAS,KAAKgC,OAAnB;CAAA;CACW9D,kBAAM5C,IADjB;CAAA;CACwB0E,iBAAK2C,GAD7B;CAEI,qCAAe,OAAO,KAAKD,KAA3B,EAAkC,oBAAkB1C,KAAK4C,WAAzD,EAAsE,KAAI,WAA1E;CAFJ,SADJ;CAMH;;;GApCe7C;;CAwCpBvH,eAAegK,MAAf,CAAsB,QAAtB,EAAgCC,KAAhC;;CAEA9B,OAAO,kBAAQ,MAAK,UAAb,GAAP,EAA0C,MAA1C;;;;"} \ No newline at end of file +{"version":3,"file":"b.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","hello-element.js","main.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\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) node.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);\r\n\t\t\telse node.setAttribute(name, value);\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 options from '../options';\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 {\n this.props[npn(name)] = this.getAttribute(name)\n })\n\n const shadowRoot = this.attachShadow({ mode: 'open' })\n\n 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\n\r\nexport function render(vnode, parent) {\r\n\tparent = typeof parent === 'string' ? document.querySelector(parent) : parent\r\n\tdiff(null, vnode, {}, false, parent, false);\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\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};\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};\r\n\r\nexport {\r\n\th,\r\n\tcreateElement,\r\n\tWeElement,\r\n\trender,\r\n\toptions,\r\n\tinstances\r\n};\r\n","import { WeElement } from '../../src/omi'\n\nclass HelloElement extends WeElement {\n\n static get props(){\n return {\n propFromParent: {\n value: '9'\n },\n msg: {\n value: ''\n },\n num :{\n value :10\n }\n }\n //不需要默认值直接使用数组\n //return ['prop-from-parent', 'msg']\n }\n\n static get data() {\n return {\n a: 1,\n b: {\n c: 2\n }\n }\n }\n\n onClick = (evt) => {\n //trigger CustomEvent\n this.fire('abc', { name : 'dntzhang', age: 12 })\n evt.stopPropagation()\n }\n\n installed(){\n setTimeout(() => {\n this.data.a = 2\n this.update()\n }, 1000);\n }\n\n css() {\n return `\n div{\n color: red;\n cursor: pointer;\n }`\n }\n\n render(props, data) {\n return (\n
\n Hello {props.msg} {props.propFromParent}\n
Click Me!{props.num}
\n
data: {data.a}
\n
props {props.num}
\n
\n )\n }\n \n}\n\ncustomElements.define('hello-element', HelloElement)\n","import { render, WeElement } from '../../src/omi'\r\nimport './hello-element'\r\n\r\nclass MyApp extends WeElement {\r\n\r\n onClick = (evt) => {\r\n\r\n }\r\n\r\n onAbc = (evt) => {\r\n this.data.abc = ' by ' + evt.detail.name\r\n this.update() \r\n }\r\n\r\n install () {\r\n this.data.abc = 'abc'\r\n this.data.passToChild = '123'\r\n }\r\n\r\n installed(){\r\n this.data.passToChild = '12345'\r\n this.data.abc = 'abcde'\r\n this.update() \r\n }\r\n\r\n css() {\r\n return `\r\n div{\r\n color: green;\r\n }`\r\n }\r\n\r\n render(props, data) {\r\n return (\r\n
\r\n Hello {props.name} {data.abc}\r\n \r\n
\r\n )\r\n }\r\n}\r\n\r\n\r\ncustomElements.define('my-app', MyApp)\r\n\r\nrender(, 'body')\r\n"],"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","WeElement","data","connectedCallback","install","names","getAttributeNames","getAttribute","shadowRoot","attachShadow","mode","host","render","installed","attributeChangedCallback","pre","update","disconnectedCallback","uninstall","beforeUpdate","afterUpdate","fire","dispatchEvent","CustomEvent","detail","querySelector","instances","Omi","version","HelloElement","onClick","evt","age","stopPropagation","msg","propFromParent","num","b","define","MyApp","onAbc","abc","passToChild"],"mappings":";;;CAAA;AACA,CAAO,SAASA,KAAT,GAAiB;;CCDxB,SAASC,SAAT,GAAqB;CACpB,KAAI,OAAOC,MAAP,KAAkB,QAAlB,IAA8B,CAACA,MAA/B,IA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CACd,mBAAO;CACH8E,mBAAG,CADA;CAEH+D,mBAAG;CACChD,uBAAG;CADJ;CAFA,aAAP;CAMH;;;;GAzBsBY;;CA6D3BhI,eAAeqK,MAAf,CAAsB,eAAtB,EAAuCT,YAAvC;;;;;;;;KC5DMU;;;;;;;;;;;;mJAEFT,UAAU,UAACC,GAAD,EAAS,UAInBS,QAAQ,UAACT,GAAD,EAAS;CACb,kBAAK7B,IAAL,CAAUuC,GAAV,GAAgB,SAASV,IAAIP,MAAJ,CAAW/F,IAApC;CACA,kBAAKuF,MAAL;CACH;;;qBAEDZ,6BAAW;CACP,aAAKF,IAAL,CAAUuC,GAAV,GAAgB,KAAhB;CACA,aAAKvC,IAAL,CAAUwC,WAAV,GAAwB,KAAxB;CACH;;qBAED7B,iCAAW;CACP,aAAKX,IAAL,CAAUwC,WAAV,GAAwB,OAAxB;CACA,aAAKxC,IAAL,CAAUuC,GAAV,GAAgB,OAAhB;CACA,aAAKzB,MAAL;CACH;;qBAEDrI,qBAAM;CACF;CAIH;;qBAEDiI,4BAAOvG,OAAO6F,MAAM;CAChB,eACI;CAAA;CAAA,cAAK,SAAS,KAAK4B,OAAnB;CAAA;CACWzH,kBAAMoB,IADjB;CAAA;CACwByE,iBAAKuC,GAD7B;CAEI,qCAAe,OAAO,KAAKD,KAA3B,EAAkC,oBAAkBtC,KAAKwC,WAAzD,EAAsE,KAAI,WAA1E;CAFJ,SADJ;CAMH;;;GApCezC;;CAwCpBhI,eAAeqK,MAAf,CAAsB,QAAtB,EAAgCC,KAAhC;;CAEA3B,OAAO,kBAAQ,MAAK,UAAb,GAAP,EAA0C,MAA1C;;;;"} \ No newline at end of file diff --git a/examples/simple/hello-element.js b/examples/simple/hello-element.js index b596a9178..8e0013088 100644 --- a/examples/simple/hello-element.js +++ b/examples/simple/hello-element.js @@ -3,16 +3,43 @@ import { WeElement } from '../../src/omi' class HelloElement extends WeElement { static get props(){ - return ['prop-from-parent', 'msg'] + return { + propFromParent: { + value: '9' + }, + msg: { + value: '' + }, + num :{ + value :10 + } + } + //不需要默认值直接使用数组 + //return ['prop-from-parent', 'msg'] + } + + static get data() { + return { + a: 1, + b: { + c: 2 + } + } } onClick = (evt) => { - console.log(this) //trigger CustomEvent this.fire('abc', { name : 'dntzhang', age: 12 }) evt.stopPropagation() } + installed(){ + setTimeout(() => { + this.data.a = 2 + this.update() + }, 1000); + } + css() { return ` div{ @@ -21,11 +48,13 @@ class HelloElement extends WeElement { }` } - render(props) { + render(props, data) { return (
Hello {props.msg} {props.propFromParent} -
Click Me!
+
Click Me!{props.num}
+
data: {data.a}
+
props {props.num}
) } diff --git a/src/options.js b/src/options.js index 7638ca21c..376cac56b 100644 --- a/src/options.js +++ b/src/options.js @@ -21,14 +21,9 @@ function getGlobal() { */ export default { - scopedStyle: true, - $store: null, - isWeb: true, - staticStyleMapping: {}, - doc: typeof document === 'object' ? document : null, - root: getGlobal(), - //styleCache :[{ctor:ctor,ctorName:ctorName,style:style}] - styleCache: [] + store: null, + + root: getGlobal() //componentChange(component, element) { }, /** If `true`, `prop` changes trigger synchronous component updates. * @name syncComponentUpdates diff --git a/src/util.js b/src/util.js index fe4f25d4e..0f103114e 100644 --- a/src/util.js +++ b/src/util.js @@ -74,29 +74,15 @@ export function applyRef(ref, value) { */ export const defer = typeof Promise=='function' ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout; +export function isArray(obj){ + return Object.prototype.toString.call(obj) === '[object Array]' +} -// export function vdToDom(vd) { -// if(vd){ -// if (vd.nodeName) { -// const dom = document.createElement(vd.nodeName) -// Object.keys(vd.attributes).forEach(key=>{ -// dom.setAttribute(key,vd.attributes[key]) -// }) -// bind(vd, dom) -// vd.children && vd.children.forEach(child => { -// const n = vdToDom(child) -// n&&dom.appendChild(n) -// }) -// return dom -// } else { -// return document.createTextNode(vd) -// } -// } -// } - -// function bind(vd, dom) { -// if (vd.attributes.onClick) { - -// dom.onclick = vd.attributes.onClick -// } -// } +export function nProps(props){ + if(!props || isArray(props)) return {} + const result = {} + Object.keys(props).forEach(key =>{ + result[key] = props[key].value + }) + return result +} diff --git a/src/we-element.js b/src/we-element.js index c177889a2..ce7a26df8 100644 --- a/src/we-element.js +++ b/src/we-element.js @@ -1,17 +1,17 @@ -import { cssToDom, npn } from './util' +import { cssToDom, npn, isArray, nProps } from './util' import { diff } from './vdom/diff'; export default class WeElement extends HTMLElement { constructor() { super() - this.props = {} - this.data = {} + this.props = nProps(this.constructor.props) + this.data = this.constructor.data || {} } static get observedAttributes() { if(!this.props) return - if(Object.prototype.toString.call(this.props) === '[object Array]'){ + if(isArray(this.props)){ return this.props } else { return Object.keys(this.props)