diff --git a/examples/simple/b.js b/examples/simple/b.js index 59268fd72..e8e3633ce 100644 --- a/examples/simple/b.js +++ b/examples/simple/b.js @@ -183,29 +183,23 @@ }); } + /** Invoke or update a ref, depending on whether it is a function or object ref. + * @param {object|function} [ref=null] + * @param {any} [value] + */ + function applyRef(ref, value) { + if (ref != null) { + if (typeof ref == 'function') ref(value);else ref.current = value; + } + } + /** * Call a function asynchronously, as soon as possible. Makes * use of HTML Promise to schedule the callback if available, * otherwise falling back to `setTimeout` (mainly for IE<11). - * - * @param {Function} callback + * @type {(callback: function) => void} */ - - var usePromise = typeof Promise == 'function'; - - // for native - if (typeof document !== 'object' && typeof global !== 'undefined' && global.__config__) { - if (global.__config__.platform === 'android') { - usePromise = true; - } else { - var systemVersion = global.__config__.systemVersion && global.__config__.systemVersion.split('.')[0] || 0; - if (systemVersion > 8) { - usePromise = true; - } - } - } - - var defer = usePromise ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout; + var defer = typeof Promise == 'function' ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout; // render modes @@ -242,69 +236,64 @@ return node.normalizedNodeName === nodeName || node.nodeName.toLowerCase() === nodeName.toLowerCase(); } - /** Create an element with the given nodeName. - * @param {String} nodeName - * @param {Boolean} [isSvg=false] If `true`, creates an element within the SVG namespace. - * @returns {Element} node + /** + * A DOM event listener + * @typedef {(e: Event) => void} EventListner + */ + + /** + * A mapping of event types to event listeners + * @typedef {Object.} EventListenerMap + */ + + /** + * Properties Preact adds to elements it creates + * @typedef PreactElementExtensions + * @property {string} [normalizedNodeName] A normalized node name to use in diffing + * @property {EventListenerMap} [_listeners] A map of event listeners added by components to this DOM node + * @property {import('../component').Component} [_component] The component that rendered this DOM node + * @property {function} [_componentConstructor] The constructor of the component that rendered this DOM node + */ + + /** + * A DOM element that has been extended with Preact properties + * @typedef {Element & ElementCSSInlineStyle & PreactElementExtensions} PreactElement + */ + + /** + * Create an element with the given nodeName. + * @param {string} nodeName The DOM node to create + * @param {boolean} [isSvg=false] If `true`, creates an element within the SVG + * namespace. + * @returns {PreactElement} The created DOM node */ function createNode(nodeName, isSvg) { - var node = isSvg ? options.doc.createElementNS('http://www.w3.org/2000/svg', nodeName) : options.doc.createElement(nodeName); + /** @type {PreactElement} */ + var node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName); node.normalizedNodeName = nodeName; return node; } - function parseCSSText(cssText) { - var cssTxt = cssText.replace(/\/\*(.|\s)*?\*\//g, " ").replace(/\s+/g, " "); - var style = {}, - _ref = cssTxt.match(/ ?(.*?) ?{([^}]*)}/) || [a, b, cssTxt], - a = _ref[0], - b = _ref[1], - rule = _ref[2]; - var cssToJs = function cssToJs(s) { - return s.replace(/\W+\w/g, function (match) { - return match.slice(-1).toUpperCase(); - }); - }; - var properties = rule.split(";").map(function (o) { - return o.split(":").map(function (x) { - return x && x.trim(); - }); - }); - for (var _iterator = properties, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { - var _ref3; - - if (_isArray) { - if (_i >= _iterator.length) break; - _ref3 = _iterator[_i++]; - } else { - _i = _iterator.next(); - if (_i.done) break; - _ref3 = _i.value; - } - - var _ref2 = _ref3; - var property = _ref2[0]; - var value = _ref2[1]; - style[cssToJs(property)] = value; - }return style; - } - - /** Remove a child node from its parent if attached. - * @param {Element} node The node to remove + /** + * Remove a child node from its parent if attached. + * @param {Node} node The node to remove */ function removeNode(node) { var parentNode = node.parentNode; if (parentNode) parentNode.removeChild(node); } - /** Set a named attribute on the given Node, with special behavior for some names and event handlers. - * If `value` is `null`, the attribute/handler will be removed. - * @param {Element} node An element to mutate - * @param {string} name The name/key to set, such as an event or attribute name - * @param {any} old The last value that was set for this name/node pair - * @param {any} value An attribute value, such as a function to be used as an event handler - * @param {Boolean} isSvg Are we currently diffing inside an svg? - * @private + /** + * Set a named attribute on the given Node, with special behavior for some names + * and event handlers. If `value` is `null`, the attribute/handler will be + * removed. + * @param {PreactElement} node An element to mutate + * @param {string} name The name/key to set, such as an event or attribute name + * @param {*} old The last value that was set for this name/node pair + * @param {*} value An attribute value, such as a function to be used as an + * event handler + * @param {boolean} isSvg Are we currently diffing inside an svg? + * @private */ function setAccessor(node, name, old, value, isSvg) { if (name === 'className') name = 'class'; @@ -312,58 +301,22 @@ if (name === 'key') { // ignore } else if (name === 'ref') { - if (old) old(null); - if (value) value(node); + applyRef(old, null); + applyRef(value, node); } else if (name === 'class' && !isSvg) { node.className = value || ''; } else if (name === 'style') { - if (options.isWeb) { - if (!value || typeof value === 'string' || typeof old === 'string') { - node.style.cssText = value || ''; - } - if (value && typeof value === 'object') { - if (typeof old !== 'string') { - for (var i in old) { - if (!(i in value)) node.style[i] = ''; - } - } - for (var _i2 in value) { - node.style[_i2] = typeof value[_i2] === 'number' && IS_NON_DIMENSIONAL.test(_i2) === false ? value[_i2] + 'px' : value[_i2]; + if (!value || typeof value === 'string' || typeof old === 'string') { + node.style.cssText = value || ''; + } + if (value && typeof value === 'object') { + if (typeof old !== 'string') { + for (var i in old) { + if (!(i in value)) node.style[i] = ''; } } - } else { - var oldJson = old, - currentJson = value; - if (typeof old === 'string') { - oldJson = parseCSSText(old); - } - if (typeof value == 'string') { - currentJson = parseCSSText(value); - } - - var result = {}, - changed = false; - - if (oldJson) { - for (var key in oldJson) { - if (typeof currentJson == 'object' && !(key in currentJson)) { - result[key] = ''; - changed = true; - } - } - - for (var ckey in currentJson) { - if (currentJson[ckey] !== oldJson[ckey]) { - result[ckey] = currentJson[ckey]; - changed = true; - } - } - - if (changed) { - node.setStyles(result); - } - } else { - node.setStyles(currentJson); + for (var _i in value) { + node.style[_i] = typeof value[_i] === 'number' && IS_NON_DIMENSIONAL.test(_i) === false ? value[_i] + 'px' : value[_i]; } } } else if (name === 'dangerouslySetInnerHTML') { @@ -378,10 +331,17 @@ } (node._listeners || (node._listeners = {}))[name] = value; } else if (name !== 'list' && name !== 'type' && !isSvg && name in node) { - setProperty(node, name, value == null ? '' : value); - if (value == null || value === false) node.removeAttribute(name); + // Attempt to set a DOM property to the given value. + // IE & FF throw for certain property-value combinations. + try { + node[name] = value == null ? '' : value; + } catch (e) {} + if ((value == null || value === false) && name != 'spellcheck') node.removeAttribute(name); } else { var ns = isSvg && name !== (name = name.replace(/^xlink:?/, '')); + // spellcheck is treated differently than all other boolean values and + // should not be removed when the value is `false`. See: + // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-spellcheck if (value == null || value === false) { if (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());else node.removeAttribute(name); } else if (typeof value !== 'function') { @@ -390,17 +350,10 @@ } } - /** Attempt to set a DOM property to the given value. - * IE & FF throw for certain property-value combinations. - */ - function setProperty(node, name, value) { - try { - node[name] = value; - } catch (e) {} - } - - /** Proxy an event to hooked event handlers - * @private + /** + * Proxy an event to hooked event handlers + * @param {Event} e The event object from the browser + * @private */ function eventProxy(e) { return this._listeners[e.type](options.event && options.event(e) || e); @@ -743,13 +696,19 @@ }; WeElement.prototype.update = function update() { + this.beforeUpdate(); diff(this.host, this.render()); + this.afterUpdate(); }; WeElement.prototype.install = function install() {}; WeElement.prototype.installed = function installed() {}; + WeElement.prototype.beforeUpdate = function beforeUpdate() {}; + + WeElement.prototype.afterUpdate = function afterUpdate() {}; + return WeElement; }(HTMLElement); diff --git a/examples/simple/b.js.map b/examples/simple/b.js.map index 89ded0d6b..e8abe6828 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\nexport 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\nfunction bind(vd, dom) {\r\n if (vd.attributes.onClick) {\r\n \r\n dom.onclick = vd.attributes.onClick\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\n/**\r\n * Copy all properties from `props` onto `obj`.\r\n * @param {Object} obj\t\tObject onto which properties should be copied.\r\n * @param {Object} props\tObject from which to copy properties.\r\n * @returns obj\r\n * @private\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/**\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 *\r\n * @param {Function} callback\r\n */\r\n\r\nlet usePromise = typeof Promise == 'function';\r\n\r\n// for native\r\nif (typeof document !== 'object' && typeof global !== 'undefined' && global.__config__) {\r\n\tif (global.__config__.platform === 'android') {\r\n\t\tusePromise = true;\r\n\t} else {\r\n\t\tlet systemVersion = global.__config__.systemVersion && global.__config__.systemVersion.split('.')[0] || 0;\r\n\t\tif (systemVersion > 8) {\r\n\t\t\tusePromise = true;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport const defer = usePromise ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout;\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 options from '../options';\r\n\r\n\r\n/** Create an element with the given nodeName.\r\n *\t@param {String} nodeName\r\n *\t@param {Boolean} [isSvg=false]\tIf `true`, creates an element within the SVG namespace.\r\n *\t@returns {Element} node\r\n */\r\nexport function createNode(nodeName, isSvg) {\r\n\tlet node = isSvg ? options.doc.createElementNS('http://www.w3.org/2000/svg', nodeName) : options.doc.createElement(nodeName);\r\n\tnode.normalizedNodeName = nodeName;\r\n\treturn node;\r\n}\r\n\r\nfunction parseCSSText(cssText) {\r\n\tlet cssTxt = cssText.replace(/\\/\\*(.|\\s)*?\\*\\//g, \" \").replace(/\\s+/g, \" \");\r\n\tlet style = {}, [a,b,rule] = cssTxt.match(/ ?(.*?) ?{([^}]*)}/)||[a,b,cssTxt];\r\n\tlet cssToJs = s => s.replace(/\\W+\\w/g, match => match.slice(-1).toUpperCase());\r\n\tlet properties = rule.split(\";\").map(o => o.split(\":\").map(x => x && x.trim()));\r\n\tfor (let [property, value] of properties) style[cssToJs(property)] = value;\r\n\treturn style;\r\n}\r\n\r\n/** Remove a child node from its parent if attached.\r\n *\t@param {Element} node\t\tThe 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/** Set a named attribute on the given Node, with special behavior for some names and event handlers.\r\n *\tIf `value` is `null`, the attribute/handler will be removed.\r\n *\t@param {Element} node\tAn element to mutate\r\n *\t@param {string} name\tThe name/key to set, such as an event or attribute name\r\n *\t@param {any} old\tThe last value that was set for this name/node pair\r\n *\t@param {any} value\tAn attribute value, such as a function to be used as an event handler\r\n *\t@param {Boolean} isSvg\tAre we currently diffing inside an svg?\r\n *\t@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\tif (old) old(null);\r\n\t\tif (value) 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 (options.isWeb) {\r\n\t\t\tif (!value || typeof value==='string' || typeof old==='string') {\r\n\t\t\t\tnode.style.cssText = value || '';\r\n\t\t\t}\r\n\t\t\tif (value && typeof value==='object') {\r\n\t\t\t\tif (typeof old!=='string') {\r\n\t\t\t\t\tfor (let i in old) if (!(i in value)) node.style[i] = '';\r\n\t\t\t\t}\r\n\t\t\t\tfor (let i in value) {\r\n\t\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\t}\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tlet oldJson = old,\r\n\t\t\t\tcurrentJson = value;\r\n\t\t\tif (typeof old === 'string') {\r\n\t\t\t\toldJson = parseCSSText(old);\r\n\t\t\t}\r\n\t\t\tif (typeof value == 'string') {\r\n\t\t\t\tcurrentJson = parseCSSText(value);\r\n\t\t\t}\r\n\t\t\r\n\t\t\tlet result = {},\r\n\t\t\t\tchanged = false;\r\n\t\t\r\n\t\t\tif (oldJson) {\r\n\t\t\t\tfor (let key in oldJson) {\r\n\t\t\t\t\tif (typeof currentJson == 'object' && !(key in currentJson)) {\r\n\t\t\t\t\t\tresult[key] = '';\r\n\t\t\t\t\t\tchanged = true;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\r\n\t\t\t\tfor (let ckey in currentJson) {\r\n\t\t\t\t\tif (currentJson[ckey] !== oldJson[ckey]) {\r\n\t\t\t\t\t\tresult[ckey] = currentJson[ckey];\r\n\t\t\t\t\t\tchanged = true;\r\n\t\t\t\t\t}\r\n\t\t\r\n\t\t\t\t}\r\n\t\t\r\n\t\t\t\tif (changed) {\r\n\t\t\t\t\tnode.setStyles(result);\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tnode.setStyles(currentJson);\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\tsetProperty(node, name, value==null ? '' : value);\r\n\t\tif (value==null || value===false) node.removeAttribute(name);\r\n\t}\r\n\telse {\r\n\t\tlet ns = isSvg && (name !== (name = name.replace(/^xlink:?/, '')));\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/** Attempt to set a DOM property to the given value.\r\n *\tIE & FF throw for certain property-value combinations.\r\n */\r\nfunction setProperty(node, name, value) {\r\n\ttry {\r\n\t\tnode[name] = value;\r\n\t} catch (e) { }\r\n}\r\n\r\n\r\n/** Proxy an event to hooked event handlers\r\n *\t@private\r\n */\r\nfunction eventProxy(e) {\r\n\treturn this._listeners[e.type](options.event && options.event(e) || e);\r\n}\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/** Invoke queued componentDidMount lifecycle methods */\r\nexport function flushMounts() {\r\n\tlet c;\r\n\twhile ((c=mounts.pop())) {\r\n\t\tif (options.afterMount) options.afterMount(c);\r\n\t\tif (c.componentDidMount) c.componentDidMount();\r\n\t\tif (c.installed) c.installed();\r\n\t}\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\tif (!componentRoot) flushMounts();\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 this._vd = this.render()\n this._css = this.css()\n\n const shadowRoot = this.attachShadow({ mode: 'open' })\n\n shadowRoot.appendChild(cssToDom(this._css))\n this.host = vdToDom(this._vd)\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 diff(this.host, this.render())\n }\n\n install() {\n\n }\n\n installed() {\n\n }\n}\n","import { vdToDom } from './util'\r\n\r\nexport function render(vnode, parent) {\r\n\tparent = typeof parent === 'string' ? document.querySelector(parent) : parent\r\n\tparent.appendChild(vdToDom(vnode))\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 observedAttributes() { \n return ['prop-from-parent']\n }\n\n onClick = (evt) => {\n console.log(this)\n evt.stopPropagation()\n }\n\n css() {\n return `\n div{\n color: red;\n }`\n }\n\n render() {\n console.log(this.props.propFromParent)\n return (\n
\n Hello {this.props.msg} {this.props.propFromParent}\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 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() {\r\n return (\r\n
\r\n Hello {this.props.name} {this.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","vdToDom","vd","dom","createElement","keys","forEach","setAttribute","bind","n","appendChild","createTextNode","onClick","onclick","cssToDom","css","node","innerText","npn","str","replace","$","$1","toUpperCase","usePromise","Promise","__config__","platform","systemVersion","split","defer","resolve","then","setTimeout","ATTR_KEY","IS_NON_DIMENSIONAL","isSameNodeType","hydrating","splitText","_componentConstructor","isNamedNode","normalizedNodeName","toLowerCase","createNode","isSvg","createElementNS","parseCSSText","cssText","cssTxt","match","a","b","rule","cssToJs","s","slice","properties","map","o","x","trim","property","value","style","removeNode","parentNode","removeChild","setAccessor","name","old","className","test","oldJson","currentJson","result","changed","ckey","setStyles","innerHTML","__html","useCapture","substring","addEventListener","eventProxy","removeEventListener","_listeners","setProperty","removeAttribute","ns","removeAttributeNS","setAttributeNS","e","type","event","mounts","diffLevel","isSvgMode","flushMounts","c","afterMount","componentDidMount","installed","diff","context","mountAll","parent","componentRoot","ownerSVGElement","ret","idiff","out","prevSvgMode","_component","nodeValue","replaceChild","recollectNodeTree","vnodeName","firstChild","fc","props","vchildren","nextSibling","innerDiffNode","dangerouslySetInnerHTML","diffAttributes","isHydrating","originalChildren","childNodes","keyed","keyedLen","min","len","childrenLen","vlen","j","f","vchild","__key","insertBefore","unmountOnly","ref","removeChildren","lastChild","next","previousSibling","attrs","WeElement","data","connectedCallback","install","names","getAttributeNames","getAttribute","_vd","render","_css","shadowRoot","attachShadow","mode","host","attributeChangedCallback","pre","current","update","disconnectedCallback","uninstall","querySelector","instances","Omi","version","HelloElement","evt","console","log","stopPropagation","propFromParent","msg","define","MyApp","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,G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oBAAkB,KAAKhC,IAAL,CAAUiC,WAA3C,EAAwD,KAAI,UAA5D;CAFJ,SADJ;CAMH;;;GA/BelC;;CAmCpB1J,eAAeyL,MAAf,CAAsB,QAAtB,EAAgCC,KAAhC;;CAEAxB,OAAO,kBAAQ,MAAK,WAAb,GAAP,EAA2C,MAA3C;;;;"} \ 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\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\nexport 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\nfunction bind(vd, dom) {\r\n if (vd.attributes.onClick) {\r\n \r\n dom.onclick = vd.attributes.onClick\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","// 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/** Invoke queued componentDidMount lifecycle methods */\r\nexport function flushMounts() {\r\n\tlet c;\r\n\twhile ((c=mounts.pop())) {\r\n\t\tif (options.afterMount) options.afterMount(c);\r\n\t\tif (c.componentDidMount) c.componentDidMount();\r\n\t\tif (c.installed) c.installed();\r\n\t}\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\tif (!componentRoot) flushMounts();\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 this._vd = this.render()\n this._css = this.css()\n\n const shadowRoot = this.attachShadow({ mode: 'open' })\n\n shadowRoot.appendChild(cssToDom(this._css))\n this.host = vdToDom(this._vd)\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())\n this.afterUpdate()\n }\n\n install() {\n\n }\n\n installed() {\n\n }\n\n beforeUpdate() {\n\n }\n\n afterUpdate() {\n\n }\n}\n","import { vdToDom } from './util'\r\n\r\nexport function render(vnode, parent) {\r\n\tparent = typeof parent === 'string' ? document.querySelector(parent) : parent\r\n\tparent.appendChild(vdToDom(vnode))\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 observedAttributes() { \n return ['prop-from-parent']\n }\n\n onClick = (evt) => {\n console.log(this)\n evt.stopPropagation()\n }\n\n css() {\n return `\n div{\n color: red;\n }`\n }\n\n render() {\n console.log(this.props.propFromParent)\n return (\n
\n Hello {this.props.msg} {this.props.propFromParent}\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 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() {\r\n return (\r\n
\r\n Hello {this.props.name} {this.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","vdToDom","vd","dom","createElement","keys","forEach","setAttribute","bind","n","appendChild","createTextNode","onClick","onclick","cssToDom","css","node","innerText","npn","str","replace","$","$1","toUpperCase","applyRef","ref","value","current","defer","Promise","resolve","then","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","type","event","mounts","diffLevel","isSvgMode","flushMounts","c","afterMount","componentDidMount","installed","diff","context","mountAll","parent","componentRoot","ownerSVGElement","ret","idiff","out","prevSvgMode","_component","nodeValue","replaceChild","recollectNodeTree","vnodeName","firstChild","fc","props","vchildren","a","nextSibling","innerDiffNode","dangerouslySetInnerHTML","diffAttributes","isHydrating","originalChildren","childNodes","keyed","keyedLen","min","len","childrenLen","vlen","j","f","vchild","__key","trim","insertBefore","unmountOnly","removeChildren","lastChild","next","previousSibling","attrs","WeElement","data","connectedCallback","install","names","getAttributeNames","getAttribute","_vd","render","_css","shadowRoot","attachShadow","mode","host","attributeChangedCallback","pre","update","disconnectedCallback","uninstall","beforeUpdate","afterUpdate","querySelector","instances","Omi","version","HelloElement","evt","console","log","stopPropagation","propFromParent","msg","define","MyApp","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,qBAA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CAEI,qCAAe,oBAAkB,KAAKjC,IAAL,CAAUkC,WAA3C,EAAwD,KAAI,UAA5D;CAFJ,SADJ;CAMH;;;GA/BenC;;CAmCpBnI,eAAemK,MAAf,CAAsB,QAAtB,EAAgCC,KAAhC;;CAEAzB,OAAO,kBAAQ,MAAK,WAAb,GAAP,EAA2C,MAA3C;;;;"} \ No newline at end of file diff --git a/src/dom/index.js b/src/dom/index.js index 8762949b2..1bbe7948c 100644 --- a/src/dom/index.js +++ b/src/dom/index.js @@ -1,29 +1,49 @@ import { IS_NON_DIMENSIONAL } from '../constants'; +import { applyRef } from '../util'; import options from '../options'; +/** + * A DOM event listener + * @typedef {(e: Event) => void} EventListner + */ -/** Create an element with the given nodeName. - * @param {String} nodeName - * @param {Boolean} [isSvg=false] If `true`, creates an element within the SVG namespace. - * @returns {Element} node +/** + * A mapping of event types to event listeners + * @typedef {Object.} EventListenerMap + */ + +/** + * Properties Preact adds to elements it creates + * @typedef PreactElementExtensions + * @property {string} [normalizedNodeName] A normalized node name to use in diffing + * @property {EventListenerMap} [_listeners] A map of event listeners added by components to this DOM node + * @property {import('../component').Component} [_component] The component that rendered this DOM node + * @property {function} [_componentConstructor] The constructor of the component that rendered this DOM node + */ + +/** + * A DOM element that has been extended with Preact properties + * @typedef {Element & ElementCSSInlineStyle & PreactElementExtensions} PreactElement + */ + +/** + * Create an element with the given nodeName. + * @param {string} nodeName The DOM node to create + * @param {boolean} [isSvg=false] If `true`, creates an element within the SVG + * namespace. + * @returns {PreactElement} The created DOM node */ export function createNode(nodeName, isSvg) { - let node = isSvg ? options.doc.createElementNS('http://www.w3.org/2000/svg', nodeName) : options.doc.createElement(nodeName); + /** @type {PreactElement} */ + let node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName); node.normalizedNodeName = nodeName; return node; } -function parseCSSText(cssText) { - let cssTxt = cssText.replace(/\/\*(.|\s)*?\*\//g, " ").replace(/\s+/g, " "); - let style = {}, [a,b,rule] = cssTxt.match(/ ?(.*?) ?{([^}]*)}/)||[a,b,cssTxt]; - let cssToJs = s => s.replace(/\W+\w/g, match => match.slice(-1).toUpperCase()); - let properties = rule.split(";").map(o => o.split(":").map(x => x && x.trim())); - for (let [property, value] of properties) style[cssToJs(property)] = value; - return style; -} -/** Remove a child node from its parent if attached. - * @param {Element} node The node to remove +/** + * Remove a child node from its parent if attached. + * @param {Node} node The node to remove */ export function removeNode(node) { let parentNode = node.parentNode; @@ -31,14 +51,17 @@ export function removeNode(node) { } -/** Set a named attribute on the given Node, with special behavior for some names and event handlers. - * If `value` is `null`, the attribute/handler will be removed. - * @param {Element} node An element to mutate - * @param {string} name The name/key to set, such as an event or attribute name - * @param {any} old The last value that was set for this name/node pair - * @param {any} value An attribute value, such as a function to be used as an event handler - * @param {Boolean} isSvg Are we currently diffing inside an svg? - * @private +/** + * Set a named attribute on the given Node, with special behavior for some names + * and event handlers. If `value` is `null`, the attribute/handler will be + * removed. + * @param {PreactElement} node An element to mutate + * @param {string} name The name/key to set, such as an event or attribute name + * @param {*} old The last value that was set for this name/node pair + * @param {*} value An attribute value, such as a function to be used as an + * event handler + * @param {boolean} isSvg Are we currently diffing inside an svg? + * @private */ export function setAccessor(node, name, old, value, isSvg) { if (name==='className') name = 'class'; @@ -48,59 +71,22 @@ export function setAccessor(node, name, old, value, isSvg) { // ignore } else if (name==='ref') { - if (old) old(null); - if (value) value(node); + applyRef(old, null); + applyRef(value, node); } else if (name==='class' && !isSvg) { node.className = value || ''; } else if (name==='style') { - if (options.isWeb) { - if (!value || typeof value==='string' || typeof old==='string') { - node.style.cssText = value || ''; + if (!value || typeof value==='string' || typeof old==='string') { + node.style.cssText = value || ''; + } + if (value && typeof value==='object') { + if (typeof old!=='string') { + for (let i in old) if (!(i in value)) node.style[i] = ''; } - if (value && typeof value==='object') { - if (typeof old!=='string') { - for (let i in old) if (!(i in value)) node.style[i] = ''; - } - for (let i in value) { - node.style[i] = typeof value[i]==='number' && IS_NON_DIMENSIONAL.test(i)===false ? (value[i]+'px') : value[i]; - } - } - } else { - let oldJson = old, - currentJson = value; - if (typeof old === 'string') { - oldJson = parseCSSText(old); - } - if (typeof value == 'string') { - currentJson = parseCSSText(value); - } - - let result = {}, - changed = false; - - if (oldJson) { - for (let key in oldJson) { - if (typeof currentJson == 'object' && !(key in currentJson)) { - result[key] = ''; - changed = true; - } - } - - for (let ckey in currentJson) { - if (currentJson[ckey] !== oldJson[ckey]) { - result[ckey] = currentJson[ckey]; - changed = true; - } - - } - - if (changed) { - node.setStyles(result); - } - } else { - node.setStyles(currentJson); + for (let i in value) { + node.style[i] = typeof value[i]==='number' && IS_NON_DIMENSIONAL.test(i)===false ? (value[i]+'px') : value[i]; } } } @@ -119,11 +105,18 @@ export function setAccessor(node, name, old, value, isSvg) { (node._listeners || (node._listeners = {}))[name] = value; } else if (name!=='list' && name!=='type' && !isSvg && name in node) { - setProperty(node, name, value==null ? '' : value); - if (value==null || value===false) node.removeAttribute(name); + // Attempt to set a DOM property to the given value. + // IE & FF throw for certain property-value combinations. + try { + node[name] = value==null ? '' : value; + } catch (e) { } + if ((value==null || value===false) && name!='spellcheck') node.removeAttribute(name); } else { let ns = isSvg && (name !== (name = name.replace(/^xlink:?/, ''))); + // spellcheck is treated differently than all other boolean values and + // should not be removed when the value is `false`. See: + // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-spellcheck if (value==null || value===false) { if (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase()); else node.removeAttribute(name); @@ -136,19 +129,11 @@ export function setAccessor(node, name, old, value, isSvg) { } -/** Attempt to set a DOM property to the given value. - * IE & FF throw for certain property-value combinations. - */ -function setProperty(node, name, value) { - try { - node[name] = value; - } catch (e) { } -} - - -/** Proxy an event to hooked event handlers - * @private +/** + * Proxy an event to hooked event handlers + * @param {Event} e The event object from the browser + * @private */ function eventProxy(e) { return this._listeners[e.type](options.event && options.event(e) || e); -} +} \ No newline at end of file diff --git a/src/util.js b/src/util.js index 738d9843c..55cef145c 100644 --- a/src/util.js +++ b/src/util.js @@ -75,38 +75,26 @@ export function npn(str) { }); } -/** - * Copy all properties from `props` onto `obj`. - * @param {Object} obj Object onto which properties should be copied. - * @param {Object} props Object from which to copy properties. - * @returns obj - * @private - */ export function extend(obj, props) { for (let i in props) obj[i] = props[i]; return obj; } +/** Invoke or update a ref, depending on whether it is a function or object ref. + * @param {object|function} [ref=null] + * @param {any} [value] + */ +export function applyRef(ref, value) { + if (ref!=null) { + if (typeof ref=='function') ref(value); + else ref.current = value; + } +} + /** * Call a function asynchronously, as soon as possible. Makes * use of HTML Promise to schedule the callback if available, * otherwise falling back to `setTimeout` (mainly for IE<11). - * - * @param {Function} callback + * @type {(callback: function) => void} */ - -let usePromise = typeof Promise == 'function'; - -// for native -if (typeof document !== 'object' && typeof global !== 'undefined' && global.__config__) { - if (global.__config__.platform === 'android') { - usePromise = true; - } else { - let systemVersion = global.__config__.systemVersion && global.__config__.systemVersion.split('.')[0] || 0; - if (systemVersion > 8) { - usePromise = true; - } - } -} - -export const defer = usePromise ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout; +export const defer = typeof Promise=='function' ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout; diff --git a/src/we-element.js b/src/we-element.js index 2a0892077..2d569e5d7 100644 --- a/src/we-element.js +++ b/src/we-element.js @@ -39,7 +39,9 @@ export default class WeElement extends HTMLElement { } update() { + this.beforeUpdate() diff(this.host, this.render()) + this.afterUpdate() } install() { @@ -49,4 +51,12 @@ export default class WeElement extends HTMLElement { installed() { } + + beforeUpdate() { + + } + + afterUpdate() { + + } }