From 7df70a812d233af097acffcc336ebe9a84dfd831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sampo=20Kivist=C3=B6?= Date: Wed, 22 Sep 2021 15:04:57 +0300 Subject: [PATCH] v8.0.0-alpha.0 --- docs/1kcomponents/dist/bundle.js | 2719 +--------- docs/animations-demo/dist/bundle.js | 150 +- docs/animations/dist/bundle.js | 1032 +--- docs/async-render/dist/bundle.js | 100 +- docs/dbmonster/dist/bundle.js | 2253 +------- docs/event-test/dist/bundle.js | 2144 +------- docs/uibench-inferno-compat/dist/bundle.js | 4893 +----------------- docs/uibench-normalization/dist/bundle.js | 2134 +------- docs/uibench-reactlike/dist/bundle.js | 2383 +-------- docs/uibench/dist/bundle.js | 2147 +------- lerna.json | 2 +- packages/inferno-animation/package.json | 12 +- packages/inferno-clone-vnode/package.json | 8 +- packages/inferno-compat/package.json | 22 +- packages/inferno-component/package.json | 4 +- packages/inferno-create-class/package.json | 8 +- packages/inferno-create-element/package.json | 8 +- packages/inferno-devtools/package.json | 10 +- packages/inferno-extras/package.json | 6 +- packages/inferno-hydrate/package.json | 12 +- packages/inferno-hyperscript/package.json | 8 +- packages/inferno-mobx/package.json | 12 +- packages/inferno-redux/package.json | 10 +- packages/inferno-router/package.json | 6 +- packages/inferno-server/package.json | 14 +- packages/inferno-shared/package.json | 2 +- packages/inferno-test-utils/package.json | 8 +- packages/inferno-utils/package.json | 6 +- packages/inferno-vnode-flags/package.json | 2 +- packages/inferno/package.json | 8 +- 30 files changed, 94 insertions(+), 20029 deletions(-) diff --git a/docs/1kcomponents/dist/bundle.js b/docs/1kcomponents/dist/bundle.js index 7e2b55240..8a8d6fab1 100644 --- a/docs/1kcomponents/dist/bundle.js +++ b/docs/1kcomponents/dist/bundle.js @@ -1,2718 +1 @@ -(function () { - 'use strict'; - - function _extends() { - _extends = Object.assign || function (target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i]; - - for (var key in source) { - if (Object.prototype.hasOwnProperty.call(source, key)) { - target[key] = source[key]; - } - } - } - - return target; - }; - - return _extends.apply(this, arguments); - } - - function _inheritsLoose(subClass, superClass) { - subClass.prototype = Object.create(superClass.prototype); - subClass.prototype.constructor = subClass; - - _setPrototypeOf(subClass, superClass); - } - - function _setPrototypeOf(o, p) { - _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { - o.__proto__ = p; - return o; - }; - - return _setPrototypeOf(o, p); - } - - function _assertThisInitialized(self) { - if (self === void 0) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - - return self; - } - - var isArray = Array.isArray; - function isStringOrNumber(o) { - var type = typeof o; - return type === 'string' || type === 'number'; - } - function isNullOrUndef(o) { - return o === void 0 || o === null; - } - function isInvalid(o) { - return o === null || o === false || o === true || o === void 0; - } - function isFunction(o) { - return typeof o === 'function'; - } - function isString(o) { - return typeof o === 'string'; - } - function isNumber(o) { - return typeof o === 'number'; - } - function isNull(o) { - return o === null; - } - function isUndefined(o) { - return o === void 0; - } - function combineFrom(first, second) { - var out = {}; - if (first) { - for (var key in first) { - out[key] = first[key]; - } - } - if (second) { - for (var key$1 in second) { - out[key$1] = second[key$1]; - } - } - return out; - } - // object.event should always be function, otherwise its badly created object. - function isLinkEventObject(o) { - return !isNull(o) && typeof o === 'object'; - } - - // We need EMPTY_OBJ defined in one place. - // Its used for comparison so we cant inline it into shared - var EMPTY_OBJ = {}; - function normalizeEventName(name) { - return name.substr(2).toLowerCase(); - } - function appendChild(parentDOM, dom) { - parentDOM.appendChild(dom); - } - function insertOrAppend(parentDOM, newNode, nextNode) { - if (isNull(nextNode)) { - appendChild(parentDOM, newNode); - } - else { - parentDOM.insertBefore(newNode, nextNode); - } - } - function documentCreateElement(tag, isSVG) { - if (isSVG) { - return document.createElementNS('http://www.w3.org/2000/svg', tag); - } - return document.createElement(tag); - } - function replaceChild(parentDOM, newDom, lastDom) { - parentDOM.replaceChild(newDom, lastDom); - } - function removeChild(parentDOM, childNode) { - parentDOM.removeChild(childNode); - } - function callAll(arrayFn) { - for (var i = 0; i < arrayFn.length; i++) { - arrayFn[i](); - } - } - function findChildVNode(vNode, startEdge, flags) { - var children = vNode.children; - if (flags & 4 /* ComponentClass */) { - return children.$LI; - } - if (flags & 8192 /* Fragment */) { - return vNode.childFlags === 2 /* HasVNodeChildren */ ? children : children[startEdge ? 0 : children.length - 1]; - } - return children; - } - function findDOMfromVNode(vNode, startEdge) { - var flags; - while (vNode) { - flags = vNode.flags; - if (flags & 2033 /* DOMRef */) { - return vNode.dom; - } - vNode = findChildVNode(vNode, startEdge, flags); - } - return null; - } - function removeVNodeDOM(vNode, parentDOM) { - do { - var flags = vNode.flags; - if (flags & 2033 /* DOMRef */) { - removeChild(parentDOM, vNode.dom); - return; - } - var children = vNode.children; - if (flags & 4 /* ComponentClass */) { - vNode = children.$LI; - } - if (flags & 8 /* ComponentFunction */) { - vNode = children; - } - if (flags & 8192 /* Fragment */) { - if (vNode.childFlags === 2 /* HasVNodeChildren */) { - vNode = children; - } - else { - for (var i = 0, len = children.length; i < len; ++i) { - removeVNodeDOM(children[i], parentDOM); - } - return; - } - } - } while (vNode); - } - function moveVNodeDOM(vNode, parentDOM, nextNode) { - do { - var flags = vNode.flags; - if (flags & 2033 /* DOMRef */) { - insertOrAppend(parentDOM, vNode.dom, nextNode); - return; - } - var children = vNode.children; - if (flags & 4 /* ComponentClass */) { - vNode = children.$LI; - } - if (flags & 8 /* ComponentFunction */) { - vNode = children; - } - if (flags & 8192 /* Fragment */) { - if (vNode.childFlags === 2 /* HasVNodeChildren */) { - vNode = children; - } - else { - for (var i = 0, len = children.length; i < len; ++i) { - moveVNodeDOM(children[i], parentDOM, nextNode); - } - return; - } - } - } while (vNode); - } - function createDerivedState(instance, nextProps, state) { - if (instance.constructor.getDerivedStateFromProps) { - return combineFrom(state, instance.constructor.getDerivedStateFromProps(nextProps, state)); - } - return state; - } - var renderCheck = { - v: false - }; - var options = { - componentComparator: null, - createVNode: null, - renderComplete: null - }; - function setTextContent(dom, children) { - dom.textContent = children; - } - // Calling this function assumes, nextValue is linkEvent - function isLastValueSameLinkEvent(lastValue, nextValue) { - return (isLinkEventObject(lastValue) && - lastValue.event === nextValue.event && - lastValue.data === nextValue.data); - } - function mergeUnsetProperties(to, from) { - for (var propName in from) { - if (isUndefined(to[propName])) { - to[propName] = from[propName]; - } - } - return to; - } - function safeCall1(method, arg1) { - return !!isFunction(method) && (method(arg1), true); - } - - var keyPrefix = '$'; - function V(childFlags, children, className, flags, key, props, ref, type) { - this.childFlags = childFlags; - this.children = children; - this.className = className; - this.dom = null; - this.flags = flags; - this.key = key === void 0 ? null : key; - this.props = props === void 0 ? null : props; - this.ref = ref === void 0 ? null : ref; - this.type = type; - } - function createVNode(flags, type, className, children, childFlags, props, key, ref) { - var childFlag = childFlags === void 0 ? 1 /* HasInvalidChildren */ : childFlags; - var vNode = new V(childFlag, children, className, flags, key, props, ref, type); - if (childFlag === 0 /* UnknownChildren */) { - normalizeChildren(vNode, vNode.children); - } - return vNode; - } - function mergeDefaultHooks(flags, type, ref) { - if (flags & 4 /* ComponentClass */) { - return ref; - } - var defaultHooks = (flags & 32768 /* ForwardRef */ ? type.render : type).defaultHooks; - if (isNullOrUndef(defaultHooks)) { - return ref; - } - if (isNullOrUndef(ref)) { - return defaultHooks; - } - return mergeUnsetProperties(ref, defaultHooks); - } - function mergeDefaultProps(flags, type, props) { - // set default props - var defaultProps = (flags & 32768 /* ForwardRef */ ? type.render : type).defaultProps; - if (isNullOrUndef(defaultProps)) { - return props; - } - if (isNullOrUndef(props)) { - return combineFrom(defaultProps, null); - } - return mergeUnsetProperties(props, defaultProps); - } - function resolveComponentFlags(flags, type) { - if (flags & 12 /* ComponentKnown */) { - return flags; - } - if (type.prototype && type.prototype.render) { - return 4 /* ComponentClass */; - } - if (type.render) { - return 32776 /* ForwardRefComponent */; - } - return 8 /* ComponentFunction */; - } - function createComponentVNode(flags, type, props, key, ref) { - flags = resolveComponentFlags(flags, type); - var vNode = new V(1 /* HasInvalidChildren */, null, null, flags, key, mergeDefaultProps(flags, type, props), mergeDefaultHooks(flags, type, ref), type); - return vNode; - } - function createTextVNode(text, key) { - return new V(1 /* HasInvalidChildren */, isNullOrUndef(text) || text === true || text === false ? '' : text, null, 16 /* Text */, key, null, null, null); - } - function createFragment(children, childFlags, key) { - var fragment = createVNode(8192 /* Fragment */, 8192 /* Fragment */, null, children, childFlags, null, key, null); - switch (fragment.childFlags) { - case 1 /* HasInvalidChildren */: - fragment.children = createVoidVNode(); - fragment.childFlags = 2 /* HasVNodeChildren */; - break; - case 16 /* HasTextChildren */: - fragment.children = [createTextVNode(children)]; - fragment.childFlags = 4 /* HasNonKeyedChildren */; - break; - } - return fragment; - } - /* - * Fragment is different than normal vNode, - * because when it needs to be cloned we need to clone its children too - * But not normalize, because otherwise those possibly get KEY and re-mount - */ - function cloneFragment(vNodeToClone) { - var oldChildren = vNodeToClone.children; - var childFlags = vNodeToClone.childFlags; - return createFragment(childFlags === 2 /* HasVNodeChildren */ ? directClone(oldChildren) : oldChildren.map(directClone), childFlags, vNodeToClone.key); - } - function directClone(vNodeToClone) { - var flags = vNodeToClone.flags & -16385 /* ClearInUse */; - var props = vNodeToClone.props; - if (flags & 14 /* Component */) { - if (!isNull(props)) { - var propsToClone = props; - props = {}; - for (var key in propsToClone) { - props[key] = propsToClone[key]; - } - } - } - if ((flags & 8192 /* Fragment */) === 0) { - return new V(vNodeToClone.childFlags, vNodeToClone.children, vNodeToClone.className, flags, vNodeToClone.key, props, vNodeToClone.ref, vNodeToClone.type); - } - return cloneFragment(vNodeToClone); - } - function createVoidVNode() { - return createTextVNode('', null); - } - function _normalizeVNodes(nodes, result, index, currentKey) { - for (var len = nodes.length; index < len; index++) { - var n = nodes[index]; - if (!isInvalid(n)) { - var newKey = currentKey + keyPrefix + index; - if (isArray(n)) { - _normalizeVNodes(n, result, 0, newKey); - } - else { - if (isStringOrNumber(n)) { - n = createTextVNode(n, newKey); - } - else { - var oldKey = n.key; - var isPrefixedKey = isString(oldKey) && oldKey[0] === keyPrefix; - if (n.flags & 81920 /* InUseOrNormalized */ || isPrefixedKey) { - n = directClone(n); - } - n.flags |= 65536 /* Normalized */; - if (!isPrefixedKey) { - if (isNull(oldKey)) { - n.key = newKey; - } - else { - n.key = currentKey + oldKey; - } - } - else if (oldKey.substring(0, currentKey.length) !== currentKey) { - n.key = currentKey + oldKey; - } - } - result.push(n); - } - } - } - } - function normalizeChildren(vNode, children) { - var newChildren; - var newChildFlags = 1 /* HasInvalidChildren */; - // Don't change children to match strict equal (===) true in patching - if (isInvalid(children)) { - newChildren = children; - } - else if (isStringOrNumber(children)) { - newChildFlags = 16 /* HasTextChildren */; - newChildren = children; - } - else if (isArray(children)) { - var len = children.length; - for (var i = 0; i < len; ++i) { - var n = children[i]; - if (isInvalid(n) || isArray(n)) { - newChildren = newChildren || children.slice(0, i); - _normalizeVNodes(children, newChildren, i, ''); - break; - } - else if (isStringOrNumber(n)) { - newChildren = newChildren || children.slice(0, i); - newChildren.push(createTextVNode(n, keyPrefix + i)); - } - else { - var key = n.key; - var needsCloning = (n.flags & 81920 /* InUseOrNormalized */) > 0; - var isNullKey = isNull(key); - var isPrefixed = isString(key) && key[0] === keyPrefix; - if (needsCloning || isNullKey || isPrefixed) { - newChildren = newChildren || children.slice(0, i); - if (needsCloning || isPrefixed) { - n = directClone(n); - } - if (isNullKey || isPrefixed) { - n.key = keyPrefix + i; - } - newChildren.push(n); - } - else if (newChildren) { - newChildren.push(n); - } - n.flags |= 65536 /* Normalized */; - } - } - newChildren = newChildren || children; - if (newChildren.length === 0) { - newChildFlags = 1 /* HasInvalidChildren */; - } - else { - newChildFlags = 8 /* HasKeyedChildren */; - } - } - else { - newChildren = children; - newChildren.flags |= 65536 /* Normalized */; - if (children.flags & 81920 /* InUseOrNormalized */) { - newChildren = directClone(children); - } - newChildFlags = 2 /* HasVNodeChildren */; - } - vNode.children = newChildren; - vNode.childFlags = newChildFlags; - return vNode; - } - function normalizeRoot(input) { - if (isInvalid(input) || isStringOrNumber(input)) { - return createTextVNode(input, null); - } - if (isArray(input)) { - return createFragment(input, 0 /* UnknownChildren */, null); - } - return input.flags & 16384 /* InUse */ ? directClone(input) : input; - } - - var xlinkNS = 'http://www.w3.org/1999/xlink'; - var xmlNS = 'http://www.w3.org/XML/1998/namespace'; - var namespaces = { - 'xlink:actuate': xlinkNS, - 'xlink:arcrole': xlinkNS, - 'xlink:href': xlinkNS, - 'xlink:role': xlinkNS, - 'xlink:show': xlinkNS, - 'xlink:title': xlinkNS, - 'xlink:type': xlinkNS, - 'xml:base': xmlNS, - 'xml:lang': xmlNS, - 'xml:space': xmlNS - }; - - function getDelegatedEventObject(v) { - return { - onClick: v, - onDblClick: v, - onFocusIn: v, - onFocusOut: v, - onKeyDown: v, - onKeyPress: v, - onKeyUp: v, - onMouseDown: v, - onMouseMove: v, - onMouseUp: v, - onTouchEnd: v, - onTouchMove: v, - onTouchStart: v - }; - } - var attachedEventCounts = getDelegatedEventObject(0); - var attachedEvents = getDelegatedEventObject(null); - var syntheticEvents = getDelegatedEventObject(true); - function updateOrAddSyntheticEvent(name, dom) { - var eventsObject = dom.$EV; - if (!eventsObject) { - eventsObject = dom.$EV = getDelegatedEventObject(null); - } - if (!eventsObject[name]) { - if (++attachedEventCounts[name] === 1) { - attachedEvents[name] = attachEventToDocument(name); - } - } - return eventsObject; - } - function unmountSyntheticEvent(name, dom) { - var eventsObject = dom.$EV; - if (eventsObject && eventsObject[name]) { - if (--attachedEventCounts[name] === 0) { - document.removeEventListener(normalizeEventName(name), attachedEvents[name]); - attachedEvents[name] = null; - } - eventsObject[name] = null; - } - } - function handleSyntheticEvent(name, lastEvent, nextEvent, dom) { - if (isFunction(nextEvent)) { - updateOrAddSyntheticEvent(name, dom)[name] = nextEvent; - } - else if (isLinkEventObject(nextEvent)) { - if (isLastValueSameLinkEvent(lastEvent, nextEvent)) { - return; - } - updateOrAddSyntheticEvent(name, dom)[name] = nextEvent; - } - else { - unmountSyntheticEvent(name, dom); - } - } - // When browsers fully support event.composedPath we could loop it through instead of using parentNode property - function getTargetNode(event) { - return isFunction(event.composedPath) ? event.composedPath()[0] : event.target; - } - function dispatchEvents(event, isClick, name, eventData) { - var dom = getTargetNode(event); - do { - // Html Nodes can be nested fe: span inside button in that scenario browser does not handle disabled attribute on parent, - // because the event listener is on document.body - // Don't process clicks on disabled elements - if (isClick && dom.disabled) { - return; - } - var eventsObject = dom.$EV; - if (eventsObject) { - var currentEvent = eventsObject[name]; - if (currentEvent) { - // linkEvent object - eventData.dom = dom; - currentEvent.event ? currentEvent.event(currentEvent.data, event) : currentEvent(event); - if (event.cancelBubble) { - return; - } - } - } - dom = dom.parentNode; - } while (!isNull(dom)); - } - function stopPropagation() { - this.cancelBubble = true; - if (!this.immediatePropagationStopped) { - this.stopImmediatePropagation(); - } - } - function isDefaultPrevented() { - return this.defaultPrevented; - } - function isPropagationStopped() { - return this.cancelBubble; - } - function extendEventProperties(event) { - // Event data needs to be object to save reference to currentTarget getter - var eventData = { - dom: document - }; - event.isDefaultPrevented = isDefaultPrevented; - event.isPropagationStopped = isPropagationStopped; - event.stopPropagation = stopPropagation; - Object.defineProperty(event, 'currentTarget', { - configurable: true, - get: function get() { - return eventData.dom; - } - }); - return eventData; - } - function rootClickEvent(name) { - return function (event) { - if (event.button !== 0) { - // Firefox incorrectly triggers click event for mid/right mouse buttons. - // This bug has been active for 17 years. - // https://bugzilla.mozilla.org/show_bug.cgi?id=184051 - event.stopPropagation(); - return; - } - dispatchEvents(event, true, name, extendEventProperties(event)); - }; - } - function rootEvent(name) { - return function (event) { - dispatchEvents(event, false, name, extendEventProperties(event)); - }; - } - function attachEventToDocument(name) { - var attachedEvent = name === 'onClick' || name === 'onDblClick' ? rootClickEvent(name) : rootEvent(name); - document.addEventListener(normalizeEventName(name), attachedEvent); - return attachedEvent; - } - - function isSameInnerHTML(dom, innerHTML) { - var tempdom = document.createElement('i'); - tempdom.innerHTML = innerHTML; - return tempdom.innerHTML === dom.innerHTML; - } - - function triggerEventListener(props, methodName, e) { - if (props[methodName]) { - var listener = props[methodName]; - if (listener.event) { - listener.event(listener.data, e); - } - else { - listener(e); - } - } - else { - var nativeListenerName = methodName.toLowerCase(); - if (props[nativeListenerName]) { - props[nativeListenerName](e); - } - } - } - function createWrappedFunction(methodName, applyValue) { - var fnMethod = function (e) { - var vNode = this.$V; - // If vNode is gone by the time event fires, no-op - if (!vNode) { - return; - } - var props = vNode.props || EMPTY_OBJ; - var dom = vNode.dom; - if (isString(methodName)) { - triggerEventListener(props, methodName, e); - } - else { - for (var i = 0; i < methodName.length; ++i) { - triggerEventListener(props, methodName[i], e); - } - } - if (isFunction(applyValue)) { - var newVNode = this.$V; - var newProps = newVNode.props || EMPTY_OBJ; - applyValue(newProps, dom, false, newVNode); - } - }; - Object.defineProperty(fnMethod, 'wrapped', { - configurable: false, - enumerable: false, - value: true, - writable: false - }); - return fnMethod; - } - - function attachEvent(dom, eventName, handler) { - var previousKey = "$" + eventName; - var previousArgs = dom[previousKey]; - if (previousArgs) { - if (previousArgs[1].wrapped) { - return; - } - dom.removeEventListener(previousArgs[0], previousArgs[1]); - dom[previousKey] = null; - } - if (isFunction(handler)) { - dom.addEventListener(eventName, handler); - dom[previousKey] = [eventName, handler]; - } - } - - function isCheckedType(type) { - return type === 'checkbox' || type === 'radio'; - } - var onTextInputChange = createWrappedFunction('onInput', applyValueInput); - var wrappedOnChange = createWrappedFunction(['onClick', 'onChange'], applyValueInput); - /* tslint:disable-next-line:no-empty */ - function emptywrapper(event) { - event.stopPropagation(); - } - emptywrapper.wrapped = true; - function inputEvents(dom, nextPropsOrEmpty) { - if (isCheckedType(nextPropsOrEmpty.type)) { - attachEvent(dom, 'change', wrappedOnChange); - attachEvent(dom, 'click', emptywrapper); - } - else { - attachEvent(dom, 'input', onTextInputChange); - } - } - function applyValueInput(nextPropsOrEmpty, dom) { - var type = nextPropsOrEmpty.type; - var value = nextPropsOrEmpty.value; - var checked = nextPropsOrEmpty.checked; - var multiple = nextPropsOrEmpty.multiple; - var defaultValue = nextPropsOrEmpty.defaultValue; - var hasValue = !isNullOrUndef(value); - if (type && type !== dom.type) { - dom.setAttribute('type', type); - } - if (!isNullOrUndef(multiple) && multiple !== dom.multiple) { - dom.multiple = multiple; - } - if (!isNullOrUndef(defaultValue) && !hasValue) { - dom.defaultValue = defaultValue + ''; - } - if (isCheckedType(type)) { - if (hasValue) { - dom.value = value; - } - if (!isNullOrUndef(checked)) { - dom.checked = checked; - } - } - else { - if (hasValue && dom.value !== value) { - dom.defaultValue = value; - dom.value = value; - } - else if (!isNullOrUndef(checked)) { - dom.checked = checked; - } - } - } - - function updateChildOptions(vNode, value) { - if (vNode.type === 'option') { - updateChildOption(vNode, value); - } - else { - var children = vNode.children; - var flags = vNode.flags; - if (flags & 4 /* ComponentClass */) { - updateChildOptions(children.$LI, value); - } - else if (flags & 8 /* ComponentFunction */) { - updateChildOptions(children, value); - } - else if (vNode.childFlags === 2 /* HasVNodeChildren */) { - updateChildOptions(children, value); - } - else if (vNode.childFlags & 12 /* MultipleChildren */) { - for (var i = 0, len = children.length; i < len; ++i) { - updateChildOptions(children[i], value); - } - } - } - } - function updateChildOption(vNode, value) { - var props = vNode.props || EMPTY_OBJ; - var dom = vNode.dom; - // we do this as multiple may have changed - dom.value = props.value; - if (props.value === value || (isArray(value) && value.indexOf(props.value) !== -1)) { - dom.selected = true; - } - else if (!isNullOrUndef(value) || !isNullOrUndef(props.selected)) { - dom.selected = props.selected || false; - } - } - var onSelectChange = createWrappedFunction('onChange', applyValueSelect); - function selectEvents(dom) { - attachEvent(dom, 'change', onSelectChange); - } - function applyValueSelect(nextPropsOrEmpty, dom, mounting, vNode) { - var multiplePropInBoolean = Boolean(nextPropsOrEmpty.multiple); - if (!isNullOrUndef(nextPropsOrEmpty.multiple) && multiplePropInBoolean !== dom.multiple) { - dom.multiple = multiplePropInBoolean; - } - var index = nextPropsOrEmpty.selectedIndex; - if (index === -1) { - dom.selectedIndex = -1; - } - var childFlags = vNode.childFlags; - if (childFlags !== 1 /* HasInvalidChildren */) { - var value = nextPropsOrEmpty.value; - if (isNumber(index) && index > -1 && dom.options[index]) { - value = dom.options[index].value; - } - if (mounting && isNullOrUndef(value)) { - value = nextPropsOrEmpty.defaultValue; - } - updateChildOptions(vNode, value); - } - } - - var onTextareaInputChange = createWrappedFunction('onInput', applyValueTextArea); - var wrappedOnChange$1 = createWrappedFunction('onChange'); - function textAreaEvents(dom, nextPropsOrEmpty) { - attachEvent(dom, 'input', onTextareaInputChange); - if (nextPropsOrEmpty.onChange) { - attachEvent(dom, 'change', wrappedOnChange$1); - } - } - function applyValueTextArea(nextPropsOrEmpty, dom, mounting) { - var value = nextPropsOrEmpty.value; - var domValue = dom.value; - if (isNullOrUndef(value)) { - if (mounting) { - var defaultValue = nextPropsOrEmpty.defaultValue; - if (!isNullOrUndef(defaultValue) && defaultValue !== domValue) { - dom.defaultValue = defaultValue; - dom.value = defaultValue; - } - } - } - else if (domValue !== value) { - /* There is value so keep it controlled */ - dom.defaultValue = value; - dom.value = value; - } - } - - function processElement(flags, vNode, dom, nextPropsOrEmpty, mounting, isControlled) { - if (flags & 64 /* InputElement */) { - applyValueInput(nextPropsOrEmpty, dom); - } - else if (flags & 256 /* SelectElement */) { - applyValueSelect(nextPropsOrEmpty, dom, mounting, vNode); - } - else if (flags & 128 /* TextareaElement */) { - applyValueTextArea(nextPropsOrEmpty, dom, mounting); - } - if (isControlled) { - dom.$V = vNode; - } - } - function addFormElementEventHandlers(flags, dom, nextPropsOrEmpty) { - if (flags & 64 /* InputElement */) { - inputEvents(dom, nextPropsOrEmpty); - } - else if (flags & 256 /* SelectElement */) { - selectEvents(dom); - } - else if (flags & 128 /* TextareaElement */) { - textAreaEvents(dom, nextPropsOrEmpty); - } - } - function isControlledFormElement(nextPropsOrEmpty) { - return nextPropsOrEmpty.type && isCheckedType(nextPropsOrEmpty.type) ? !isNullOrUndef(nextPropsOrEmpty.checked) : !isNullOrUndef(nextPropsOrEmpty.value); - } - function unmountRef(ref) { - if (ref) { - if (!safeCall1(ref, null) && ref.current) { - ref.current = null; - } - } - } - function mountRef(ref, value, lifecycle) { - if (ref && (isFunction(ref) || ref.current !== void 0)) { - lifecycle.push(function () { - if (!safeCall1(ref, value) && ref.current !== void 0) { - ref.current = value; - } - }); - } - } - - function remove(vNode, parentDOM) { - unmount(vNode); - removeVNodeDOM(vNode, parentDOM); - } - function unmount(vNode) { - var flags = vNode.flags; - var children = vNode.children; - var ref; - if (flags & 481 /* Element */) { - ref = vNode.ref; - var props = vNode.props; - unmountRef(ref); - var childFlags = vNode.childFlags; - if (!isNull(props)) { - var keys = Object.keys(props); - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i]; - if (syntheticEvents[key]) { - unmountSyntheticEvent(key, vNode.dom); - } - } - } - if (childFlags & 12 /* MultipleChildren */) { - unmountAllChildren(children); - } - else if (childFlags === 2 /* HasVNodeChildren */) { - unmount(children); - } - } - else if (children) { - if (flags & 4 /* ComponentClass */) { - if (isFunction(children.componentWillUnmount)) { - children.componentWillUnmount(); - } - unmountRef(vNode.ref); - children.$UN = true; - unmount(children.$LI); - } - else if (flags & 8 /* ComponentFunction */) { - ref = vNode.ref; - if (!isNullOrUndef(ref) && isFunction(ref.onComponentWillUnmount)) { - ref.onComponentWillUnmount(findDOMfromVNode(vNode, true), vNode.props || EMPTY_OBJ); - } - unmount(children); - } - else if (flags & 1024 /* Portal */) { - remove(children, vNode.ref); - } - else if (flags & 8192 /* Fragment */) { - if (vNode.childFlags & 12 /* MultipleChildren */) { - unmountAllChildren(children); - } - } - } - } - function unmountAllChildren(children) { - for (var i = 0, len = children.length; i < len; ++i) { - unmount(children[i]); - } - } - function clearDOM(dom) { - // Optimization for clearing dom - dom.textContent = ''; - } - function removeAllChildren(dom, vNode, children) { - unmountAllChildren(children); - if (vNode.flags & 8192 /* Fragment */) { - removeVNodeDOM(vNode, dom); - } - else { - clearDOM(dom); - } - } - - function wrapLinkEvent(nextValue) { - // This variable makes sure there is no "this" context in callback - var ev = nextValue.event; - return function (e) { - ev(nextValue.data, e); - }; - } - function patchEvent(name, lastValue, nextValue, dom) { - if (isLinkEventObject(nextValue)) { - if (isLastValueSameLinkEvent(lastValue, nextValue)) { - return; - } - nextValue = wrapLinkEvent(nextValue); - } - attachEvent(dom, normalizeEventName(name), nextValue); - } - // We are assuming here that we come from patchProp routine - // -nextAttrValue cannot be null or undefined - function patchStyle(lastAttrValue, nextAttrValue, dom) { - if (isNullOrUndef(nextAttrValue)) { - dom.removeAttribute('style'); - return; - } - var domStyle = dom.style; - var style; - var value; - if (isString(nextAttrValue)) { - domStyle.cssText = nextAttrValue; - return; - } - if (!isNullOrUndef(lastAttrValue) && !isString(lastAttrValue)) { - for (style in nextAttrValue) { - // do not add a hasOwnProperty check here, it affects performance - value = nextAttrValue[style]; - if (value !== lastAttrValue[style]) { - domStyle.setProperty(style, value); - } - } - for (style in lastAttrValue) { - if (isNullOrUndef(nextAttrValue[style])) { - domStyle.removeProperty(style); - } - } - } - else { - for (style in nextAttrValue) { - value = nextAttrValue[style]; - domStyle.setProperty(style, value); - } - } - } - function patchDangerInnerHTML(lastValue, nextValue, lastVNode, dom) { - var lastHtml = (lastValue && lastValue.__html) || ''; - var nextHtml = (nextValue && nextValue.__html) || ''; - if (lastHtml !== nextHtml) { - if (!isNullOrUndef(nextHtml) && !isSameInnerHTML(dom, nextHtml)) { - if (!isNull(lastVNode)) { - if (lastVNode.childFlags & 12 /* MultipleChildren */) { - unmountAllChildren(lastVNode.children); - } - else if (lastVNode.childFlags === 2 /* HasVNodeChildren */) { - unmount(lastVNode.children); - } - lastVNode.children = null; - lastVNode.childFlags = 1 /* HasInvalidChildren */; - } - dom.innerHTML = nextHtml; - } - } - } - function patchProp(prop, lastValue, nextValue, dom, isSVG, hasControlledValue, lastVNode) { - switch (prop) { - case 'children': - case 'childrenType': - case 'className': - case 'defaultValue': - case 'key': - case 'multiple': - case 'ref': - case 'selectedIndex': - break; - case 'autoFocus': - dom.autofocus = !!nextValue; - break; - case 'allowfullscreen': - case 'autoplay': - case 'capture': - case 'checked': - case 'controls': - case 'default': - case 'disabled': - case 'hidden': - case 'indeterminate': - case 'loop': - case 'muted': - case 'novalidate': - case 'open': - case 'readOnly': - case 'required': - case 'reversed': - case 'scoped': - case 'seamless': - case 'selected': - dom[prop] = !!nextValue; - break; - case 'defaultChecked': - case 'value': - case 'volume': - if (hasControlledValue && prop === 'value') { - break; - } - var value = isNullOrUndef(nextValue) ? '' : nextValue; - if (dom[prop] !== value) { - dom[prop] = value; - } - break; - case 'style': - patchStyle(lastValue, nextValue, dom); - break; - case 'dangerouslySetInnerHTML': - patchDangerInnerHTML(lastValue, nextValue, lastVNode, dom); - break; - default: - if (syntheticEvents[prop]) { - handleSyntheticEvent(prop, lastValue, nextValue, dom); - } - else if (prop.charCodeAt(0) === 111 && prop.charCodeAt(1) === 110) { - patchEvent(prop, lastValue, nextValue, dom); - } - else if (isNullOrUndef(nextValue)) { - dom.removeAttribute(prop); - } - else if (isSVG && namespaces[prop]) { - // We optimize for isSVG being false - // If we end up in this path we can read property again - dom.setAttributeNS(namespaces[prop], prop, nextValue); - } - else { - dom.setAttribute(prop, nextValue); - } - break; - } - } - function mountProps(vNode, flags, props, dom, isSVG) { - var hasControlledValue = false; - var isFormElement = (flags & 448 /* FormElement */) > 0; - if (isFormElement) { - hasControlledValue = isControlledFormElement(props); - if (hasControlledValue) { - addFormElementEventHandlers(flags, dom, props); - } - } - for (var prop in props) { - // do not add a hasOwnProperty check here, it affects performance - patchProp(prop, null, props[prop], dom, isSVG, hasControlledValue, null); - } - if (isFormElement) { - processElement(flags, vNode, dom, props, true, hasControlledValue); - } - } - - function renderNewInput(instance, props, context) { - var nextInput = normalizeRoot(instance.render(props, instance.state, context)); - var childContext = context; - if (isFunction(instance.getChildContext)) { - childContext = combineFrom(context, instance.getChildContext()); - } - instance.$CX = childContext; - return nextInput; - } - function createClassComponentInstance(vNode, Component, props, context, isSVG, lifecycle) { - var instance = new Component(props, context); - var usesNewAPI = (instance.$N = Boolean(Component.getDerivedStateFromProps || instance.getSnapshotBeforeUpdate)); - instance.$SVG = isSVG; - instance.$L = lifecycle; - vNode.children = instance; - instance.$BS = false; - instance.context = context; - if (instance.props === EMPTY_OBJ) { - instance.props = props; - } - if (!usesNewAPI) { - if (isFunction(instance.componentWillMount)) { - instance.$BR = true; - instance.componentWillMount(); - var pending = instance.$PS; - if (!isNull(pending)) { - var state = instance.state; - if (isNull(state)) { - instance.state = pending; - } - else { - for (var key in pending) { - state[key] = pending[key]; - } - } - instance.$PS = null; - } - instance.$BR = false; - } - } - else { - instance.state = createDerivedState(instance, props, instance.state); - } - instance.$LI = renderNewInput(instance, props, context); - return instance; - } - function renderFunctionalComponent(vNode, context) { - var props = vNode.props || EMPTY_OBJ; - return vNode.flags & 32768 /* ForwardRef */ ? vNode.type.render(props, vNode.ref, context) : vNode.type(props, context); - } - - function mount(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var flags = (vNode.flags |= 16384 /* InUse */); - if (flags & 481 /* Element */) { - mountElement(vNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (flags & 4 /* ComponentClass */) { - mountClassComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (flags & 8 /* ComponentFunction */) { - mountFunctionalComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle); - mountFunctionalComponentCallbacks(vNode, lifecycle); - } - else if (flags & 512 /* Void */ || flags & 16 /* Text */) { - mountText(vNode, parentDOM, nextNode); - } - else if (flags & 8192 /* Fragment */) { - mountFragment(vNode, context, parentDOM, isSVG, nextNode, lifecycle); - } - else if (flags & 1024 /* Portal */) { - mountPortal(vNode, context, parentDOM, nextNode, lifecycle); - } - else ; - } - function mountPortal(vNode, context, parentDOM, nextNode, lifecycle) { - mount(vNode.children, vNode.ref, context, false, null, lifecycle); - var placeHolderVNode = createVoidVNode(); - mountText(placeHolderVNode, parentDOM, nextNode); - vNode.dom = placeHolderVNode.dom; - } - function mountFragment(vNode, context, parentDOM, isSVG, nextNode, lifecycle) { - var children = vNode.children; - var childFlags = vNode.childFlags; - // When fragment is optimized for multiple children, check if there is no children and change flag to invalid - // This is the only normalization always done, to keep optimization flags API same for fragments and regular elements - if (childFlags & 12 /* MultipleChildren */ && children.length === 0) { - childFlags = vNode.childFlags = 2 /* HasVNodeChildren */; - children = vNode.children = createVoidVNode(); - } - if (childFlags === 2 /* HasVNodeChildren */) { - mount(children, parentDOM, nextNode, isSVG, nextNode, lifecycle); - } - else { - mountArrayChildren(children, parentDOM, context, isSVG, nextNode, lifecycle); - } - } - function mountText(vNode, parentDOM, nextNode) { - var dom = (vNode.dom = document.createTextNode(vNode.children)); - if (!isNull(parentDOM)) { - insertOrAppend(parentDOM, dom, nextNode); - } - } - function mountElement(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var flags = vNode.flags; - var props = vNode.props; - var className = vNode.className; - var childFlags = vNode.childFlags; - var dom = (vNode.dom = documentCreateElement(vNode.type, (isSVG = isSVG || (flags & 32 /* SvgElement */) > 0))); - var children = vNode.children; - if (!isNullOrUndef(className) && className !== '') { - if (isSVG) { - dom.setAttribute('class', className); - } - else { - dom.className = className; - } - } - if (childFlags === 16 /* HasTextChildren */) { - setTextContent(dom, children); - } - else if (childFlags !== 1 /* HasInvalidChildren */) { - var childrenIsSVG = isSVG && vNode.type !== 'foreignObject'; - if (childFlags === 2 /* HasVNodeChildren */) { - if (children.flags & 16384 /* InUse */) { - vNode.children = children = directClone(children); - } - mount(children, dom, context, childrenIsSVG, null, lifecycle); - } - else if (childFlags === 8 /* HasKeyedChildren */ || childFlags === 4 /* HasNonKeyedChildren */) { - mountArrayChildren(children, dom, context, childrenIsSVG, null, lifecycle); - } - } - if (!isNull(parentDOM)) { - insertOrAppend(parentDOM, dom, nextNode); - } - if (!isNull(props)) { - mountProps(vNode, flags, props, dom, isSVG); - } - mountRef(vNode.ref, dom, lifecycle); - } - function mountArrayChildren(children, dom, context, isSVG, nextNode, lifecycle) { - for (var i = 0; i < children.length; ++i) { - var child = children[i]; - if (child.flags & 16384 /* InUse */) { - children[i] = child = directClone(child); - } - mount(child, dom, context, isSVG, nextNode, lifecycle); - } - } - function mountClassComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var instance = createClassComponentInstance(vNode, vNode.type, vNode.props || EMPTY_OBJ, context, isSVG, lifecycle); - mount(instance.$LI, parentDOM, instance.$CX, isSVG, nextNode, lifecycle); - mountClassComponentCallbacks(vNode.ref, instance, lifecycle); - } - function mountFunctionalComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - mount((vNode.children = normalizeRoot(renderFunctionalComponent(vNode, context))), parentDOM, context, isSVG, nextNode, lifecycle); - } - function createClassMountCallback(instance) { - return function () { - instance.componentDidMount(); - }; - } - function mountClassComponentCallbacks(ref, instance, lifecycle) { - mountRef(ref, instance, lifecycle); - if (isFunction(instance.componentDidMount)) { - lifecycle.push(createClassMountCallback(instance)); - } - } - function createOnMountCallback(ref, vNode) { - return function () { - ref.onComponentDidMount(findDOMfromVNode(vNode, true), vNode.props || EMPTY_OBJ); - }; - } - function mountFunctionalComponentCallbacks(vNode, lifecycle) { - var ref = vNode.ref; - if (!isNullOrUndef(ref)) { - safeCall1(ref.onComponentWillMount, vNode.props || EMPTY_OBJ); - if (isFunction(ref.onComponentDidMount)) { - lifecycle.push(createOnMountCallback(ref, vNode)); - } - } - } - - function replaceWithNewNode(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle) { - unmount(lastVNode); - if ((nextVNode.flags & lastVNode.flags & 2033 /* DOMRef */) !== 0) { - mount(nextVNode, null, context, isSVG, null, lifecycle); - // Single DOM operation, when we have dom references available - replaceChild(parentDOM, nextVNode.dom, lastVNode.dom); - } - else { - mount(nextVNode, parentDOM, context, isSVG, findDOMfromVNode(lastVNode, true), lifecycle); - removeVNodeDOM(lastVNode, parentDOM); - } - } - function patch(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var nextFlags = (nextVNode.flags |= 16384 /* InUse */); - if (lastVNode.flags !== nextFlags || lastVNode.type !== nextVNode.type || lastVNode.key !== nextVNode.key || nextFlags & 2048 /* ReCreate */) { - if (lastVNode.flags & 16384 /* InUse */) { - replaceWithNewNode(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle); - } - else { - // Last vNode is not in use, it has crashed at application level. Just mount nextVNode and ignore last one - mount(nextVNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - } - else if (nextFlags & 481 /* Element */) { - patchElement(lastVNode, nextVNode, context, isSVG, nextFlags, lifecycle); - } - else if (nextFlags & 4 /* ComponentClass */) { - patchClassComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (nextFlags & 8 /* ComponentFunction */) { - patchFunctionalComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (nextFlags & 16 /* Text */) { - patchText(lastVNode, nextVNode); - } - else if (nextFlags & 512 /* Void */) { - nextVNode.dom = lastVNode.dom; - } - else if (nextFlags & 8192 /* Fragment */) { - patchFragment(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle); - } - else { - patchPortal(lastVNode, nextVNode, context, lifecycle); - } - } - function patchSingleTextChild(lastChildren, nextChildren, parentDOM) { - if (lastChildren !== nextChildren) { - if (lastChildren !== '') { - parentDOM.firstChild.nodeValue = nextChildren; - } - else { - setTextContent(parentDOM, nextChildren); - } - } - } - function patchContentEditableChildren(dom, nextChildren) { - if (dom.textContent !== nextChildren) { - dom.textContent = nextChildren; - } - } - function patchFragment(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle) { - var lastChildren = lastVNode.children; - var nextChildren = nextVNode.children; - var lastChildFlags = lastVNode.childFlags; - var nextChildFlags = nextVNode.childFlags; - var nextNode = null; - // When fragment is optimized for multiple children, check if there is no children and change flag to invalid - // This is the only normalization always done, to keep optimization flags API same for fragments and regular elements - if (nextChildFlags & 12 /* MultipleChildren */ && nextChildren.length === 0) { - nextChildFlags = nextVNode.childFlags = 2 /* HasVNodeChildren */; - nextChildren = nextVNode.children = createVoidVNode(); - } - var nextIsSingle = (nextChildFlags & 2 /* HasVNodeChildren */) !== 0; - if (lastChildFlags & 12 /* MultipleChildren */) { - var lastLen = lastChildren.length; - // We need to know Fragment's edge node when - if ( - // It uses keyed algorithm - (lastChildFlags & 8 /* HasKeyedChildren */ && nextChildFlags & 8 /* HasKeyedChildren */) || - // It transforms from many to single - nextIsSingle || - // It will append more nodes - (!nextIsSingle && nextChildren.length > lastLen)) { - // When fragment has multiple children there is always at least one vNode - nextNode = findDOMfromVNode(lastChildren[lastLen - 1], false).nextSibling; - } - } - patchChildren(lastChildFlags, nextChildFlags, lastChildren, nextChildren, parentDOM, context, isSVG, nextNode, lastVNode, lifecycle); - } - function patchPortal(lastVNode, nextVNode, context, lifecycle) { - var lastContainer = lastVNode.ref; - var nextContainer = nextVNode.ref; - var nextChildren = nextVNode.children; - patchChildren(lastVNode.childFlags, nextVNode.childFlags, lastVNode.children, nextChildren, lastContainer, context, false, null, lastVNode, lifecycle); - nextVNode.dom = lastVNode.dom; - if (lastContainer !== nextContainer && !isInvalid(nextChildren)) { - var node = nextChildren.dom; - removeChild(lastContainer, node); - appendChild(nextContainer, node); - } - } - function patchElement(lastVNode, nextVNode, context, isSVG, nextFlags, lifecycle) { - var dom = (nextVNode.dom = lastVNode.dom); - var lastProps = lastVNode.props; - var nextProps = nextVNode.props; - var isFormElement = false; - var hasControlledValue = false; - var nextPropsOrEmpty; - isSVG = isSVG || (nextFlags & 32 /* SvgElement */) > 0; - // inlined patchProps -- starts -- - if (lastProps !== nextProps) { - var lastPropsOrEmpty = lastProps || EMPTY_OBJ; - nextPropsOrEmpty = nextProps || EMPTY_OBJ; - if (nextPropsOrEmpty !== EMPTY_OBJ) { - isFormElement = (nextFlags & 448 /* FormElement */) > 0; - if (isFormElement) { - hasControlledValue = isControlledFormElement(nextPropsOrEmpty); - } - for (var prop in nextPropsOrEmpty) { - var lastValue = lastPropsOrEmpty[prop]; - var nextValue = nextPropsOrEmpty[prop]; - if (lastValue !== nextValue) { - patchProp(prop, lastValue, nextValue, dom, isSVG, hasControlledValue, lastVNode); - } - } - } - if (lastPropsOrEmpty !== EMPTY_OBJ) { - for (var prop$1 in lastPropsOrEmpty) { - if (isNullOrUndef(nextPropsOrEmpty[prop$1]) && !isNullOrUndef(lastPropsOrEmpty[prop$1])) { - patchProp(prop$1, lastPropsOrEmpty[prop$1], null, dom, isSVG, hasControlledValue, lastVNode); - } - } - } - } - var nextChildren = nextVNode.children; - var nextClassName = nextVNode.className; - // inlined patchProps -- ends -- - if (lastVNode.className !== nextClassName) { - if (isNullOrUndef(nextClassName)) { - dom.removeAttribute('class'); - } - else if (isSVG) { - dom.setAttribute('class', nextClassName); - } - else { - dom.className = nextClassName; - } - } - if (nextFlags & 4096 /* ContentEditable */) { - patchContentEditableChildren(dom, nextChildren); - } - else { - patchChildren(lastVNode.childFlags, nextVNode.childFlags, lastVNode.children, nextChildren, dom, context, isSVG && nextVNode.type !== 'foreignObject', null, lastVNode, lifecycle); - } - if (isFormElement) { - processElement(nextFlags, nextVNode, dom, nextPropsOrEmpty, false, hasControlledValue); - } - var nextRef = nextVNode.ref; - var lastRef = lastVNode.ref; - if (lastRef !== nextRef) { - unmountRef(lastRef); - mountRef(nextRef, dom, lifecycle); - } - } - function replaceOneVNodeWithMultipleVNodes(lastChildren, nextChildren, parentDOM, context, isSVG, lifecycle) { - unmount(lastChildren); - mountArrayChildren(nextChildren, parentDOM, context, isSVG, findDOMfromVNode(lastChildren, true), lifecycle); - removeVNodeDOM(lastChildren, parentDOM); - } - function patchChildren(lastChildFlags, nextChildFlags, lastChildren, nextChildren, parentDOM, context, isSVG, nextNode, parentVNode, lifecycle) { - switch (lastChildFlags) { - case 2 /* HasVNodeChildren */: - switch (nextChildFlags) { - case 2 /* HasVNodeChildren */: - patch(lastChildren, nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - remove(lastChildren, parentDOM); - break; - case 16 /* HasTextChildren */: - unmount(lastChildren); - setTextContent(parentDOM, nextChildren); - break; - default: - replaceOneVNodeWithMultipleVNodes(lastChildren, nextChildren, parentDOM, context, isSVG, lifecycle); - break; - } - break; - case 1 /* HasInvalidChildren */: - switch (nextChildFlags) { - case 2 /* HasVNodeChildren */: - mount(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - break; - case 16 /* HasTextChildren */: - setTextContent(parentDOM, nextChildren); - break; - default: - mountArrayChildren(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - } - break; - case 16 /* HasTextChildren */: - switch (nextChildFlags) { - case 16 /* HasTextChildren */: - patchSingleTextChild(lastChildren, nextChildren, parentDOM); - break; - case 2 /* HasVNodeChildren */: - clearDOM(parentDOM); - mount(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - clearDOM(parentDOM); - break; - default: - clearDOM(parentDOM); - mountArrayChildren(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - } - break; - default: - switch (nextChildFlags) { - case 16 /* HasTextChildren */: - unmountAllChildren(lastChildren); - setTextContent(parentDOM, nextChildren); - break; - case 2 /* HasVNodeChildren */: - removeAllChildren(parentDOM, parentVNode, lastChildren); - mount(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - removeAllChildren(parentDOM, parentVNode, lastChildren); - break; - default: - var lastLength = lastChildren.length | 0; - var nextLength = nextChildren.length | 0; - // Fast path's for both algorithms - if (lastLength === 0) { - if (nextLength > 0) { - mountArrayChildren(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - } - } - else if (nextLength === 0) { - removeAllChildren(parentDOM, parentVNode, lastChildren); - } - else if (nextChildFlags === 8 /* HasKeyedChildren */ && lastChildFlags === 8 /* HasKeyedChildren */) { - patchKeyedChildren(lastChildren, nextChildren, parentDOM, context, isSVG, lastLength, nextLength, nextNode, parentVNode, lifecycle); - } - else { - patchNonKeyedChildren(lastChildren, nextChildren, parentDOM, context, isSVG, lastLength, nextLength, nextNode, lifecycle); - } - break; - } - break; - } - } - function createDidUpdate(instance, lastProps, lastState, snapshot, lifecycle) { - lifecycle.push(function () { - instance.componentDidUpdate(lastProps, lastState, snapshot); - }); - } - function updateClassComponent(instance, nextState, nextProps, parentDOM, context, isSVG, force, nextNode, lifecycle) { - var lastState = instance.state; - var lastProps = instance.props; - var usesNewAPI = Boolean(instance.$N); - var hasSCU = isFunction(instance.shouldComponentUpdate); - if (usesNewAPI) { - nextState = createDerivedState(instance, nextProps, nextState !== lastState ? combineFrom(lastState, nextState) : nextState); - } - if (force || !hasSCU || (hasSCU && instance.shouldComponentUpdate(nextProps, nextState, context))) { - if (!usesNewAPI && isFunction(instance.componentWillUpdate)) { - instance.componentWillUpdate(nextProps, nextState, context); - } - instance.props = nextProps; - instance.state = nextState; - instance.context = context; - var snapshot = null; - var nextInput = renderNewInput(instance, nextProps, context); - if (usesNewAPI && isFunction(instance.getSnapshotBeforeUpdate)) { - snapshot = instance.getSnapshotBeforeUpdate(lastProps, lastState); - } - patch(instance.$LI, nextInput, parentDOM, instance.$CX, isSVG, nextNode, lifecycle); - // Dont update Last input, until patch has been succesfully executed - instance.$LI = nextInput; - if (isFunction(instance.componentDidUpdate)) { - createDidUpdate(instance, lastProps, lastState, snapshot, lifecycle); - } - } - else { - instance.props = nextProps; - instance.state = nextState; - instance.context = context; - } - } - function patchClassComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var instance = (nextVNode.children = lastVNode.children); - // If Component has crashed, ignore it to stay functional - if (isNull(instance)) { - return; - } - instance.$L = lifecycle; - var nextProps = nextVNode.props || EMPTY_OBJ; - var nextRef = nextVNode.ref; - var lastRef = lastVNode.ref; - var nextState = instance.state; - if (!instance.$N) { - if (isFunction(instance.componentWillReceiveProps)) { - instance.$BR = true; - instance.componentWillReceiveProps(nextProps, context); - // If instance component was removed during its own update do nothing. - if (instance.$UN) { - return; - } - instance.$BR = false; - } - if (!isNull(instance.$PS)) { - nextState = combineFrom(nextState, instance.$PS); - instance.$PS = null; - } - } - updateClassComponent(instance, nextState, nextProps, parentDOM, context, isSVG, false, nextNode, lifecycle); - if (lastRef !== nextRef) { - unmountRef(lastRef); - mountRef(nextRef, instance, lifecycle); - } - } - function patchFunctionalComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var shouldUpdate = true; - var nextProps = nextVNode.props || EMPTY_OBJ; - var nextRef = nextVNode.ref; - var lastProps = lastVNode.props; - var nextHooksDefined = !isNullOrUndef(nextRef); - var lastInput = lastVNode.children; - if (nextHooksDefined && isFunction(nextRef.onComponentShouldUpdate)) { - shouldUpdate = nextRef.onComponentShouldUpdate(lastProps, nextProps); - } - if (shouldUpdate !== false) { - if (nextHooksDefined && isFunction(nextRef.onComponentWillUpdate)) { - nextRef.onComponentWillUpdate(lastProps, nextProps); - } - var nextInput = normalizeRoot(renderFunctionalComponent(nextVNode, context)); - patch(lastInput, nextInput, parentDOM, context, isSVG, nextNode, lifecycle); - nextVNode.children = nextInput; - if (nextHooksDefined && isFunction(nextRef.onComponentDidUpdate)) { - nextRef.onComponentDidUpdate(lastProps, nextProps); - } - } - else { - nextVNode.children = lastInput; - } - } - function patchText(lastVNode, nextVNode) { - var nextText = nextVNode.children; - var dom = (nextVNode.dom = lastVNode.dom); - if (nextText !== lastVNode.children) { - dom.nodeValue = nextText; - } - } - function patchNonKeyedChildren(lastChildren, nextChildren, dom, context, isSVG, lastChildrenLength, nextChildrenLength, nextNode, lifecycle) { - var commonLength = lastChildrenLength > nextChildrenLength ? nextChildrenLength : lastChildrenLength; - var i = 0; - var nextChild; - var lastChild; - for (; i < commonLength; ++i) { - nextChild = nextChildren[i]; - lastChild = lastChildren[i]; - if (nextChild.flags & 16384 /* InUse */) { - nextChild = nextChildren[i] = directClone(nextChild); - } - patch(lastChild, nextChild, dom, context, isSVG, nextNode, lifecycle); - lastChildren[i] = nextChild; - } - if (lastChildrenLength < nextChildrenLength) { - for (i = commonLength; i < nextChildrenLength; ++i) { - nextChild = nextChildren[i]; - if (nextChild.flags & 16384 /* InUse */) { - nextChild = nextChildren[i] = directClone(nextChild); - } - mount(nextChild, dom, context, isSVG, nextNode, lifecycle); - } - } - else if (lastChildrenLength > nextChildrenLength) { - for (i = commonLength; i < lastChildrenLength; ++i) { - remove(lastChildren[i], dom); - } - } - } - function patchKeyedChildren(a, b, dom, context, isSVG, aLength, bLength, outerEdge, parentVNode, lifecycle) { - var aEnd = aLength - 1; - var bEnd = bLength - 1; - var j = 0; - var aNode = a[j]; - var bNode = b[j]; - var nextPos; - var nextNode; - // Step 1 - // tslint:disable-next-line - outer: { - // Sync nodes with the same key at the beginning. - while (aNode.key === bNode.key) { - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - a[j] = bNode; - ++j; - if (j > aEnd || j > bEnd) { - break outer; - } - aNode = a[j]; - bNode = b[j]; - } - aNode = a[aEnd]; - bNode = b[bEnd]; - // Sync nodes with the same key at the end. - while (aNode.key === bNode.key) { - if (bNode.flags & 16384 /* InUse */) { - b[bEnd] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - a[aEnd] = bNode; - aEnd--; - bEnd--; - if (j > aEnd || j > bEnd) { - break outer; - } - aNode = a[aEnd]; - bNode = b[bEnd]; - } - } - if (j > aEnd) { - if (j <= bEnd) { - nextPos = bEnd + 1; - nextNode = nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge; - while (j <= bEnd) { - bNode = b[j]; - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - ++j; - mount(bNode, dom, context, isSVG, nextNode, lifecycle); - } - } - } - else if (j > bEnd) { - while (j <= aEnd) { - remove(a[j++], dom); - } - } - else { - patchKeyedChildrenComplex(a, b, context, aLength, bLength, aEnd, bEnd, j, dom, isSVG, outerEdge, parentVNode, lifecycle); - } - } - function patchKeyedChildrenComplex(a, b, context, aLength, bLength, aEnd, bEnd, j, dom, isSVG, outerEdge, parentVNode, lifecycle) { - var aNode; - var bNode; - var nextPos; - var i = 0; - var aStart = j; - var bStart = j; - var aLeft = aEnd - j + 1; - var bLeft = bEnd - j + 1; - var sources = new Int32Array(bLeft + 1); - // Keep track if its possible to remove whole DOM using textContent = ''; - var canRemoveWholeContent = aLeft === aLength; - var moved = false; - var pos = 0; - var patched = 0; - // When sizes are small, just loop them through - if (bLength < 4 || (aLeft | bLeft) < 32) { - for (i = aStart; i <= aEnd; ++i) { - aNode = a[i]; - if (patched < bLeft) { - for (j = bStart; j <= bEnd; j++) { - bNode = b[j]; - if (aNode.key === bNode.key) { - sources[j - bStart] = i + 1; - if (canRemoveWholeContent) { - canRemoveWholeContent = false; - while (aStart < i) { - remove(a[aStart++], dom); - } - } - if (pos > j) { - moved = true; - } - else { - pos = j; - } - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - ++patched; - break; - } - } - if (!canRemoveWholeContent && j > bEnd) { - remove(aNode, dom); - } - } - else if (!canRemoveWholeContent) { - remove(aNode, dom); - } - } - } - else { - var keyIndex = {}; - // Map keys by their index - for (i = bStart; i <= bEnd; ++i) { - keyIndex[b[i].key] = i; - } - // Try to patch same keys - for (i = aStart; i <= aEnd; ++i) { - aNode = a[i]; - if (patched < bLeft) { - j = keyIndex[aNode.key]; - if (j !== void 0) { - if (canRemoveWholeContent) { - canRemoveWholeContent = false; - while (i > aStart) { - remove(a[aStart++], dom); - } - } - sources[j - bStart] = i + 1; - if (pos > j) { - moved = true; - } - else { - pos = j; - } - bNode = b[j]; - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - ++patched; - } - else if (!canRemoveWholeContent) { - remove(aNode, dom); - } - } - else if (!canRemoveWholeContent) { - remove(aNode, dom); - } - } - } - // fast-path: if nothing patched remove all old and add all new - if (canRemoveWholeContent) { - removeAllChildren(dom, parentVNode, a); - mountArrayChildren(b, dom, context, isSVG, outerEdge, lifecycle); - } - else if (moved) { - var seq = lis_algorithm(sources); - j = seq.length - 1; - for (i = bLeft - 1; i >= 0; i--) { - if (sources[i] === 0) { - pos = i + bStart; - bNode = b[pos]; - if (bNode.flags & 16384 /* InUse */) { - b[pos] = bNode = directClone(bNode); - } - nextPos = pos + 1; - mount(bNode, dom, context, isSVG, nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge, lifecycle); - } - else if (j < 0 || i !== seq[j]) { - pos = i + bStart; - bNode = b[pos]; - nextPos = pos + 1; - moveVNodeDOM(bNode, dom, nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge); - } - else { - j--; - } - } - } - else if (patched !== bLeft) { - // when patched count doesn't match b length we need to insert those new ones - // loop backwards so we can use insertBefore - for (i = bLeft - 1; i >= 0; i--) { - if (sources[i] === 0) { - pos = i + bStart; - bNode = b[pos]; - if (bNode.flags & 16384 /* InUse */) { - b[pos] = bNode = directClone(bNode); - } - nextPos = pos + 1; - mount(bNode, dom, context, isSVG, nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge, lifecycle); - } - } - } - } - var result; - var p; - var maxLen = 0; - // https://en.wikipedia.org/wiki/Longest_increasing_subsequence - function lis_algorithm(arr) { - var arrI = 0; - var i = 0; - var j = 0; - var k = 0; - var u = 0; - var v = 0; - var c = 0; - var len = arr.length; - if (len > maxLen) { - maxLen = len; - result = new Int32Array(len); - p = new Int32Array(len); - } - for (; i < len; ++i) { - arrI = arr[i]; - if (arrI !== 0) { - j = result[k]; - if (arr[j] < arrI) { - p[i] = j; - result[++k] = i; - continue; - } - u = 0; - v = k; - while (u < v) { - c = (u + v) >> 1; - if (arr[result[c]] < arrI) { - u = c + 1; - } - else { - v = c; - } - } - if (arrI < arr[result[u]]) { - if (u > 0) { - p[i] = result[u - 1]; - } - result[u] = i; - } - } - } - u = k + 1; - var seq = new Int32Array(u); - v = result[u - 1]; - while (u-- > 0) { - seq[u] = v; - v = p[v]; - result[u] = 0; - } - return seq; - } - - var hasDocumentAvailable = typeof document !== 'undefined'; - if (hasDocumentAvailable) { - /* - * Defining $EV and $V properties on Node.prototype - * fixes v8 "wrong map" de-optimization - */ - if (window.Node) { - Node.prototype.$EV = null; - Node.prototype.$V = null; - } - } - function __render(input, parentDOM, callback, context) { - var lifecycle = []; - var rootInput = parentDOM.$V; - renderCheck.v = true; - if (isNullOrUndef(rootInput)) { - if (!isNullOrUndef(input)) { - if (input.flags & 16384 /* InUse */) { - input = directClone(input); - } - mount(input, parentDOM, context, false, null, lifecycle); - parentDOM.$V = input; - rootInput = input; - } - } - else { - if (isNullOrUndef(input)) { - remove(rootInput, parentDOM); - parentDOM.$V = null; - } - else { - if (input.flags & 16384 /* InUse */) { - input = directClone(input); - } - patch(rootInput, input, parentDOM, context, false, null, lifecycle); - rootInput = parentDOM.$V = input; - } - } - callAll(lifecycle); - renderCheck.v = false; - if (isFunction(callback)) { - callback(); - } - if (isFunction(options.renderComplete)) { - options.renderComplete(rootInput, parentDOM); - } - } - function render(input, parentDOM, callback, context) { - if ( callback === void 0 ) callback = null; - if ( context === void 0 ) context = EMPTY_OBJ; - - __render(input, parentDOM, callback, context); - } - - var QUEUE = []; - var nextTick = typeof Promise !== 'undefined' - ? Promise.resolve().then.bind(Promise.resolve()) - : function (a) { - window.setTimeout(a, 0); - }; - var microTaskPending = false; - function queueStateChanges(component, newState, callback, force) { - var pending = component.$PS; - if (isFunction(newState)) { - newState = newState(pending ? combineFrom(component.state, pending) : component.state, component.props, component.context); - } - if (isNullOrUndef(pending)) { - component.$PS = newState; - } - else { - for (var stateKey in newState) { - pending[stateKey] = newState[stateKey]; - } - } - if (!component.$BR) { - if (!renderCheck.v) { - if (QUEUE.length === 0) { - applyState(component, force); - if (isFunction(callback)) { - callback.call(component); - } - return; - } - } - if (QUEUE.indexOf(component) === -1) { - QUEUE.push(component); - } - if (force) { - component.$F = true; - } - if (!microTaskPending) { - microTaskPending = true; - nextTick(rerender); - } - if (isFunction(callback)) { - var QU = component.$QU; - if (!QU) { - QU = component.$QU = []; - } - QU.push(callback); - } - } - else if (isFunction(callback)) { - component.$L.push(callback.bind(component)); - } - } - function callSetStateCallbacks(component) { - var queue = component.$QU; - for (var i = 0; i < queue.length; ++i) { - queue[i].call(component); - } - component.$QU = null; - } - function rerender() { - var component; - microTaskPending = false; - while ((component = QUEUE.shift())) { - if (!component.$UN) { - var force = component.$F; - component.$F = false; - applyState(component, force); - if (component.$QU) { - callSetStateCallbacks(component); - } - } - } - } - function applyState(component, force) { - if (force || !component.$BR) { - var pendingState = component.$PS; - component.$PS = null; - var lifecycle = []; - renderCheck.v = true; - updateClassComponent(component, combineFrom(component.state, pendingState), component.props, findDOMfromVNode(component.$LI, true).parentNode, component.context, component.$SVG, force, null, lifecycle); - callAll(lifecycle); - renderCheck.v = false; - } - else { - component.state = component.$PS; - component.$PS = null; - } - } - var Component = function Component(props, context) { - // Public - this.state = null; - // Internal properties - this.$BR = false; // BLOCK RENDER - this.$BS = true; // BLOCK STATE - this.$PS = null; // PENDING STATE (PARTIAL or FULL) - this.$LI = null; // LAST INPUT - this.$UN = false; // UNMOUNTED - this.$CX = null; // CHILDCONTEXT - this.$QU = null; // QUEUE - this.$N = false; // Uses new lifecycle API Flag - this.$L = null; // Current lifecycle of this component - this.$SVG = false; // Flag to keep track if component is inside SVG tree - this.$F = false; // Force update flag - this.props = props || EMPTY_OBJ; - this.context = context || EMPTY_OBJ; // context should not be mutable - }; - Component.prototype.forceUpdate = function forceUpdate (callback) { - if (this.$UN) { - return; - } - // Do not allow double render during force update - queueStateChanges(this, {}, callback, true); - }; - Component.prototype.setState = function setState (newState, callback) { - if (this.$UN) { - return; - } - if (!this.$BS) { - queueStateChanges(this, newState, callback, false); - } - }; - Component.prototype.render = function render (_nextProps, _nextState, _nextContext) { - return null; - }; - - var MonitorMaxSamples = 100; - var MonitorSamplesResult = (function () { - function MonitorSamplesResult(min, max, mean, last) { - this.min = min; - this.max = max; - this.mean = mean; - this.last = last; - } - return MonitorSamplesResult; - }()); - /** - * Profile Samples. - */ - var MonitorSamples = (function () { - function MonitorSamples(maxSamples) { - this.samples = []; - this.maxSamples = maxSamples; - this._i = -1; - } - MonitorSamples.prototype.addSample = function (v) { - this._i = (this._i + 1) % this.maxSamples; - this.samples[this._i] = v; - }; - MonitorSamples.prototype.each = function (fn) { - var samples = this.samples; - for (var i = 0; i < samples.length; i++) { - fn(samples[(this._i + 1 + i) % samples.length], i); - } - }; - MonitorSamples.prototype.calc = function () { - var samples = this.samples; - if (samples.length === 0) { - return new MonitorSamplesResult(0, 0, 0, 0); - } - var min = samples[(this._i + 1) % samples.length]; - var max = min; - var sum = 0; - for (var i = 0; i < samples.length; i++) { - var k = samples[(this._i + 1 + i) % samples.length]; - if (k < min) { - min = k; - } - if (k > max) { - max = k; - } - sum += k; - } - var last = samples[this._i]; - var mean = sum / samples.length; - return new MonitorSamplesResult(min, max, mean, last); - }; - return MonitorSamples; - }()); - - var frameTasks = []; - var rafId = -1; - /** - * Schedule new task that will be executed on the next frame. - */ - function scheduleNextFrameTask(task) { - frameTasks.push(task); - if (rafId === -1) { - requestAnimationFrame(function (t) { - rafId = -1; - var tasks = frameTasks; - frameTasks = []; - for (var i = 0; i < tasks.length; i++) { - tasks[i](); - } - }); - } - } - - var __extends = (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - })(); - var MonitorGraphHeight = 30; - var MonitorGraphWidth = MonitorMaxSamples; - var Widget = (function () { - function Widget(name) { - var _this = this; - this._sync = function () { - _this.sync(); - _this._dirty = false; - }; - this.name = name; - this.element = document.createElement("div"); - this.element.style.cssText = "padding: 2px;" + - "background-color: #020;" + - "font-family: monospace;" + - "font-size: 12px;" + - "color: #0f0"; - this._dirty = false; - this.invalidate(); - } - Widget.prototype.invalidate = function () { - if (!this._dirty) { - this._dirty = true; - scheduleNextFrameTask(this._sync); - } - }; - Widget.prototype.sync = function () { - throw new Error("sync method not implemented"); - }; - return Widget; - }()); - var MonitorWidgetFlags; - (function (MonitorWidgetFlags) { - MonitorWidgetFlags[MonitorWidgetFlags["HideMin"] = 1] = "HideMin"; - MonitorWidgetFlags[MonitorWidgetFlags["HideMax"] = 2] = "HideMax"; - MonitorWidgetFlags[MonitorWidgetFlags["HideMean"] = 4] = "HideMean"; - MonitorWidgetFlags[MonitorWidgetFlags["HideLast"] = 8] = "HideLast"; - MonitorWidgetFlags[MonitorWidgetFlags["HideGraph"] = 16] = "HideGraph"; - MonitorWidgetFlags[MonitorWidgetFlags["RoundValues"] = 32] = "RoundValues"; - })(MonitorWidgetFlags || (MonitorWidgetFlags = {})); - var MonitorWidget = (function (_super) { - __extends(MonitorWidget, _super); - function MonitorWidget(name, flags, unitName, samples) { - var _this = _super.call(this, name) || this; - _this.flags = flags; - _this.unitName = unitName; - _this.samples = samples; - var label = document.createElement("div"); - label.style.cssText = "text-align: center"; - label.textContent = _this.name; - var text = document.createElement("div"); - if ((flags & MonitorWidgetFlags.HideMin) === 0) { - _this.minText = document.createElement("div"); - text.appendChild(_this.minText); - } - else { - _this.minText = null; - } - if ((flags & MonitorWidgetFlags.HideMax) === 0) { - _this.maxText = document.createElement("div"); - text.appendChild(_this.maxText); - } - else { - _this.maxText = null; - } - if ((flags & MonitorWidgetFlags.HideMean) === 0) { - _this.meanText = document.createElement("div"); - text.appendChild(_this.meanText); - } - else { - _this.meanText = null; - } - if ((flags & MonitorWidgetFlags.HideLast) === 0) { - _this.lastText = document.createElement("div"); - text.appendChild(_this.lastText); - } - else { - _this.lastText = null; - } - _this.element.appendChild(label); - _this.element.appendChild(text); - if ((flags & MonitorWidgetFlags.HideGraph) === 0) { - _this.canvas = document.createElement("canvas"); - _this.canvas.style.cssText = "display: block; padding: 0; margin: 0"; - _this.canvas.width = MonitorGraphWidth; - _this.canvas.height = MonitorGraphHeight; - _this.ctx = _this.canvas.getContext("2d"); - _this.element.appendChild(_this.canvas); - } - else { - _this.canvas = null; - _this.ctx = null; - } - return _this; - } - MonitorWidget.prototype.sync = function () { - var _this = this; - var result = this.samples.calc(); - var scale = MonitorGraphHeight / (result.max * 1.2); - var min; - var max; - var mean; - var last; - if ((this.flags & MonitorWidgetFlags.RoundValues) === 0) { - min = result.min.toFixed(2); - max = result.max.toFixed(2); - mean = result.mean.toFixed(2); - last = result.last.toFixed(2); - } - else { - min = Math.round(result.min).toString(); - max = Math.round(result.max).toString(); - mean = Math.round(result.mean).toString(); - last = Math.round(result.last).toString(); - } - if (this.minText !== null) { - this.minText.textContent = "min: \u00A0" + min + this.unitName; - } - if (this.maxText !== null) { - this.maxText.textContent = "max: \u00A0" + max + this.unitName; - } - if (this.meanText !== null) { - this.meanText.textContent = "mean: " + mean + this.unitName; - } - if (this.lastText !== null) { - this.lastText.textContent = "last: " + last + this.unitName; - } - if (this.ctx !== null) { - this.ctx.fillStyle = "#010"; - this.ctx.fillRect(0, 0, MonitorGraphWidth, MonitorGraphHeight); - this.ctx.fillStyle = "#0f0"; - this.samples.each(function (v, i) { - _this.ctx.fillRect(i, MonitorGraphHeight, 1, -(v * scale)); - }); - } - }; - return MonitorWidget; - }(Widget)); - ((function (_super) { - __extends(CounterWidget, _super); - function CounterWidget(name, counter) { - var _this = _super.call(this, name) || this; - _this.counter = counter; - _this.text = document.createElement("div"); - _this.element.appendChild(_this.text); - return _this; - } - CounterWidget.prototype.sync = function () { - this.text.textContent = this.name + ": " + this.counter.value; - }; - return CounterWidget; - })(Widget)); - - var container = null; - /** - * Check that everything is properly initialized. - */ - function checkInit() { - if (!container) { - container = document.createElement("div"); - container.style.cssText = "position: fixed;" + - "opacity: 0.9;" + - "right: 0;" + - "bottom: 0"; - document.body.appendChild(container); - } - } - /** - * Start FPS monitor - */ - function startFPSMonitor(flags) { - if (flags === void 0) { flags = MonitorWidgetFlags.HideMin | MonitorWidgetFlags.HideMax | - MonitorWidgetFlags.HideMean | MonitorWidgetFlags.RoundValues; } - checkInit(); - var data = new MonitorSamples(MonitorMaxSamples); - var w = new MonitorWidget("FPS", flags, "", data); - container.appendChild(w.element); - var alpha = 2 / 121; - var last = 0; - var fps = 60; - function update(now) { - if (last > 0) { - fps += alpha * ((1000 / (now - last)) - fps); - } - last = now; - data.addSample(fps); - w.invalidate(); - requestAnimationFrame(update); - } - requestAnimationFrame(update); - } - /** - * Start Memory Monitor - */ - function startMemMonitor(flags) { - if (flags === void 0) { flags = MonitorWidgetFlags.HideMin | MonitorWidgetFlags.HideMean; } - checkInit(); - if (performance.memory === undefined) { - return; - } - var data = new MonitorSamples(MonitorMaxSamples); - var w = new MonitorWidget("Memory", flags, "MB", data); - container.appendChild(w.element); - function update() { - data.addSample(Math.round(performance.memory.usedJSHeapSize / (1024 * 1024))); - w.invalidate(); - setTimeout(update, 30); - } - update(); - } - - function colors(specifier) { - var n = specifier.length / 6 | 0, colors = new Array(n), i = 0; - while (i < n) colors[i] = "#" + specifier.slice(i * 6, ++i * 6); - return colors; - } - - function ramp(range) { - var n = range.length; - return function(t) { - return range[Math.max(0, Math.min(n - 1, Math.floor(t * n)))]; - }; - } - - var interpolateViridis = ramp(colors("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725")); - - ramp(colors("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")); - - ramp(colors("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")); - - ramp(colors("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921")); - - startFPSMonitor(); - startMemMonitor(); - - function map(arr, to) { - var out = []; - - for (var i = 0; i < arr.length; i++) { - out.push(to(arr[i])); - } - - return out; - } - - var Demo = /*#__PURE__*/function (_Component) { - _inheritsLoose(Demo, _Component); - - function Demo(props, context) { - var _this; - - _this = _Component.call(this, props, context) || this; - _this.state = { - numPoints: 0 - }; - _this.updateCount = _this.updateCount.bind(_assertThisInitialized(_this)); - return _this; - } - - var _proto = Demo.prototype; - - _proto.updateCount = function updateCount(e) { - this.setState({ - numPoints: e.target.value - }); - }; - - _proto.componentDidMount = function componentDidMount() { - this.setState({ - numPoints: 1000 - }); - }; - - _proto.render = function render(props, state) { - return createVNode(1, "div", "app-wrapper", [createComponentVNode(2, VizDemo, { - "count": state.numPoints - }, null, null), createVNode(1, "div", "controls", [createTextVNode("# Points"), createVNode(64, "input", null, null, 1, { - "type": "range", - "min": 10, - "max": 10000, - "value": state.numPoints, - "onInput": this.updateCount - }, null, null), state.numPoints], 0, null, null, null), createVNode(1, "div", "about", [createTextVNode("InfernoJS 1k Components Demo based on the Glimmer demo by "), createVNode(1, "a", null, "Michael Lange", 16, { - "href": "http://mlange.io", - "target": "_blank" - }, null, null), createTextVNode(".")], 4, null, null, null)], 4, null, null, null); - }; - - return Demo; - }(Component); - - var Layout = { - PHYLLOTAXIS: 0, - GRID: 1, - WAVE: 2, - SPIRAL: 3 - }; - var LAYOUT_ORDER = [Layout.PHYLLOTAXIS, Layout.SPIRAL, Layout.PHYLLOTAXIS, Layout.GRID, Layout.WAVE]; - - var VizDemo = /*#__PURE__*/function (_Component2) { - _inheritsLoose(VizDemo, _Component2); - - function VizDemo(props, context) { - var _this2; - - _this2 = _Component2.call(this, props, context) || this; - _this2.layout = 0; - _this2.phyllotaxis = genPhyllotaxis(100); - _this2.grid = genGrid(100); - _this2.wave = genWave(100); - _this2.spiral = genSpiral(100); - _this2.points = []; - _this2.step = 0; - _this2.numSteps = 60 * 2; - return _this2; - } - - var _proto2 = VizDemo.prototype; - - _proto2.next = function next() { - var _this3 = this; - - this.step = (this.step + 1) % this.numSteps; - - if (this.step === 0) { - this.layout = (this.layout + 1) % LAYOUT_ORDER.length; - } // Clamp the linear interpolation at 80% for a pause at each finished layout state - - - var pct = Math.min(1, this.step / (this.numSteps * 0.8)); - var currentLayout = LAYOUT_ORDER[this.layout]; - var nextLayout = LAYOUT_ORDER[(this.layout + 1) % LAYOUT_ORDER.length]; // Keep these redundant computations out of the loop - - var pxProp = xForLayout(currentLayout); - var nxProp = xForLayout(nextLayout); - var pyProp = yForLayout(currentLayout); - var nyProp = yForLayout(nextLayout); - this.points = this.points.map(function (point) { - var newPoint = _extends({}, point); - - newPoint.x = lerp(newPoint, pct, pxProp, nxProp); - newPoint.y = lerp(newPoint, pct, pyProp, nyProp); - return newPoint; - }); - this.setState(); - requestAnimationFrame(function () { - _this3.next(); - }); - }; - - _proto2.setAnchors = function setAnchors(arr) { - var _this4 = this; - - arr.map(function (p, index) { - var _project = project(_this4.grid(index)), - gx = _project[0], - gy = _project[1]; - - var _project2 = project(_this4.wave(index)), - wx = _project2[0], - wy = _project2[1]; - - var _project3 = project(_this4.spiral(index)), - sx = _project3[0], - sy = _project3[1]; - - var _project4 = project(_this4.phyllotaxis(index)), - px = _project4[0], - py = _project4[1]; - - Object.assign(p, { - gx: gx, - gy: gy, - wx: wx, - wy: wy, - sx: sx, - sy: sy, - px: px, - py: py - }); - }); - this.points = arr; - }; - - _proto2.makePoints = function makePoints(count) { - var newPoints = []; - - for (var i = 0; i < count; i++) { - newPoints.push({ - x: 0, - y: 0, - color: interpolateViridis(i / count) - }); - } - - this.setAnchors(newPoints); - }; - - _proto2.componentWillReceiveProps = function componentWillReceiveProps(props) { - if (props.count !== this.props.count) { - this.phyllotaxis = genPhyllotaxis(props.count); - this.grid = genGrid(props.count); - this.wave = genWave(props.count); - this.spiral = genSpiral(props.count); - this.makePoints(props.count); - } - }; - - _proto2.componentDidMount = function componentDidMount() { - this.next(); - }; - - _proto2.renderPoint = function renderPoint(point) { - return createComponentVNode(2, Point, { - "x": point.x, - "y": point.y, - "color": point.color - }, null, null); - }; - - _proto2.render = function render() { - return createVNode(32, "svg", "demo", createVNode(32, "g", null, map(this.points, this.renderPoint), 4, null, null, null), 2, null, null, null); - }; - - return VizDemo; - }(Component); - - function Point(_ref) { - var x = _ref.x, - y = _ref.y, - color = _ref.color; - return createVNode(32, "rect", "point", null, 1, { - "transform": "translate(" + Math.floor(x) + ", " + Math.floor(y) + ")", - "fill": color - }, null, null); - } - - var theta = Math.PI * (3 - Math.sqrt(5)); - - function xForLayout(layout) { - switch (layout) { - case Layout.PHYLLOTAXIS: - return 'px'; - - case Layout.GRID: - return 'gx'; - - case Layout.WAVE: - return 'wx'; - - case Layout.SPIRAL: - return 'sx'; - } - } - - function yForLayout(layout) { - switch (layout) { - case Layout.PHYLLOTAXIS: - return 'py'; - - case Layout.GRID: - return 'gy'; - - case Layout.WAVE: - return 'wy'; - - case Layout.SPIRAL: - return 'sy'; - } - } - - function lerp(obj, percent, startProp, endProp) { - var px = obj[startProp]; - return px + (obj[endProp] - px) * percent; - } - - function genPhyllotaxis(n) { - return function (i) { - var r = Math.sqrt(i / n); - var th = i * theta; - return [r * Math.cos(th), r * Math.sin(th)]; - }; - } - - function genGrid(n) { - var rowLength = Math.round(Math.sqrt(n)); - return function (i) { - return [-0.8 + 1.6 / rowLength * (i % rowLength), -0.8 + 1.6 / rowLength * Math.floor(i / rowLength)]; - }; - } - - function genWave(n) { - var xScale = 2 / (n - 1); - return function (i) { - var x = -1 + i * xScale; - return [x, Math.sin(x * Math.PI * 3) * 0.3]; - }; - } - - function genSpiral(n) { - return function (i) { - var t = Math.sqrt(i / (n - 1)), - phi = t * Math.PI * 10; - return [t * Math.cos(phi), t * Math.sin(phi)]; - }; - } - - function scale(magnitude, vector) { - return vector.map(function (p) { - return p * magnitude; - }); - } - - function translate(translation, vector) { - return vector.map(function (p, i) { - return p + translation[i]; - }); - } - - function project(vector) { - var wh = window.innerHeight / 2; - var ww = window.innerWidth / 2; - return translate([ww, wh], scale(Math.min(wh, ww), vector)); - } - - render(createComponentVNode(2, Demo, null, null, null), document.getElementById('app')); - -}()); +!function(){"use strict";function e(){return e=Object.assign||function(e){for(var n=1;n0,p=d(s),b=l(s)&&s[0]===L;h||p||b?(t=t||n.slice(0,o),(h||b)&&(u=R(u)),(p||b)&&(u.key=L+o),t.push(u)):t&&t.push(u),u.flags|=65536}}a=0===(t=t||n).length?1:8}else(t=n).flags|=65536,81920&n.flags&&(t=R(n)),a=2;return e.children=t,e.childFlags=a,e}function G(e){if(i(e)||r(e))return B(e,null);if(f(e))return O(e,0,null);return 16384&e.flags?R(e):e}var Q="http://www.w3.org/1999/xlink",X="http://www.w3.org/XML/1998/namespace",K={"xlink:actuate":Q,"xlink:arcrole":Q,"xlink:href":Q,"xlink:role":Q,"xlink:show":Q,"xlink:title":Q,"xlink:type":Q,"xml:base":X,"xml:lang":X,"xml:space":X};function z(e){return{onClick:e,onDblClick:e,onFocusIn:e,onFocusOut:e,onKeyDown:e,onKeyPress:e,onKeyUp:e,onMouseDown:e,onMouseMove:e,onMouseUp:e,onTouchEnd:e,onTouchMove:e,onTouchStart:e}}var J=z(0),Y=z(null),Z=z(!0);function ee(e,n){var t=n.$EV;return t||(t=n.$EV=z(null)),t[e]||1===++J[e]&&(Y[e]=ue(e)),t}function ne(e,n){var t=n.$EV;t&&t[e]&&(0===--J[e]&&(document.removeEventListener(p(e),Y[e]),Y[e]=null),t[e]=null)}function te(e,n,t,a){if(o(t))ee(e,a)[e]=t;else if(s(t)){if(T(n,t))return;ee(e,a)[e]=t}else ne(e,a)}function ae(e){return o(e.composedPath)?e.composedPath()[0]:e.target}function fe(e,n,t,a){var f=ae(e);do{if(n&&f.disabled)return;var r=f.$EV;if(r){var c=r[t];if(c&&(a.dom=f,c.event?c.event(c.data,e):c(e),e.cancelBubble))return}f=f.parentNode}while(!d(f))}function re(){this.cancelBubble=!0,this.immediatePropagationStopped||this.stopImmediatePropagation()}function ce(){return this.defaultPrevented}function ie(){return this.cancelBubble}function oe(e){var n={dom:document};return e.isDefaultPrevented=ce,e.isPropagationStopped=ie,e.stopPropagation=re,Object.defineProperty(e,"currentTarget",{configurable:!0,get:function(){return n.dom}}),n}function le(e){return function(n){if(0!==n.button)return void n.stopPropagation();fe(n,!0,e,oe(n))}}function de(e){return function(n){fe(n,!1,e,oe(n))}}function ue(e){var n="onClick"===e||"onDblClick"===e?le(e):de(e);return document.addEventListener(p(e),n),n}function se(e,n){var t=document.createElement("i");return t.innerHTML=n,t.innerHTML===e.innerHTML}function he(e,n,t){if(e[n]){var a=e[n];a.event?a.event(a.data,t):a(t)}else{var f=n.toLowerCase();e[f]&&e[f](t)}}function pe(e,n){var t=function(t){var a=this.$V;if(!a)return;var f=a.props||h,r=a.dom;if(l(e))he(f,e,t);else for(var c=0;c-1&&n.options[r]&&(i=n.options[r].value),t&&c(i)&&(i=e.defaultValue),ke(a,i)}}var Se,Fe,Te=pe("onInput",Le),Ue=pe("onChange");function Ne(e,n){be(e,"input",Te),n.onChange&&be(e,"change",Ue)}function Le(e,n,t){var a=e.value,f=n.value;if(c(a)){if(t){var r=e.defaultValue;c(r)||r===f||(n.defaultValue=r,n.value=r)}}else f!==a&&(n.defaultValue=a,n.value=a)}function Ve(e,n,t,a,f,r){64&e?$e(a,t):256&e?Pe(a,t,f,n):128&e&&Le(a,t,f),r&&(t.$V=n)}function _e(e,n,t){64&e?xe(n,t):256&e?Me(n):128&e&&Ne(n,t)}function Ie(e){return e.type&&ve(e.type)?!c(e.checked):!c(e.value)}function He(e){e&&!N(e,null)&&e.current&&(e.current=null)}function Ee(e,n,t){e&&(o(e)||void 0!==e.current)&&t.push((function(){N(e,n)||void 0===e.current||(e.current=n)}))}function Ae(e,n){Be(e),w(e,n)}function Be(e){var n,t=e.flags,a=e.children;if(481&t){n=e.ref;var f=e.props;He(n);var r=e.childFlags;if(!d(f))for(var i=Object.keys(f),l=0,u=i.length;l0;for(var i in c&&(r=Ie(t))&&_e(n,a,t),t)Qe(i,null,t[i],a,f,r,null);c&&Ve(n,e,a,t,!0,r)}function Ke(e,n,t){var a=G(e.render(n,e.state,t)),f=t;return o(e.getChildContext)&&(f=u(t,e.getChildContext())),e.$CX=f,a}function ze(e,n,t,a,f,r){var c=new n(t,a),i=c.$N=Boolean(n.getDerivedStateFromProps||c.getSnapshotBeforeUpdate);if(c.$SVG=f,c.$L=r,e.children=c,c.$BS=!1,c.context=a,c.props===h&&(c.props=t),i)c.state=M(c,t,c.state);else if(o(c.componentWillMount)){c.$BR=!0,c.componentWillMount();var l=c.$PS;if(!d(l)){var u=c.state;if(d(u))c.state=l;else for(var s in l)u[s]=l[s];c.$PS=null}c.$BR=!1}return c.$LI=Ke(c,t,a),c}function Je(e,n){var t=e.props||h;return 32768&e.flags?e.type.render(t,e.ref,n):e.type(t,n)}function Ye(e,n,t,a,f,r){var c=e.flags|=16384;481&c?tn(e,n,t,a,f,r):4&c?fn(e,n,t,a,f,r):8&c?(rn(e,n,t,a,f,r),dn(e,r)):512&c||16&c?nn(e,n,f):8192&c?en(e,t,n,a,f,r):1024&c&&Ze(e,t,n,f,r)}function Ze(e,n,t,a,f){Ye(e.children,e.ref,n,!1,null,f);var r=W();nn(r,t,a),e.dom=r.dom}function en(e,n,t,a,f,r){var c=e.children,i=e.childFlags;12&i&&0===c.length&&(i=e.childFlags=2,c=e.children=W()),2===i?Ye(c,t,f,a,f,r):an(c,t,n,a,f,r)}function nn(e,n,t){var a=e.dom=document.createTextNode(e.children);d(n)||v(n,a,t)}function tn(e,n,t,a,f,r){var i=e.flags,o=e.props,l=e.className,u=e.childFlags,s=e.dom=m(e.type,a=a||(32&i)>0),h=e.children;if(c(l)||""===l||(a?s.setAttribute("class",l):s.className=l),16===u)F(s,h);else if(1!==u){var p=a&&"foreignObject"!==e.type;2===u?(16384&h.flags&&(e.children=h=R(h)),Ye(h,s,t,p,null,r)):8!==u&&4!==u||an(h,s,t,p,null,r)}d(n)||v(n,s,f),d(o)||Xe(e,i,o,s,a),Ee(e.ref,s,r)}function an(e,n,t,a,f,r){for(var c=0;cs)&&(d=k(c[s-1],!1).nextSibling)}yn(o,l,c,i,t,a,f,d,e,r)}function vn(e,n,t,a){var f=e.ref,r=n.ref,c=n.children;if(yn(e.childFlags,n.childFlags,e.children,c,f,t,!1,null,e,a),n.dom=e.dom,f!==r&&!i(c)){var o=c.dom;y(f,o),b(r,o)}}function mn(e,n,t,a,f,r){var i,o=n.dom=e.dom,l=e.props,d=n.props,u=!1,s=!1;if(a=a||(32&f)>0,l!==d){var p=l||h;if((i=d||h)!==h)for(var b in(u=(448&f)>0)&&(s=Ie(i)),i){var v=p[b],m=i[b];v!==m&&Qe(b,v,m,o,a,s,e)}if(p!==h)for(var g in p)c(i[g])&&!c(p[g])&&Qe(g,p[g],null,o,a,s,e)}var y=n.children,x=n.className;e.className!==x&&(c(x)?o.removeAttribute("class"):a?o.setAttribute("class",x):o.className=x),4096&f?pn(o,y):yn(e.childFlags,n.childFlags,e.children,y,o,t,a&&"foreignObject"!==n.type,null,e,r),u&&Ve(f,n,o,i,!1,s);var $=n.ref,k=e.ref;k!==$&&(He(k),Ee($,o,r))}function gn(e,n,t,a,f,r){Be(e),an(n,t,a,f,k(e,!0),r),w(e,t)}function yn(e,n,t,a,f,r,c,i,o,l){switch(e){case 2:switch(n){case 2:sn(t,a,f,r,c,i,l);break;case 1:Ae(t,f);break;case 16:Be(t),F(f,a);break;default:gn(t,a,f,r,c,l)}break;case 1:switch(n){case 2:Ye(a,f,r,c,i,l);break;case 1:break;case 16:F(f,a);break;default:an(a,f,r,c,i,l)}break;case 16:switch(n){case 16:hn(t,a,f);break;case 2:De(f),Ye(a,f,r,c,i,l);break;case 1:De(f);break;default:De(f),an(a,f,r,c,i,l)}break;default:switch(n){case 16:Oe(t),F(f,a);break;case 2:Re(f,o,t),Ye(a,f,r,c,i,l);break;case 1:Re(f,o,t);break;default:var d=0|t.length,u=0|a.length;0===d?u>0&&an(a,f,r,c,i,l):0===u?Re(f,o,t):8===n&&8===e?Pn(t,a,f,r,c,d,u,i,o,l):Mn(t,a,f,r,c,d,u,i,l)}}}function xn(e,n,t,a,f){f.push((function(){e.componentDidUpdate(n,t,a)}))}function $n(e,n,t,a,f,r,c,i,l){var d=e.state,s=e.props,h=Boolean(e.$N),p=o(e.shouldComponentUpdate);if(h&&(n=M(e,t,n!==d?u(d,n):n)),c||!p||p&&e.shouldComponentUpdate(t,n,f)){!h&&o(e.componentWillUpdate)&&e.componentWillUpdate(t,n,f),e.props=t,e.state=n,e.context=f;var b=null,v=Ke(e,t,f);h&&o(e.getSnapshotBeforeUpdate)&&(b=e.getSnapshotBeforeUpdate(s,d)),sn(e.$LI,v,a,e.$CX,r,i,l),e.$LI=v,o(e.componentDidUpdate)&&xn(e,s,d,b,l)}else e.props=t,e.state=n,e.context=f}function kn(e,n,t,a,f,r,c){var i=n.children=e.children;if(d(i))return;i.$L=c;var l=n.props||h,s=n.ref,p=e.ref,b=i.state;if(!i.$N){if(o(i.componentWillReceiveProps)){if(i.$BR=!0,i.componentWillReceiveProps(l,a),i.$UN)return;i.$BR=!1}d(i.$PS)||(b=u(b,i.$PS),i.$PS=null)}$n(i,b,l,t,a,f,!1,r,c),p!==s&&(He(p),Ee(s,i,c))}function wn(e,n,t,a,f,r,i){var l=!0,d=n.props||h,u=n.ref,s=e.props,p=!c(u),b=e.children;if(p&&o(u.onComponentShouldUpdate)&&(l=u.onComponentShouldUpdate(s,d)),!1!==l){p&&o(u.onComponentWillUpdate)&&u.onComponentWillUpdate(s,d);var v=G(Je(n,a));sn(b,v,t,a,f,r,i),n.children=v,p&&o(u.onComponentDidUpdate)&&u.onComponentDidUpdate(s,d)}else n.children=b}function Cn(e,n){var t=n.children,a=n.dom=e.dom;t!==e.children&&(a.nodeValue=t)}function Mn(e,n,t,a,f,r,c,i,o){for(var l,d,u=r>c?c:r,s=0;sc)for(s=u;ss||p>h)break e;b=e[p],v=n[p]}for(b=e[s],v=n[h];b.key===v.key;){if(16384&v.flags&&(n[h]=v=R(v)),sn(b,v,t,a,f,i,l),e[s]=v,h--,p>--s||p>h)break e;b=e[s],v=n[h]}}if(p>s){if(p<=h)for(u=(d=h+1)h)for(;p<=s;)Ae(e[p++],t);else Sn(e,n,a,r,c,s,h,p,t,f,i,o,l)}function Sn(e,n,t,a,f,r,c,i,o,l,d,u,s){var h,p,b,v=0,m=i,g=i,y=r-i+1,x=c-i+1,$=new Int32Array(x+1),w=y===a,M=!1,P=0,S=0;if(f<4||(y|x)<32)for(v=m;v<=r;++v)if(h=e[v],Si?M=!0:P=i,16384&p.flags&&(n[i]=p=R(p)),sn(h,p,o,t,l,d,s),++S;break}!w&&i>c&&Ae(h,o)}else w||Ae(h,o);else{var F={};for(v=g;v<=c;++v)F[n[v].key]=v;for(v=m;v<=r;++v)if(h=e[v],Sm;)Ae(e[m++],o);$[i-g]=v+1,P>i?M=!0:P=i,16384&(p=n[i]).flags&&(n[i]=p=R(p)),sn(h,p,o,t,l,d,s),++S}else w||Ae(h,o);else w||Ae(h,o)}if(w)Re(o,u,e),an(n,o,t,l,d,s);else if(M){var T=Tn($);for(i=T.length-1,v=x-1;v>=0;v--)0===$[v]?(16384&(p=n[P=v+g]).flags&&(n[P]=p=R(p)),Ye(p,o,t,l,(b=P+1)=0;v--)0===$[v]&&(16384&(p=n[P=v+g]).flags&&(n[P]=p=R(p)),Ye(p,o,t,l,(b=P+1)Fn&&(Fn=o,Se=new Int32Array(o),Fe=new Int32Array(o));t>1]]0&&(Fe[t]=Se[r-1]),Se[r]=t)}r=f+1;var l=new Int32Array(r);for(c=Se[r-1];r-- >0;)l[r]=c,c=Fe[c],Se[r]=0;return l}"undefined"!==typeof document&&window.Node&&(Node.prototype.$EV=null,Node.prototype.$V=null);var Un=[],Nn="undefined"!==typeof Promise?Promise.resolve().then.bind(Promise.resolve()):function(e){window.setTimeout(e,0)},Ln=!1;function Vn(e,n,t,a){var f=e.$PS;if(o(n)&&(n=n(f?u(e.state,f):e.state,e.props,e.context)),c(f))e.$PS=n;else for(var r in n)f[r]=n[r];if(e.$BR)o(t)&&e.$L.push(t.bind(e));else{if(!P.v&&0===Un.length)return Hn(e,a),void(o(t)&&t.call(e));if(-1===Un.indexOf(e)&&Un.push(e),a&&(e.$F=!0),Ln||(Ln=!0,Nn(In)),o(t)){var i=e.$QU;i||(i=e.$QU=[]),i.push(t)}}}function _n(e){for(var n=e.$QU,t=0;tt&&(t=r),a+=r}var c=e[this._i],i=a/e.length;return new On(n,t,i,c)},e}(),Rn=[],Wn=-1,jn=(An=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var t in n)n.hasOwnProperty(t)&&(e[t]=n[t])},function(e,n){function t(){this.constructor=e}An(e,n),e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)}),qn=function(){function e(e){var n=this;this._sync=function(){n.sync(),n._dirty=!1},this.name=e,this.element=document.createElement("div"),this.element.style.cssText="padding: 2px;background-color: #020;font-family: monospace;font-size: 12px;color: #0f0",this._dirty=!1,this.invalidate()}return e.prototype.invalidate=function(){var e;this._dirty||(this._dirty=!0,e=this._sync,Rn.push(e),-1===Wn&&requestAnimationFrame((function(e){Wn=-1;var n=Rn;Rn=[];for(var t=0;t0&&(f+=.01652892561983471*(1e3/(r-a)-f)),a=r,n.addSample(f),t.invalidate(),requestAnimationFrame(e)}))}(),function(e){if(void 0===e&&(e=Bn.HideMin|Bn.HideMean),Xn(),void 0===performance.memory)return;var n=new Dn(100),t=new Gn("Memory",e,"MB",n);Qn.appendChild(t.element),function e(){n.addSample(Math.round(performance.memory.usedJSHeapSize/1048576)),t.invalidate(),setTimeout(e,30)}()}();var Zn=function(e){function t(n,t){var f;return(f=e.call(this,n,t)||this).state={numPoints:0},f.updateCount=f.updateCount.bind(a(f)),f}n(t,e);var f=t.prototype;return f.updateCount=function(e){this.setState({numPoints:e.target.value})},f.componentDidMount=function(){this.setState({numPoints:1e3})},f.render=function(e,n){return _(1,"div","app-wrapper",[A(2,nt,{count:n.numPoints},null,null),_(1,"div","controls",[B("# Points"),_(64,"input",null,null,1,{type:"range",min:10,max:1e4,value:n.numPoints,onInput:this.updateCount},null,null),n.numPoints],0,null,null,null),_(1,"div","about",[B("InfernoJS 1k Components Demo based on the Glimmer demo by "),_(1,"a",null,"Michael Lange",16,{href:"http://mlange.io",target:"_blank"},null,null),B(".")],4,null,null,null)],4,null,null,null)},t}(En),et=[0,3,0,1,2],nt=function(t){function a(e,n){var a;return(a=t.call(this,e,n)||this).layout=0,a.phyllotaxis=ut(100),a.grid=st(100),a.wave=ht(100),a.spiral=pt(100),a.points=[],a.step=0,a.numSteps=120,a}n(a,t);var f=a.prototype;return f.next=function(){var n=this;this.step=(this.step+1)%this.numSteps,0===this.step&&(this.layout=(this.layout+1)%et.length);var t=Math.min(1,this.step/(.8*this.numSteps)),a=et[this.layout],f=et[(this.layout+1)%et.length],r=ot(a),c=ot(f),i=lt(a),o=lt(f);this.points=this.points.map((function(n){var a=e({},n);return a.x=dt(a,t,r,c),a.y=dt(a,t,i,o),a})),this.setState(),requestAnimationFrame((function(){n.next()}))},f.setAnchors=function(e){var n=this;e.map((function(e,t){var a=mt(n.grid(t)),f=a[0],r=a[1],c=mt(n.wave(t)),i=c[0],o=c[1],l=mt(n.spiral(t)),d=l[0],u=l[1],s=mt(n.phyllotaxis(t)),h=s[0],p=s[1];Object.assign(e,{gx:f,gy:r,wx:i,wy:o,sx:d,sy:u,px:h,py:p})})),this.points=e},f.makePoints=function(e){for(var n=[],t=0;t animates height and opacity on add. The image and body of each card animates using the card animation CSS-classes but with different transitions. The card inherits AnimatedComponet which is only aware of the card animation. The child animations need to be finished when the card animations are finished.' - }), container_1); - }); - })(); - -}()); +!function(){"use strict";function t(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,e(t,n)}function e(t,n){return e=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},e(t,n)}!function(){var e=Inferno.Component,n=Inferno.createElement,i=Inferno.Animation,o=i.AnimatedComponent;i.componentDidAppear,i.componentWillDisappear;var r=i.utils;r.addClassName,r.removeClassName,r.forceReflow,r.registerTransitionListener;var a=function(e){function i(){return e.apply(this,arguments)||this}return t(i,e),i.prototype.render=function(){var t=this;return n("li",{className:"item",onClick:function(e){return t.props.onClick(e,t.props.index)}},n("div",{className:"inner"},[n("img",{width:"120px",height:"120px",src:"avatar.png"}),n("div",{className:"body"},[n("h2",null,this.props.children),n("h3",null,"Inferno is a blazingly fast framework.")])]))},i}(o),s=function(e){function i(){var t;return(t=e.call(this)||this).doRemove=function(e,n){e.preventDefault();var i=t.state.items.concat([]);i.splice(n,1),t.setState({items:i})},t.doAdd=function(e){e.preventDefault();var n=t.state.items.concat([]),i=0===n.length?0:n[n.length-1].key+1;n.push({key:i}),t.setState({items:n})},t.renderItem=function(e,i){return n(a,{key:e.key,index:i,animation:t.props.animation,onClick:t.doRemove},"This line is nice with "+(e.key+1)+" bar")},t.state={items:[]},t.items=[],t}t(i,e);var o=i.prototype;return o.componentDidMount=function(){for(var t=0;this.items.length<20;)this.items[this.items.length]={key:t++};this.setState({items:this.items})},o.render=function(){return n("div",null,[n("ul",null,this.state.items.map(this.renderItem)),n("h2",null,this.props.animation),n("p",null,this.props.description),n("button",{onClick:this.doAdd},"Add")])},i}(e);document.addEventListener("DOMContentLoaded",(function(){var t=document.querySelector("#App1");Inferno.render(n(s,{animation:"Complex",description:"Each card
  • animates height and opacity on add. The image and body of each card animates using the card animation CSS-classes but with different transitions. The card inherits AnimatedComponet which is only aware of the card animation. The child animations need to be finished when the card animations are finished."}),t)}))}()}(); diff --git a/docs/animations/dist/bundle.js b/docs/animations/dist/bundle.js index 5cf6d4475..9e4a94d74 100644 --- a/docs/animations/dist/bundle.js +++ b/docs/animations/dist/bundle.js @@ -1,1031 +1 @@ -(function () { - 'use strict'; - - function _extends() { - _extends = Object.assign || function (target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i]; - - for (var key in source) { - if (Object.prototype.hasOwnProperty.call(source, key)) { - target[key] = source[key]; - } - } - } - - return target; - }; - - return _extends.apply(this, arguments); - } - - function _inheritsLoose(subClass, superClass) { - subClass.prototype = Object.create(superClass.prototype); - subClass.prototype.constructor = subClass; - - _setPrototypeOf(subClass, superClass); - } - - function _setPrototypeOf(o, p) { - _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { - o.__proto__ = p; - return o; - }; - - return _setPrototypeOf(o, p); - } - - function _objectWithoutPropertiesLoose(source, excluded) { - if (source == null) return {}; - var target = {}; - var sourceKeys = Object.keys(source); - var key, i; - - for (i = 0; i < sourceKeys.length; i++) { - key = sourceKeys[i]; - if (excluded.indexOf(key) >= 0) continue; - target[key] = source[key]; - } - - return target; - } - - var _excluded = ["children"], - _excluded2 = ["children"], - _excluded3 = ["children"]; - - (function () { - - var Component = Inferno.Component; - var createElement = Inferno.createElement; - var InfernoAnimation = Inferno.Animation; - var AnimatedComponent = InfernoAnimation.AnimatedComponent, - AnimatedMoveComponent = InfernoAnimation.AnimatedMoveComponent, - componentDidAppear = InfernoAnimation.componentDidAppear, - componentWillDisappear = InfernoAnimation.componentWillDisappear, - componentWillMove = InfernoAnimation.componentWillMove; - var _InfernoAnimation$uti = InfernoAnimation.utils, - addClassName = _InfernoAnimation$uti.addClassName, - removeClassName = _InfernoAnimation$uti.removeClassName, - forceReflow = _InfernoAnimation$uti.forceReflow, - registerTransitionListener = _InfernoAnimation$uti.registerTransitionListener; - var anim = { - onComponentDidAppear: componentDidAppear, - onComponentWillDisappear: componentWillDisappear - }; - var animMove = { - onComponentWillMove: componentWillMove - }; - - var ListItem = /*#__PURE__*/function (_AnimatedComponent) { - _inheritsLoose(ListItem, _AnimatedComponent); - - function ListItem() { - return _AnimatedComponent.apply(this, arguments) || this; - } - - var _proto = ListItem.prototype; - - _proto.render = function render() { - var _this = this; - return createElement('li', { - onClick: function onClick(e) { - return _this.props.onClick(e, _this.props.index); - } - }, this.props.children); - }; - - return ListItem; - }(AnimatedComponent); - - var SectionItem = /*#__PURE__*/function (_AnimatedComponent2) { - _inheritsLoose(SectionItem, _AnimatedComponent2); - - function SectionItem() { - return _AnimatedComponent2.apply(this, arguments) || this; - } - - var _proto2 = SectionItem.prototype; - - _proto2.render = function render() { - var _this2 = this; - return createElement('section', { - onClick: function onClick(e) { - return _this2.props.onClick(e, _this2.props.index); - } - }, this.props.children); - }; - - return SectionItem; - }(AnimatedComponent); - - var FuncListItem = function FuncListItem(_ref) { - var children = _ref.children, - props = _objectWithoutPropertiesLoose(_ref, _excluded); - return createElement('li', { - onClick: function onClick(e) { - return props.onClick(e, props.index); - } - }, children); - }; - - var FuncSectionItem = function FuncSectionItem(_ref2) { - var children = _ref2.children, - props = _objectWithoutPropertiesLoose(_ref2, _excluded2); - return createElement('section', { - onClick: function onClick(e) { - return props.onClick(e, props.index); - } - }, children); - }; - - var ListItemMoveAnim = /*#__PURE__*/function (_AnimatedMoveComponen) { - _inheritsLoose(ListItemMoveAnim, _AnimatedMoveComponen); - - function ListItemMoveAnim() { - return _AnimatedMoveComponen.apply(this, arguments) || this; - } - - var _proto3 = ListItemMoveAnim.prototype; - - _proto3.render = function render() { - var _this3 = this; - return createElement('li', { - onClick: function onClick(e) { - return _this3.props.onClick(e, _this3.props.index); - } - }, this.props.children); - }; - - return ListItemMoveAnim; - }(AnimatedMoveComponent); - - var FuncListItemMoveAnim = function FuncListItemMoveAnim(_ref3) { - var children = _ref3.children, - props = _objectWithoutPropertiesLoose(_ref3, _excluded3); - return createElement('li', { - onClick: function onClick(e) { - return props.onClick(e, props.index); - } - }, children); - }; - - var List = /*#__PURE__*/function (_Component) { - _inheritsLoose(List, _Component); - - function List() { - var _this4; - - _this4 = _Component.call(this) || this; - - _this4.doRemove = function (e, index) { - e.preventDefault(); - - var newItems = _this4.state.items.concat([]); - - newItems.splice(index, 1); - - _this4.setState({ - items: newItems - }); - }; - - _this4.doAdd = function (e) { - e.preventDefault(); - - var newItems = _this4.state.items.concat([]); - - var nextKey = newItems.length === 0 ? 0 : newItems[newItems.length - 1].key + 1; - newItems.push({ - key: nextKey - }); - - _this4.setState({ - items: newItems - }); - }; - - _this4.doRemove20 = function (e) { - e.preventDefault(); - - var newItems = _this4.state.items.concat([]); - - newItems.splice(newItems.length >= 20 ? newItems.length - 20 : 0, newItems.length >= 20 ? 20 : newItems.length); - - _this4.setState({ - items: newItems - }); - }; - - _this4.doAdd20 = function (e) { - e.preventDefault(); - - var newItems = _this4.state.items.concat([]); - - var nextKey = newItems.length === 0 ? 0 : newItems[newItems.length - 1].key + 1; - - for (var i = 0; i < 20; i++) { - newItems.push({ - key: nextKey + i - }); - } - - _this4.setState({ - items: newItems - }); - }; - - _this4.renderItem = function (item, i) { - if (_this4.props.useFunctionalComponent) { - return createElement(FuncListItem, _extends({ - key: item.key, - index: i, - animation: _this4.props.animation - }, anim, { - onClick: _this4.doRemove - }), item.key + 1 + "bar"); - } else { - return createElement(ListItem, { - key: item.key, - index: i, - animation: _this4.props.animation, - onClick: _this4.doRemove - }, item.key + 1 + "bar"); - } - }; - - _this4.state = { - items: [] - }; - _this4.items = []; - return _this4; - } - - var _proto4 = List.prototype; - - _proto4.componentDidMount = function componentDidMount() { - var i = 0; - - while (this.items.length < 20) { - this.items[this.items.length] = { - key: i++ - }; - } - - this.setState({ - items: this.items - }); - }; - - _proto4.render = function render() { - return createElement('div', null, [createElement('ul', null, this.state.items.map(this.renderItem)), createElement('h2', null, this.props.animation), createElement('p', null, this.props.description), createElement('button', { - onClick: this.doAdd - }, 'Add'), createElement('button', { - onClick: this.doAdd20 - }, 'Add 20'), createElement('button', { - onClick: this.doRemove20 - }, 'Remove 20')]); - }; - - return List; - }(Component); - - var MixedList = /*#__PURE__*/function (_Component2) { - _inheritsLoose(MixedList, _Component2); - - function MixedList() { - var _this5; - - _this5 = _Component2.call(this) || this; - - _this5.componentDidAppear = function (dom) { - var animCls = { - 'start': 'fade-enter', - 'active': 'fade-enter-active', - 'end': 'fade-enter-end' - }; // 1. Set animation start state - - addClassName(dom, animCls.start); - forceReflow(); // 2. Activate transition - - addClassName(dom, animCls.active); // 3. Set an animation listener, code at end - // Needs to be done after activating so timeout is calculated correctly - - registerTransitionListener([dom], function () { - // *** Cleanup *** - // 5. Remove the element - removeClassName(dom, animCls.active); - removeClassName(dom, animCls.end); - }); // 4. Activate target state - - requestAnimationFrame(function () { - removeClassName(dom, animCls.start); - addClassName(dom, animCls.end); - }); - }; - - _this5.componentWillDisappear = function (dom, callback) { - var animCls = { - 'start': 'fade-leave', - 'active': 'fade-leave-active', - 'end': 'fade-leave-end' - }; // 1. Set animation start state - - addClassName(dom, animCls.start); // 2. Activate transitions - - addClassName(dom, animCls.active); // 3. Set an animation listener, code at end - // Needs to be done after activating so timeout is calculated correctly - - registerTransitionListener([dom], function () { - // *** Cleanup *** - // Simulate some work is being done - // setTimeout(function () { - // callback(); - // }, 1000); - callback(); - }); // 4. Activate target state - - requestAnimationFrame(function () { - addClassName(dom, animCls.end); - removeClassName(dom, animCls.start); - }); - }; - - _this5.doRemove = function (e, index) { - e.preventDefault(); - - var newItems = _this5.state.items.concat([]); - - newItems.splice(index, 1); - - _this5.setState({ - items: newItems - }); - }; - - _this5.doRemoveSpecial = function (e) { - e.preventDefault(); // Remove random ListItem and trigger animation - - var onlyListItems = _this5.state.items.filter(function (item) { - return item.isListItem; - }); - - var toDeleteIndex = parseInt(Math.round(Math.random() * (onlyListItems.length - 1))); - var toDeleteKey = onlyListItems[toDeleteIndex].key; - - var newItems = _this5.state.items.filter(function (item) { - return item.key !== toDeleteKey; - }); - - _this5.setState({ - items: newItems - }); // Remove random divider during animation - // NOTE! If the divider is the last element, it will cause everything to be removed, - // thus cutting the running animation short. This is expected behaviour because we don't - // check if the parent has an animating child. Opportunity for improvement. - - - setTimeout(function () { - var onlyDividers = _this5.state.items.filter(function (item) { - return !item.isListItem; - }); - - var toDeleteIndex = parseInt(Math.round(Math.random() * (onlyDividers.length - 1))); - var counter = 0; - - var newItems = _this5.state.items.filter(function (item) { - return item.isListItem || counter++ !== toDeleteIndex; - }); - - _this5.setState({ - items: newItems - }); - }, 100); - }; - - _this5.doAdd = function (e) { - e.preventDefault(); - - var newItems = _this5.state.items.concat([]); - - var nextKey = newItems.reduce(function (prev, curr) { - return curr.key > prev ? curr.key : prev; - }, 0) + 1; - newItems.push({ - key: nextKey, - isListItem: true - }); - newItems.push({ - key: nextKey + 1 - }); - - _this5.setState({ - items: newItems - }); - }; - - _this5.renderItem = function (item, i) { - if (_this5.props.useFunctionalComponent) { - return createElement(FuncSectionItem, _extends({ - key: item.key, - index: i, - animation: _this5.props.animation - }, anim, { - onClick: _this5.doRemove - }), item.key + 1 + "bar"); - } else { - return createElement(SectionItem, { - key: item.key, - index: i, - animation: _this5.props.animation, - onClick: _this5.doRemove - }, item.key + 1 + "bar"); - } - }; - - var _i = 0; - var items = []; - - while (items.length < 40) { - items[items.length] = { - key: _i++, - isListItem: true - }; - items[items.length] = { - key: _i++ - }; - } - - _this5.state = { - items: items - }; - return _this5; - } - - var _proto5 = MixedList.prototype; - - _proto5.render = function render() { - var _this6 = this; - - // Mixing
    and instead of using
  • for all to trigger special code path in Inferno - return createElement('div', null, [createElement('article', null, this.state.items.map(function (item, i) { - return item.isListItem ? _this6.renderItem(item, i) : createElement('span', { - className: 'divider' - }); - })), createElement('h2', null, 'Mixed list'), createElement('p', null, this.props.description), createElement('button', { - onClick: this.doAdd - }, 'Add'), createElement('button', { - onClick: this.doRemoveSpecial - }, 'Remove')]); - }; - - return MixedList; - }(Component); - - var ShuffleList = /*#__PURE__*/function (_Component3) { - _inheritsLoose(ShuffleList, _Component3); - - function ShuffleList() { - var _this7; - - _this7 = _Component3.call(this) || this; // set initial time: - - _this7.doRemove = function (e, index) { - e && e.preventDefault(); - - var newItems = _this7.state.items.concat([]); - - newItems.splice(index, 1); - - _this7.setState({ - items: newItems - }); - }; - - _this7.doAdd = function (e) { - e && e.preventDefault(); - - var newItems = _this7.state.items.concat([]); - - var nextKey = newItems.reduce(function (prev, curr) { - return curr.key > prev ? curr.key : prev; - }, 0) + 1; - newItems.push({ - key: nextKey, - val: nextKey - }); - - _this7.setState({ - items: newItems - }); - }; - - _this7.doMix = function (e) { - e && e.preventDefault(); - - var newItems = _this7.state.items.concat([]); - - shuffle(newItems); - - _this7.setState({ - items: newItems - }); - }; - - _this7.doReassignKeys = function (e) { - e && e.preventDefault(); - - var tmpItems = _this7.state.items.concat([]); - - shuffle(tmpItems); - - var newItems = _this7.state.items.map(function (item, index) { - return Object.assign({}, item, { - key: tmpItems[index].key - }); - }); - - _this7.setState({ - items: newItems - }); - }; - - _this7.doRemoveMix = function (e) { - e && e.preventDefault(); - - if (_this7.state.items.length === 0) { - return; - } // Remove random ListItem and trigger animation - - - var toDeleteIndex = parseInt(Math.round(Math.random() * (_this7.state.items.length - 1))); - var toDeleteKey = _this7.state.items[toDeleteIndex].key; - - var newItems = _this7.state.items.filter(function (item) { - return item.key !== toDeleteKey; - }); - - _this7.setState({ - items: newItems, - deleted: toDeleteKey + 1 - }); - - setTimeout(function () { - return _this7.doMix(e); - }, 100); - }; - - _this7.removeAndShuffle = function (e) { - e && e.preventDefault(); - - for (var i = 0; i < 20; i++) { - setTimeout(function () { - var toDeleteIndex = parseInt(Math.round(Math.random() * (_this7.state.items.length - 1))); - - _this7.doRemove(undefined, toDeleteIndex); - - _this7.doReassignKeys(); - - _this7.doMix(); - }); - } - }; - - _this7.doAdd20 = function (e) { - e && e.preventDefault(); // Add data - - for (var i = 0; i < 20; i++) { - _this7.doAdd(); - } // Shuffle them - - - for (var _i2 = 0; _i2 < 5; _i2++) { - _this7.doReassignKeys(); - - _this7.doMix(); - } - }; - - _this7.doAdd20SeqMix = function (e) { - e && e.preventDefault(); // Add data - - for (var i = 0; i < 20; i++) { - _this7.doAdd(); - } // Shuffle them - - - for (var _i3 = 0; _i3 < 5; _i3++) { - setTimeout(function () { - // this.doReassignKeys(e); - _this7.doMix(); - }, 500 + 100 * _i3); - } - }; - - _this7.renderItem = function (item, i) { - if (_this7.props.useFunctionalComponent) { - return createElement(FuncListItem, _extends({ - key: item.key, - index: i, - animation: _this7.props.animation - }, anim, { - onClick: _this7.doRemove - }), item.val + "bar (" + item.key + ")"); - } else { - return createElement(ListItem, { - key: item.key, - index: i, - animation: _this7.props.animation, - onClick: _this7.doRemove - }, item.val + "bar (" + item.key + ")"); - } - }; - - _this7.state = { - items: [] - }; - _this7.items = []; - return _this7; - } - - var _proto6 = ShuffleList.prototype; - - _proto6.componentDidMount = function componentDidMount() { - var i = 0; - - while (this.items.length < 20) { - this.items[this.items.length] = { - key: i, - val: i - }; - i++; - } - - this.setState({ - items: this.items - }); - }; - - _proto6.render = function render() { - return createElement('div', null, [createElement('ul', null, this.state.items.map(this.renderItem)), createElement('h2', null, 'Shuffle'), createElement('p', null, this.props.description), createElement('button', { - onClick: this.doAdd - }, 'Add'), createElement('button', { - onClick: this.doMix - }, 'Shuffle'), createElement('button', { - onClick: this.doReassignKeys - }, 'Shuffle keys'), createElement('button', { - onClick: this.doRemoveMix - }, 'Remove' + (this.state.deleted ? " (" + this.state.deleted + ")" : '')), createElement('button', { - onClick: this.doAdd20 - }, 'Add and shuffle 20'), createElement('button', { - onClick: this.doAdd20SeqMix - }, 'Add 20 do 5 shuffle'), createElement('button', { - onClick: this.removeAndShuffle - }, 'Remove and shuffle 20')]); - }; - - return ShuffleList; - }(Component); // https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array - - - var shuffle = function shuffle(array) { - var currentIndex = array.length, - temporaryValue, - randomIndex; // While there remain elements to shuffle... - - while (0 !== currentIndex) { - // Pick a remaining element... - randomIndex = Math.floor(Math.random() * currentIndex); - currentIndex -= 1; // And swap it with the current element. - - temporaryValue = array[currentIndex]; - array[currentIndex] = array[randomIndex]; - array[randomIndex] = temporaryValue; - } - - return array; - }; - - var RerenderList = /*#__PURE__*/function (_Component4) { - _inheritsLoose(RerenderList, _Component4); - - function RerenderList() { - var _this8; - - _this8 = _Component4.call(this) || this; // set initial time: - - _this8.doRemove = function (e, index) { - e.preventDefault(); - - var newItems = _this8.state.items.concat([]); - - newItems.splice(index, 1); - - _this8.setState({ - items: newItems - }); - }; - - _this8.doAdd = function (e) { - e.preventDefault(); - - var newItems = _this8.state.items.concat([]); - - var nextKey = newItems.reduce(function (prev, curr) { - return curr.key > prev ? curr.key : prev; - }, 0) + 1; - newItems.push({ - key: nextKey, - val: nextKey - }); - - _this8.setState({ - items: newItems - }); - }; - - _this8.renderItem = function (item, i) { - if (_this8.props.useFunctionalComponent) { - return createElement(FuncListItem, _extends({ - key: item.key, - index: i, - animation: _this8.props.animation - }, anim, { - onClick: _this8.doRemove - }), item.val + "bar (" + item.key + ")"); - } else { - return createElement(ListItem, { - key: item.key, - index: i, - animation: _this8.props.animation, - onClick: _this8.doRemove - }, item.val + "bar (" + item.key + ")"); - } - }; - - _this8.state = { - items: [] - }; - _this8.items = []; - return _this8; - } - - var _proto7 = RerenderList.prototype; - - _proto7.componentDidMount = function componentDidMount() { - this.componentWillReceiveProps(this.props); - }; - - _proto7.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { - var i = 0; - - while (this.items.length < nextProps.items) { - this.items[this.items.length] = { - key: i, - val: i - }; - i++; - } - - this.setState({ - items: this.items - }); - }; - - _proto7.render = function render() { - return createElement('div', null, [createElement('ul', null, this.state.items.map(this.renderItem)), createElement('h2', null, 'patchKeyedChildren'), createElement('p', null, this.props.description), createElement('button', { - onClick: this.doAdd - }, 'Add')]); - }; - - return RerenderList; - }(Component); - - var ShuffleListWithAnimation = /*#__PURE__*/function (_Component5) { - _inheritsLoose(ShuffleListWithAnimation, _Component5); - - function ShuffleListWithAnimation() { - var _this9; - - _this9 = _Component5.call(this) || this; // set initial time: - - _this9.doMove = function (e, index) { - e && e.preventDefault(); - - var newItems = _this9.state.items.concat([]); - - var _newItems$splice = newItems.splice(index, 1), - tmp = _newItems$splice[0]; - - newItems.splice(Math.round(Math.random() * newItems.length), 0, tmp); - - _this9.setState({ - items: newItems - }); - }; - - _this9.doAdd = function (e) { - e && e.preventDefault(); - - var newItems = _this9.state.items.concat([]); - - var nextKey = newItems.reduce(function (prev, curr) { - return curr.key > prev ? curr.key : prev; - }, 0) + 1; - newItems.push({ - key: nextKey, - val: nextKey - }); - - _this9.setState({ - items: newItems - }); - }; - - _this9.doMix = function (e) { - e && e.preventDefault(); - - var newItems = _this9.state.items.concat([]); - - shuffle(newItems); // So this is the shuffled order - - console.log('Expected order: ' + newItems.map(function (el) { - return '(' + el.val + ')'; - }).join(',')); - - _this9.setState({ - items: newItems - }); // And this is what the DOM looks like - - - setTimeout(function () { - var res = document.querySelector('#App6 ul').textContent.match(/\(\d*\)/g); - console.log('Actual order: ' + res.join(',')); - }, 100); - }; - - _this9.doDoubleMix = function (e) { - e && e.preventDefault(); - - var newItems = _this9.state.items.concat([]); - - shuffle(newItems); // So this is the shuffled order - - console.log('Expected order 1: ' + newItems.map(function (el) { - return '(' + el.val + ')'; - }).join(',')); - - _this9.setState({ - items: newItems - }); - - setTimeout(function () { - var newItems2 = newItems.concat([]); - shuffle(newItems2); - - _this9.setState({ - items: newItems2 - }); - - console.log('Expected order 2: ' + newItems2.map(function (el) { - return '(' + el.val + ')'; - }).join(',')); - }, 1); // And this is what the DOM looks like - - setTimeout(function () { - var res = document.querySelector('#App6 ul').textContent.match(/\(\d*\)/g); - console.log('Actual order: ' + res.join(',')); - }, 100); - }; - - _this9.doMoveOne = function (e) { - e && e.preventDefault(); - - var newItems = _this9.state.items.concat([]); - - newItems.push(newItems.shift()); - - _this9.setState({ - items: newItems - }); - }; - - _this9.doClearMarkers = function (e) { - e && e.preventDefault(); - var tmp = document.querySelectorAll('.debugMarker'); - tmp.forEach(function (marker) { - marker.parentNode.removeChild(marker); - }); - }; - - _this9.renderItem = function (item, i) { - if (_this9.props.useFunctionalComponent) { - return createElement(FuncListItemMoveAnim, _extends({ - key: item.key, - index: i, - animation: _this9.props.animation - }, animMove, { - onClick: _this9.doMove - }), item.val + "bar (" + item.key + ")"); - } else { - return createElement(ListItemMoveAnim, { - key: item.key, - index: i, - animation: _this9.props.animation, - onClick: _this9.doMove - }, item.val + "bar (" + item.key + ")"); - } - }; - - _this9.state = { - items: [] - }; - _this9.items = []; - return _this9; - } - - var _proto8 = ShuffleListWithAnimation.prototype; - - _proto8.componentDidMount = function componentDidMount() { - var i = 0; - - while (this.items.length < 5) { - this.items[this.items.length] = { - key: i, - val: i - }; - i++; - } - - this.setState({ - items: this.items - }); - }; - - _proto8.render = function render() { - return createElement('div', null, [createElement('ul', null, this.state.items.map(this.renderItem)), createElement('h2', null, 'Shuffle w. Anim'), createElement('p', null, this.props.description), createElement('button', { - onClick: this.doAdd - }, 'Add'), createElement('button', { - onClick: this.doMix - }, 'Shuffle'), createElement('button', { - onClick: this.doDoubleMix - }, 'DoubleShuffle'), createElement('button', { - onClick: this.doMoveOne - }, 'Move 1'), createElement('button', { - onClick: this.doRemoveMix - }, 'Remove' + (this.state.deleted ? " (" + this.state.deleted + ")" : '')), createElement('button', { - onClick: this.doClearMarkers - }, 'Clear debug markers')]); - }; - - return ShuffleListWithAnimation; - }(Component); - - document.addEventListener('DOMContentLoaded', function () { - var container_1 = document.querySelector('#App1'); - var container_2 = document.querySelector('#App2'); - var container_3 = document.querySelector('#App3'); - var container_4 = document.querySelector('#App4'); - var container_5 = document.querySelector('#App5'); - var container_6 = document.querySelector('#App6'); - var useFunctionalComponent = location.search === '?functional'; - Inferno.render(createElement(List, { - useFunctionalComponent: useFunctionalComponent, - animation: 'HeightAndFade', - description: 'The children in this container animate opacity and height when added and removed. Click an item to remove it.' - }), container_1); - Inferno.render(createElement(List, { - useFunctionalComponent: useFunctionalComponent, - animation: 'NoTranistionEvent', - description: 'The children in this container have a broken animation. This is detected by inferno-animation and the animation callback is called immediately. Click an item to remove it.' - }), container_2); - Inferno.render(createElement(MixedList, { - useFunctionalComponent: useFunctionalComponent, - animation: 'HeightAndFade', - description: 'This container fades in and blocks the children from animating on first render. There is no animation on divider between elements. When you click [Remove] a random row and another random divder will be removed. Click an item to remove it (leaving the divider).' - }), container_3); - Inferno.render(createElement(ShuffleList, { - useFunctionalComponent: useFunctionalComponent, - animation: 'HeightAndFade', - description: 'This container will shuffle keys or items. Click an item to remove it.' - }), container_4); - var btn = document.querySelector('#Rerender > button'); - btn.addEventListener('click', function (e) { - e && e.preventDefault(); //Inferno.render(createElement('div', null, createElement(RerenderList, {animation: 'HeightAndFade', items: 5})), container_5); - - Inferno.render(createElement(RerenderList, { - useFunctionalComponent: useFunctionalComponent, - animation: 'HeightAndFade', - items: 5, - description: 'This container will be filled with 5 rows every time you click the button. Click an item to remove it.' - }), container_5); - }); - Inferno.render(createElement(ShuffleListWithAnimation, { - useFunctionalComponent: useFunctionalComponent, - animation: 'MoveAnim', - description: 'This container will animate items on shuffle. Click an item to randomly move it.' - }), container_6); - }); - })(); - -}()); +!function(){"use strict";function e(){return e=Object.assign||function(e){for(var t=1;t=0)continue;o[n]=e[n]}return o}var o,r,a,s,u,c,l,d,m,p,f,h,v,k,y,C,A,g,b,S,M,x,D,R,I,F,T,q=["children"],w=["children"],O=["children"];o=Inferno.Component,r=Inferno.createElement,s=(a=Inferno.Animation).AnimatedComponent,u=a.AnimatedMoveComponent,c=a.componentDidAppear,l=a.componentWillDisappear,d=a.componentWillMove,m=a.utils,p=m.addClassName,f=m.removeClassName,h=m.forceReflow,v=m.registerTransitionListener,k={onComponentDidAppear:c,onComponentWillDisappear:l},y={onComponentWillMove:d},C=function(e){function n(){return e.apply(this,arguments)||this}return t(n,e),n.prototype.render=function(){var e=this;return r("li",{onClick:function(t){return e.props.onClick(t,e.props.index)}},this.props.children)},n}(s),A=function(e){function n(){return e.apply(this,arguments)||this}return t(n,e),n.prototype.render=function(){var e=this;return r("section",{onClick:function(t){return e.props.onClick(t,e.props.index)}},this.props.children)},n}(s),g=function(e){var t=e.children,n=i(e,q);return r("li",{onClick:function(e){return n.onClick(e,n.index)}},t)},b=function(e){var t=e.children,n=i(e,w);return r("section",{onClick:function(e){return n.onClick(e,n.index)}},t)},S=function(e){function n(){return e.apply(this,arguments)||this}return t(n,e),n.prototype.render=function(){var e=this;return r("li",{onClick:function(t){return e.props.onClick(t,e.props.index)}},this.props.children)},n}(u),M=function(e){var t=e.children,n=i(e,O);return r("li",{onClick:function(e){return n.onClick(e,n.index)}},t)},x=function(n){function i(){var t;return(t=n.call(this)||this).doRemove=function(e,n){e.preventDefault();var i=t.state.items.concat([]);i.splice(n,1),t.setState({items:i})},t.doAdd=function(e){e.preventDefault();var n=t.state.items.concat([]),i=0===n.length?0:n[n.length-1].key+1;n.push({key:i}),t.setState({items:n})},t.doRemove20=function(e){e.preventDefault();var n=t.state.items.concat([]);n.splice(n.length>=20?n.length-20:0,n.length>=20?20:n.length),t.setState({items:n})},t.doAdd20=function(e){e.preventDefault();for(var n=t.state.items.concat([]),i=0===n.length?0:n[n.length-1].key+1,o=0;o<20;o++)n.push({key:i+o});t.setState({items:n})},t.renderItem=function(n,i){return t.props.useFunctionalComponent?r(g,e({key:n.key,index:i,animation:t.props.animation},k,{onClick:t.doRemove}),n.key+1+"bar"):r(C,{key:n.key,index:i,animation:t.props.animation,onClick:t.doRemove},n.key+1+"bar")},t.state={items:[]},t.items=[],t}t(i,n);var o=i.prototype;return o.componentDidMount=function(){for(var e=0;this.items.length<20;)this.items[this.items.length]={key:e++};this.setState({items:this.items})},o.render=function(){return r("div",null,[r("ul",null,this.state.items.map(this.renderItem)),r("h2",null,this.props.animation),r("p",null,this.props.description),r("button",{onClick:this.doAdd},"Add"),r("button",{onClick:this.doAdd20},"Add 20"),r("button",{onClick:this.doRemove20},"Remove 20")])},i}(o),D=function(n){function i(){var t;(t=n.call(this)||this).componentDidAppear=function(e){var t="fade-enter",n="fade-enter-active",i="fade-enter-end";p(e,t),h(),p(e,n),v([e],(function(){f(e,n),f(e,i)})),requestAnimationFrame((function(){f(e,t),p(e,i)}))},t.componentWillDisappear=function(e,t){var n="fade-leave";p(e,n),p(e,"fade-leave-active"),v([e],(function(){t()})),requestAnimationFrame((function(){p(e,"fade-leave-end"),f(e,n)}))},t.doRemove=function(e,n){e.preventDefault();var i=t.state.items.concat([]);i.splice(n,1),t.setState({items:i})},t.doRemoveSpecial=function(e){e.preventDefault();var n=t.state.items.filter((function(e){return e.isListItem})),i=n[parseInt(Math.round(Math.random()*(n.length-1)))].key,o=t.state.items.filter((function(e){return e.key!==i}));t.setState({items:o}),setTimeout((function(){var e=t.state.items.filter((function(e){return!e.isListItem})),n=parseInt(Math.round(Math.random()*(e.length-1))),i=0,o=t.state.items.filter((function(e){return e.isListItem||i++!==n}));t.setState({items:o})}),100)},t.doAdd=function(e){e.preventDefault();var n=t.state.items.concat([]),i=n.reduce((function(e,t){return t.key>e?t.key:e}),0)+1;n.push({key:i,isListItem:!0}),n.push({key:i+1}),t.setState({items:n})},t.renderItem=function(n,i){return t.props.useFunctionalComponent?r(b,e({key:n.key,index:i,animation:t.props.animation},k,{onClick:t.doRemove}),n.key+1+"bar"):r(A,{key:n.key,index:i,animation:t.props.animation,onClick:t.doRemove},n.key+1+"bar")};for(var i=0,o=[];o.length<40;)o[o.length]={key:i++,isListItem:!0},o[o.length]={key:i++};return t.state={items:o},t}return t(i,n),i.prototype.render=function(){var e=this;return r("div",null,[r("article",null,this.state.items.map((function(t,n){return t.isListItem?e.renderItem(t,n):r("span",{className:"divider"})}))),r("h2",null,"Mixed list"),r("p",null,this.props.description),r("button",{onClick:this.doAdd},"Add"),r("button",{onClick:this.doRemoveSpecial},"Remove")])},i}(o),R=function(n){function i(){var t;return(t=n.call(this)||this).doRemove=function(e,n){e&&e.preventDefault();var i=t.state.items.concat([]);i.splice(n,1),t.setState({items:i})},t.doAdd=function(e){e&&e.preventDefault();var n=t.state.items.concat([]),i=n.reduce((function(e,t){return t.key>e?t.key:e}),0)+1;n.push({key:i,val:i}),t.setState({items:n})},t.doMix=function(e){e&&e.preventDefault();var n=t.state.items.concat([]);I(n),t.setState({items:n})},t.doReassignKeys=function(e){e&&e.preventDefault();var n=t.state.items.concat([]);I(n);var i=t.state.items.map((function(e,t){return Object.assign({},e,{key:n[t].key})}));t.setState({items:i})},t.doRemoveMix=function(e){if(e&&e.preventDefault(),0===t.state.items.length)return;var n=parseInt(Math.round(Math.random()*(t.state.items.length-1))),i=t.state.items[n].key,o=t.state.items.filter((function(e){return e.key!==i}));t.setState({items:o,deleted:i+1}),setTimeout((function(){return t.doMix(e)}),100)},t.removeAndShuffle=function(e){e&&e.preventDefault();for(var n=0;n<20;n++)setTimeout((function(){var e=parseInt(Math.round(Math.random()*(t.state.items.length-1)));t.doRemove(void 0,e),t.doReassignKeys(),t.doMix()}))},t.doAdd20=function(e){e&&e.preventDefault();for(var n=0;n<20;n++)t.doAdd();for(var i=0;i<5;i++)t.doReassignKeys(),t.doMix()},t.doAdd20SeqMix=function(e){e&&e.preventDefault();for(var n=0;n<20;n++)t.doAdd();for(var i=0;i<5;i++)setTimeout((function(){t.doMix()}),500+100*i)},t.renderItem=function(n,i){return t.props.useFunctionalComponent?r(g,e({key:n.key,index:i,animation:t.props.animation},k,{onClick:t.doRemove}),n.val+"bar ("+n.key+")"):r(C,{key:n.key,index:i,animation:t.props.animation,onClick:t.doRemove},n.val+"bar ("+n.key+")")},t.state={items:[]},t.items=[],t}t(i,n);var o=i.prototype;return o.componentDidMount=function(){for(var e=0;this.items.length<20;)this.items[this.items.length]={key:e,val:e},e++;this.setState({items:this.items})},o.render=function(){return r("div",null,[r("ul",null,this.state.items.map(this.renderItem)),r("h2",null,"Shuffle"),r("p",null,this.props.description),r("button",{onClick:this.doAdd},"Add"),r("button",{onClick:this.doMix},"Shuffle"),r("button",{onClick:this.doReassignKeys},"Shuffle keys"),r("button",{onClick:this.doRemoveMix},"Remove"+(this.state.deleted?" ("+this.state.deleted+")":"")),r("button",{onClick:this.doAdd20},"Add and shuffle 20"),r("button",{onClick:this.doAdd20SeqMix},"Add 20 do 5 shuffle"),r("button",{onClick:this.removeAndShuffle},"Remove and shuffle 20")])},i}(o),I=function(e){for(var t,n,i=e.length;0!==i;)n=Math.floor(Math.random()*i),t=e[i-=1],e[i]=e[n],e[n]=t;return e},F=function(n){function i(){var t;return(t=n.call(this)||this).doRemove=function(e,n){e.preventDefault();var i=t.state.items.concat([]);i.splice(n,1),t.setState({items:i})},t.doAdd=function(e){e.preventDefault();var n=t.state.items.concat([]),i=n.reduce((function(e,t){return t.key>e?t.key:e}),0)+1;n.push({key:i,val:i}),t.setState({items:n})},t.renderItem=function(n,i){return t.props.useFunctionalComponent?r(g,e({key:n.key,index:i,animation:t.props.animation},k,{onClick:t.doRemove}),n.val+"bar ("+n.key+")"):r(C,{key:n.key,index:i,animation:t.props.animation,onClick:t.doRemove},n.val+"bar ("+n.key+")")},t.state={items:[]},t.items=[],t}t(i,n);var o=i.prototype;return o.componentDidMount=function(){this.componentWillReceiveProps(this.props)},o.componentWillReceiveProps=function(e){for(var t=0;this.items.lengthe?t.key:e}),0)+1;n.push({key:i,val:i}),t.setState({items:n})},t.doMix=function(e){e&&e.preventDefault();var n=t.state.items.concat([]);I(n),console.log("Expected order: "+n.map((function(e){return"("+e.val+")"})).join(",")),t.setState({items:n}),setTimeout((function(){var e=document.querySelector("#App6 ul").textContent.match(/\(\d*\)/g);console.log("Actual order: "+e.join(","))}),100)},t.doDoubleMix=function(e){e&&e.preventDefault();var n=t.state.items.concat([]);I(n),console.log("Expected order 1: "+n.map((function(e){return"("+e.val+")"})).join(",")),t.setState({items:n}),setTimeout((function(){var e=n.concat([]);I(e),t.setState({items:e}),console.log("Expected order 2: "+e.map((function(e){return"("+e.val+")"})).join(","))}),1),setTimeout((function(){var e=document.querySelector("#App6 ul").textContent.match(/\(\d*\)/g);console.log("Actual order: "+e.join(","))}),100)},t.doMoveOne=function(e){e&&e.preventDefault();var n=t.state.items.concat([]);n.push(n.shift()),t.setState({items:n})},t.doClearMarkers=function(e){e&&e.preventDefault(),document.querySelectorAll(".debugMarker").forEach((function(e){e.parentNode.removeChild(e)}))},t.renderItem=function(n,i){return t.props.useFunctionalComponent?r(M,e({key:n.key,index:i,animation:t.props.animation},y,{onClick:t.doMove}),n.val+"bar ("+n.key+")"):r(S,{key:n.key,index:i,animation:t.props.animation,onClick:t.doMove},n.val+"bar ("+n.key+")")},t.state={items:[]},t.items=[],t}t(i,n);var o=i.prototype;return o.componentDidMount=function(){for(var e=0;this.items.length<5;)this.items[this.items.length]={key:e,val:e},e++;this.setState({items:this.items})},o.render=function(){return r("div",null,[r("ul",null,this.state.items.map(this.renderItem)),r("h2",null,"Shuffle w. Anim"),r("p",null,this.props.description),r("button",{onClick:this.doAdd},"Add"),r("button",{onClick:this.doMix},"Shuffle"),r("button",{onClick:this.doDoubleMix},"DoubleShuffle"),r("button",{onClick:this.doMoveOne},"Move 1"),r("button",{onClick:this.doRemoveMix},"Remove"+(this.state.deleted?" ("+this.state.deleted+")":"")),r("button",{onClick:this.doClearMarkers},"Clear debug markers")])},i}(o),document.addEventListener("DOMContentLoaded",(function(){var e=document.querySelector("#App1"),t=document.querySelector("#App2"),n=document.querySelector("#App3"),i=document.querySelector("#App4"),o=document.querySelector("#App5"),a=document.querySelector("#App6"),s="?functional"===location.search;Inferno.render(r(x,{useFunctionalComponent:s,animation:"HeightAndFade",description:"The children in this container animate opacity and height when added and removed. Click an item to remove it."}),e),Inferno.render(r(x,{useFunctionalComponent:s,animation:"NoTranistionEvent",description:"The children in this container have a broken animation. This is detected by inferno-animation and the animation callback is called immediately. Click an item to remove it."}),t),Inferno.render(r(D,{useFunctionalComponent:s,animation:"HeightAndFade",description:"This container fades in and blocks the children from animating on first render. There is no animation on divider between elements. When you click [Remove] a random row and another random divder will be removed. Click an item to remove it (leaving the divider)."}),n),Inferno.render(r(R,{useFunctionalComponent:s,animation:"HeightAndFade",description:"This container will shuffle keys or items. Click an item to remove it."}),i),document.querySelector("#Rerender > button").addEventListener("click",(function(e){e&&e.preventDefault(),Inferno.render(r(F,{useFunctionalComponent:s,animation:"HeightAndFade",items:5,description:"This container will be filled with 5 rows every time you click the button. Click an item to remove it."}),o)})),Inferno.render(r(T,{useFunctionalComponent:s,animation:"MoveAnim",description:"This container will animate items on shuffle. Click an item to randomly move it."}),a)}))}(); diff --git a/docs/async-render/dist/bundle.js b/docs/async-render/dist/bundle.js index 48657d806..e85e48eb7 100644 --- a/docs/async-render/dist/bundle.js +++ b/docs/async-render/dist/bundle.js @@ -1,99 +1 @@ -(function () { - 'use strict'; - - function _inheritsLoose(subClass, superClass) { - subClass.prototype = Object.create(superClass.prototype); - subClass.prototype.constructor = subClass; - - _setPrototypeOf(subClass, superClass); - } - - function _setPrototypeOf(o, p) { - _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { - o.__proto__ = p; - return o; - }; - - return _setPrototypeOf(o, p); - } - - (function () { - // https://jsfiddle.net/oLwa7ysr/ - - /* (flags, type, props, children, key, ref, noNormalise) */ - - Inferno.createVNode; - var Component = Inferno.Component; - var createElement = Inferno.createElement; - var renderCounter = 0; - - var ListItem = /*#__PURE__*/function (_Component) { - _inheritsLoose(ListItem, _Component); - - function ListItem() { - return _Component.apply(this, arguments) || this; - } - - var _proto = ListItem.prototype; - - _proto.render = function render() { - renderCounter++; - return createElement('li', null, this.props.children); - }; - - return ListItem; - }(Component); - - var List = /*#__PURE__*/function (_Component2) { - _inheritsLoose(List, _Component2); - - function List() { - var _this; - - _this = _Component2.call(this) || this; // set initial time: - - _this.state = { - items: [] - }; - _this.items = []; - return _this; - } - - var _proto2 = List.prototype; - - _proto2.componentDidMount = function componentDidMount() { - var i = 0; - - while (this.items.length < 2000) { - this.items[this.items.length] = createElement(ListItem, { - key: ++i - }, this.items.length + "bar"); - this.setState({ - items: this.items - }); - } - }; - - _proto2.render = function render() { - return createElement('ul', null, this.state.items); - }; - - return List; - }(Component); - - document.addEventListener('DOMContentLoaded', function () { - var container = document.querySelector('#App'); - var count = 2; - var totalTime = 0; - - for (var i = 0; i < count; i++) { - Inferno.render(createElement(List), container); - } - - setTimeout(function () { - Inferno.render(createElement('div', null, "\n\t\t\t\tRounds: " + count + ",\n\t\t\t\tAverage: " + totalTime / count + ",\n\t\t\t\tTotal: " + totalTime + ",\n\t\t\t\tcounter: " + renderCounter + "\n\t\t\t"), container); - }, 5000); - }); - })(); - -}()); +!function(){"use strict";function t(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,e(t,n)}function e(t,n){return e=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},e(t,n)}!function(){Inferno.createVNode;var e=Inferno.Component,n=Inferno.createElement,r=0,o=function(e){function o(){return e.apply(this,arguments)||this}return t(o,e),o.prototype.render=function(){return r++,n("li",null,this.props.children)},o}(e),i=function(e){function r(){var t;return(t=e.call(this)||this).state={items:[]},t.items=[],t}t(r,e);var i=r.prototype;return i.componentDidMount=function(){for(var t=0;this.items.length<2e3;)this.items[this.items.length]=n(o,{key:++t},this.items.length+"bar"),this.setState({items:this.items})},i.render=function(){return n("ul",null,this.state.items)},r}(e);document.addEventListener("DOMContentLoaded",(function(){for(var t=document.querySelector("#App"),e=0;e<2;e++)Inferno.render(n(i),t);setTimeout((function(){Inferno.render(n("div",null,"\n\t\t\t\tRounds: 2,\n\t\t\t\tAverage: 0,\n\t\t\t\tTotal: 0,\n\t\t\t\tcounter: "+r+"\n\t\t\t"),t)}),5e3)}))}()}(); diff --git a/docs/dbmonster/dist/bundle.js b/docs/dbmonster/dist/bundle.js index b50ab26a8..6ed977c31 100644 --- a/docs/dbmonster/dist/bundle.js +++ b/docs/dbmonster/dist/bundle.js @@ -1,2252 +1 @@ -(function () { - 'use strict'; - - var MonitorMaxSamples = 100; - var MonitorSamplesResult = (function () { - function MonitorSamplesResult(min, max, mean, last) { - this.min = min; - this.max = max; - this.mean = mean; - this.last = last; - } - return MonitorSamplesResult; - }()); - /** - * Profile Samples. - */ - var MonitorSamples = (function () { - function MonitorSamples(maxSamples) { - this.samples = []; - this.maxSamples = maxSamples; - this._i = -1; - } - MonitorSamples.prototype.addSample = function (v) { - this._i = (this._i + 1) % this.maxSamples; - this.samples[this._i] = v; - }; - MonitorSamples.prototype.each = function (fn) { - var samples = this.samples; - for (var i = 0; i < samples.length; i++) { - fn(samples[(this._i + 1 + i) % samples.length], i); - } - }; - MonitorSamples.prototype.calc = function () { - var samples = this.samples; - if (samples.length === 0) { - return new MonitorSamplesResult(0, 0, 0, 0); - } - var min = samples[(this._i + 1) % samples.length]; - var max = min; - var sum = 0; - for (var i = 0; i < samples.length; i++) { - var k = samples[(this._i + 1 + i) % samples.length]; - if (k < min) { - min = k; - } - if (k > max) { - max = k; - } - sum += k; - } - var last = samples[this._i]; - var mean = sum / samples.length; - return new MonitorSamplesResult(min, max, mean, last); - }; - return MonitorSamples; - }()); - - var frameTasks = []; - var rafId = -1; - /** - * Schedule new task that will be executed on the next frame. - */ - function scheduleNextFrameTask(task) { - frameTasks.push(task); - if (rafId === -1) { - requestAnimationFrame(function (t) { - rafId = -1; - var tasks = frameTasks; - frameTasks = []; - for (var i = 0; i < tasks.length; i++) { - tasks[i](); - } - }); - } - } - - var __extends = (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - })(); - var MonitorGraphHeight = 30; - var MonitorGraphWidth = MonitorMaxSamples; - var Widget = (function () { - function Widget(name) { - var _this = this; - this._sync = function () { - _this.sync(); - _this._dirty = false; - }; - this.name = name; - this.element = document.createElement("div"); - this.element.style.cssText = "padding: 2px;" + - "background-color: #020;" + - "font-family: monospace;" + - "font-size: 12px;" + - "color: #0f0"; - this._dirty = false; - this.invalidate(); - } - Widget.prototype.invalidate = function () { - if (!this._dirty) { - this._dirty = true; - scheduleNextFrameTask(this._sync); - } - }; - Widget.prototype.sync = function () { - throw new Error("sync method not implemented"); - }; - return Widget; - }()); - var MonitorWidgetFlags; - (function (MonitorWidgetFlags) { - MonitorWidgetFlags[MonitorWidgetFlags["HideMin"] = 1] = "HideMin"; - MonitorWidgetFlags[MonitorWidgetFlags["HideMax"] = 2] = "HideMax"; - MonitorWidgetFlags[MonitorWidgetFlags["HideMean"] = 4] = "HideMean"; - MonitorWidgetFlags[MonitorWidgetFlags["HideLast"] = 8] = "HideLast"; - MonitorWidgetFlags[MonitorWidgetFlags["HideGraph"] = 16] = "HideGraph"; - MonitorWidgetFlags[MonitorWidgetFlags["RoundValues"] = 32] = "RoundValues"; - })(MonitorWidgetFlags || (MonitorWidgetFlags = {})); - var MonitorWidget = (function (_super) { - __extends(MonitorWidget, _super); - function MonitorWidget(name, flags, unitName, samples) { - var _this = _super.call(this, name) || this; - _this.flags = flags; - _this.unitName = unitName; - _this.samples = samples; - var label = document.createElement("div"); - label.style.cssText = "text-align: center"; - label.textContent = _this.name; - var text = document.createElement("div"); - if ((flags & MonitorWidgetFlags.HideMin) === 0) { - _this.minText = document.createElement("div"); - text.appendChild(_this.minText); - } - else { - _this.minText = null; - } - if ((flags & MonitorWidgetFlags.HideMax) === 0) { - _this.maxText = document.createElement("div"); - text.appendChild(_this.maxText); - } - else { - _this.maxText = null; - } - if ((flags & MonitorWidgetFlags.HideMean) === 0) { - _this.meanText = document.createElement("div"); - text.appendChild(_this.meanText); - } - else { - _this.meanText = null; - } - if ((flags & MonitorWidgetFlags.HideLast) === 0) { - _this.lastText = document.createElement("div"); - text.appendChild(_this.lastText); - } - else { - _this.lastText = null; - } - _this.element.appendChild(label); - _this.element.appendChild(text); - if ((flags & MonitorWidgetFlags.HideGraph) === 0) { - _this.canvas = document.createElement("canvas"); - _this.canvas.style.cssText = "display: block; padding: 0; margin: 0"; - _this.canvas.width = MonitorGraphWidth; - _this.canvas.height = MonitorGraphHeight; - _this.ctx = _this.canvas.getContext("2d"); - _this.element.appendChild(_this.canvas); - } - else { - _this.canvas = null; - _this.ctx = null; - } - return _this; - } - MonitorWidget.prototype.sync = function () { - var _this = this; - var result = this.samples.calc(); - var scale = MonitorGraphHeight / (result.max * 1.2); - var min; - var max; - var mean; - var last; - if ((this.flags & MonitorWidgetFlags.RoundValues) === 0) { - min = result.min.toFixed(2); - max = result.max.toFixed(2); - mean = result.mean.toFixed(2); - last = result.last.toFixed(2); - } - else { - min = Math.round(result.min).toString(); - max = Math.round(result.max).toString(); - mean = Math.round(result.mean).toString(); - last = Math.round(result.last).toString(); - } - if (this.minText !== null) { - this.minText.textContent = "min: \u00A0" + min + this.unitName; - } - if (this.maxText !== null) { - this.maxText.textContent = "max: \u00A0" + max + this.unitName; - } - if (this.meanText !== null) { - this.meanText.textContent = "mean: " + mean + this.unitName; - } - if (this.lastText !== null) { - this.lastText.textContent = "last: " + last + this.unitName; - } - if (this.ctx !== null) { - this.ctx.fillStyle = "#010"; - this.ctx.fillRect(0, 0, MonitorGraphWidth, MonitorGraphHeight); - this.ctx.fillStyle = "#0f0"; - this.samples.each(function (v, i) { - _this.ctx.fillRect(i, MonitorGraphHeight, 1, -(v * scale)); - }); - } - }; - return MonitorWidget; - }(Widget)); - ((function (_super) { - __extends(CounterWidget, _super); - function CounterWidget(name, counter) { - var _this = _super.call(this, name) || this; - _this.counter = counter; - _this.text = document.createElement("div"); - _this.element.appendChild(_this.text); - return _this; - } - CounterWidget.prototype.sync = function () { - this.text.textContent = this.name + ": " + this.counter.value; - }; - return CounterWidget; - })(Widget)); - - var container = null; - /** - * Check that everything is properly initialized. - */ - function checkInit() { - if (!container) { - container = document.createElement("div"); - container.style.cssText = "position: fixed;" + - "opacity: 0.9;" + - "right: 0;" + - "bottom: 0"; - document.body.appendChild(container); - } - } - /** - * Start FPS monitor - */ - function startFPSMonitor(flags) { - if (flags === void 0) { flags = MonitorWidgetFlags.HideMin | MonitorWidgetFlags.HideMax | - MonitorWidgetFlags.HideMean | MonitorWidgetFlags.RoundValues; } - checkInit(); - var data = new MonitorSamples(MonitorMaxSamples); - var w = new MonitorWidget("FPS", flags, "", data); - container.appendChild(w.element); - var alpha = 2 / 121; - var last = 0; - var fps = 60; - function update(now) { - if (last > 0) { - fps += alpha * ((1000 / (now - last)) - fps); - } - last = now; - data.addSample(fps); - w.invalidate(); - requestAnimationFrame(update); - } - requestAnimationFrame(update); - } - /** - * Start Memory Monitor - */ - function startMemMonitor(flags) { - if (flags === void 0) { flags = MonitorWidgetFlags.HideMin | MonitorWidgetFlags.HideMean; } - checkInit(); - if (performance.memory === undefined) { - return; - } - var data = new MonitorSamples(MonitorMaxSamples); - var w = new MonitorWidget("Memory", flags, "MB", data); - container.appendChild(w.element); - function update() { - data.addSample(Math.round(performance.memory.usedJSHeapSize / (1024 * 1024))); - w.invalidate(); - setTimeout(update, 30); - } - update(); - } - var ProfilerDetails = (function () { - function ProfilerDetails(name, unitName, flags) { - this.data = new MonitorSamples(MonitorMaxSamples); - this.widget = new MonitorWidget(name, flags, unitName, this.data); - this.startTime = -1; - } - return ProfilerDetails; - }()); - var profilerInstances = {}; - /** - * Initialize profiler and insert into container. - */ - function initProfiler(name, flags) { - if (flags === void 0) { flags = 0; } - checkInit(); - var profiler = profilerInstances[name]; - if (profiler === void 0) { - profilerInstances[name] = profiler = new ProfilerDetails(name, "ms", flags); - container.appendChild(profiler.widget.element); - } - } - function startProfile(name) { - var profiler = profilerInstances[name]; - if (profiler !== void 0) { - profiler.startTime = performance.now(); - } - } - function endProfile(name) { - var now = performance.now(); - var profiler = profilerInstances[name]; - if (profiler !== void 0 && profiler.startTime !== -1) { - profiler.data.addSample(now - profiler.startTime); - profiler.widget.invalidate(); - } - } - - var isArray = Array.isArray; - function isStringOrNumber(o) { - var type = typeof o; - return type === 'string' || type === 'number'; - } - function isNullOrUndef(o) { - return o === void 0 || o === null; - } - function isInvalid(o) { - return o === null || o === false || o === true || o === void 0; - } - function isFunction(o) { - return typeof o === 'function'; - } - function isString(o) { - return typeof o === 'string'; - } - function isNumber(o) { - return typeof o === 'number'; - } - function isNull(o) { - return o === null; - } - function combineFrom(first, second) { - var out = {}; - if (first) { - for (var key in first) { - out[key] = first[key]; - } - } - if (second) { - for (var key$1 in second) { - out[key$1] = second[key$1]; - } - } - return out; - } - // object.event should always be function, otherwise its badly created object. - function isLinkEventObject(o) { - return !isNull(o) && typeof o === 'object'; - } - - // We need EMPTY_OBJ defined in one place. - // Its used for comparison so we cant inline it into shared - var EMPTY_OBJ = {}; - function normalizeEventName(name) { - return name.substr(2).toLowerCase(); - } - function appendChild(parentDOM, dom) { - parentDOM.appendChild(dom); - } - function insertOrAppend(parentDOM, newNode, nextNode) { - if (isNull(nextNode)) { - appendChild(parentDOM, newNode); - } - else { - parentDOM.insertBefore(newNode, nextNode); - } - } - function documentCreateElement(tag, isSVG) { - if (isSVG) { - return document.createElementNS('http://www.w3.org/2000/svg', tag); - } - return document.createElement(tag); - } - function replaceChild(parentDOM, newDom, lastDom) { - parentDOM.replaceChild(newDom, lastDom); - } - function removeChild(parentDOM, childNode) { - parentDOM.removeChild(childNode); - } - function callAll(arrayFn) { - for (var i = 0; i < arrayFn.length; i++) { - arrayFn[i](); - } - } - function findChildVNode(vNode, startEdge, flags) { - var children = vNode.children; - if (flags & 4 /* ComponentClass */) { - return children.$LI; - } - if (flags & 8192 /* Fragment */) { - return vNode.childFlags === 2 /* HasVNodeChildren */ ? children : children[startEdge ? 0 : children.length - 1]; - } - return children; - } - function findDOMfromVNode(vNode, startEdge) { - var flags; - while (vNode) { - flags = vNode.flags; - if (flags & 2033 /* DOMRef */) { - return vNode.dom; - } - vNode = findChildVNode(vNode, startEdge, flags); - } - return null; - } - function removeVNodeDOM(vNode, parentDOM) { - do { - var flags = vNode.flags; - if (flags & 2033 /* DOMRef */) { - removeChild(parentDOM, vNode.dom); - return; - } - var children = vNode.children; - if (flags & 4 /* ComponentClass */) { - vNode = children.$LI; - } - if (flags & 8 /* ComponentFunction */) { - vNode = children; - } - if (flags & 8192 /* Fragment */) { - if (vNode.childFlags === 2 /* HasVNodeChildren */) { - vNode = children; - } - else { - for (var i = 0, len = children.length; i < len; ++i) { - removeVNodeDOM(children[i], parentDOM); - } - return; - } - } - } while (vNode); - } - function moveVNodeDOM(vNode, parentDOM, nextNode) { - do { - var flags = vNode.flags; - if (flags & 2033 /* DOMRef */) { - insertOrAppend(parentDOM, vNode.dom, nextNode); - return; - } - var children = vNode.children; - if (flags & 4 /* ComponentClass */) { - vNode = children.$LI; - } - if (flags & 8 /* ComponentFunction */) { - vNode = children; - } - if (flags & 8192 /* Fragment */) { - if (vNode.childFlags === 2 /* HasVNodeChildren */) { - vNode = children; - } - else { - for (var i = 0, len = children.length; i < len; ++i) { - moveVNodeDOM(children[i], parentDOM, nextNode); - } - return; - } - } - } while (vNode); - } - function createDerivedState(instance, nextProps, state) { - if (instance.constructor.getDerivedStateFromProps) { - return combineFrom(state, instance.constructor.getDerivedStateFromProps(nextProps, state)); - } - return state; - } - var options = { - componentComparator: null, - createVNode: null, - renderComplete: null - }; - function setTextContent(dom, children) { - dom.textContent = children; - } - // Calling this function assumes, nextValue is linkEvent - function isLastValueSameLinkEvent(lastValue, nextValue) { - return (isLinkEventObject(lastValue) && - lastValue.event === nextValue.event && - lastValue.data === nextValue.data); - } - function safeCall1(method, arg1) { - return !!isFunction(method) && (method(arg1), true); - } - - var keyPrefix = '$'; - function V(childFlags, children, className, flags, key, props, ref, type) { - this.childFlags = childFlags; - this.children = children; - this.className = className; - this.dom = null; - this.flags = flags; - this.key = key === void 0 ? null : key; - this.props = props === void 0 ? null : props; - this.ref = ref === void 0 ? null : ref; - this.type = type; - } - function createVNode(flags, type, className, children, childFlags, props, key, ref) { - var childFlag = childFlags === void 0 ? 1 /* HasInvalidChildren */ : childFlags; - var vNode = new V(childFlag, children, className, flags, key, props, ref, type); - if (childFlag === 0 /* UnknownChildren */) { - normalizeChildren(vNode, vNode.children); - } - return vNode; - } - function createTextVNode(text, key) { - return new V(1 /* HasInvalidChildren */, isNullOrUndef(text) || text === true || text === false ? '' : text, null, 16 /* Text */, key, null, null, null); - } - function createFragment(children, childFlags, key) { - var fragment = createVNode(8192 /* Fragment */, 8192 /* Fragment */, null, children, childFlags, null, key, null); - switch (fragment.childFlags) { - case 1 /* HasInvalidChildren */: - fragment.children = createVoidVNode(); - fragment.childFlags = 2 /* HasVNodeChildren */; - break; - case 16 /* HasTextChildren */: - fragment.children = [createTextVNode(children)]; - fragment.childFlags = 4 /* HasNonKeyedChildren */; - break; - } - return fragment; - } - /* - * Fragment is different than normal vNode, - * because when it needs to be cloned we need to clone its children too - * But not normalize, because otherwise those possibly get KEY and re-mount - */ - function cloneFragment(vNodeToClone) { - var oldChildren = vNodeToClone.children; - var childFlags = vNodeToClone.childFlags; - return createFragment(childFlags === 2 /* HasVNodeChildren */ ? directClone(oldChildren) : oldChildren.map(directClone), childFlags, vNodeToClone.key); - } - function directClone(vNodeToClone) { - var flags = vNodeToClone.flags & -16385 /* ClearInUse */; - var props = vNodeToClone.props; - if (flags & 14 /* Component */) { - if (!isNull(props)) { - var propsToClone = props; - props = {}; - for (var key in propsToClone) { - props[key] = propsToClone[key]; - } - } - } - if ((flags & 8192 /* Fragment */) === 0) { - return new V(vNodeToClone.childFlags, vNodeToClone.children, vNodeToClone.className, flags, vNodeToClone.key, props, vNodeToClone.ref, vNodeToClone.type); - } - return cloneFragment(vNodeToClone); - } - function createVoidVNode() { - return createTextVNode('', null); - } - function _normalizeVNodes(nodes, result, index, currentKey) { - for (var len = nodes.length; index < len; index++) { - var n = nodes[index]; - if (!isInvalid(n)) { - var newKey = currentKey + keyPrefix + index; - if (isArray(n)) { - _normalizeVNodes(n, result, 0, newKey); - } - else { - if (isStringOrNumber(n)) { - n = createTextVNode(n, newKey); - } - else { - var oldKey = n.key; - var isPrefixedKey = isString(oldKey) && oldKey[0] === keyPrefix; - if (n.flags & 81920 /* InUseOrNormalized */ || isPrefixedKey) { - n = directClone(n); - } - n.flags |= 65536 /* Normalized */; - if (!isPrefixedKey) { - if (isNull(oldKey)) { - n.key = newKey; - } - else { - n.key = currentKey + oldKey; - } - } - else if (oldKey.substring(0, currentKey.length) !== currentKey) { - n.key = currentKey + oldKey; - } - } - result.push(n); - } - } - } - } - function normalizeChildren(vNode, children) { - var newChildren; - var newChildFlags = 1 /* HasInvalidChildren */; - // Don't change children to match strict equal (===) true in patching - if (isInvalid(children)) { - newChildren = children; - } - else if (isStringOrNumber(children)) { - newChildFlags = 16 /* HasTextChildren */; - newChildren = children; - } - else if (isArray(children)) { - var len = children.length; - for (var i = 0; i < len; ++i) { - var n = children[i]; - if (isInvalid(n) || isArray(n)) { - newChildren = newChildren || children.slice(0, i); - _normalizeVNodes(children, newChildren, i, ''); - break; - } - else if (isStringOrNumber(n)) { - newChildren = newChildren || children.slice(0, i); - newChildren.push(createTextVNode(n, keyPrefix + i)); - } - else { - var key = n.key; - var needsCloning = (n.flags & 81920 /* InUseOrNormalized */) > 0; - var isNullKey = isNull(key); - var isPrefixed = isString(key) && key[0] === keyPrefix; - if (needsCloning || isNullKey || isPrefixed) { - newChildren = newChildren || children.slice(0, i); - if (needsCloning || isPrefixed) { - n = directClone(n); - } - if (isNullKey || isPrefixed) { - n.key = keyPrefix + i; - } - newChildren.push(n); - } - else if (newChildren) { - newChildren.push(n); - } - n.flags |= 65536 /* Normalized */; - } - } - newChildren = newChildren || children; - if (newChildren.length === 0) { - newChildFlags = 1 /* HasInvalidChildren */; - } - else { - newChildFlags = 8 /* HasKeyedChildren */; - } - } - else { - newChildren = children; - newChildren.flags |= 65536 /* Normalized */; - if (children.flags & 81920 /* InUseOrNormalized */) { - newChildren = directClone(children); - } - newChildFlags = 2 /* HasVNodeChildren */; - } - vNode.children = newChildren; - vNode.childFlags = newChildFlags; - return vNode; - } - function normalizeRoot(input) { - if (isInvalid(input) || isStringOrNumber(input)) { - return createTextVNode(input, null); - } - if (isArray(input)) { - return createFragment(input, 0 /* UnknownChildren */, null); - } - return input.flags & 16384 /* InUse */ ? directClone(input) : input; - } - - var xlinkNS = 'http://www.w3.org/1999/xlink'; - var xmlNS = 'http://www.w3.org/XML/1998/namespace'; - var namespaces = { - 'xlink:actuate': xlinkNS, - 'xlink:arcrole': xlinkNS, - 'xlink:href': xlinkNS, - 'xlink:role': xlinkNS, - 'xlink:show': xlinkNS, - 'xlink:title': xlinkNS, - 'xlink:type': xlinkNS, - 'xml:base': xmlNS, - 'xml:lang': xmlNS, - 'xml:space': xmlNS - }; - - function getDelegatedEventObject(v) { - return { - onClick: v, - onDblClick: v, - onFocusIn: v, - onFocusOut: v, - onKeyDown: v, - onKeyPress: v, - onKeyUp: v, - onMouseDown: v, - onMouseMove: v, - onMouseUp: v, - onTouchEnd: v, - onTouchMove: v, - onTouchStart: v - }; - } - var attachedEventCounts = getDelegatedEventObject(0); - var attachedEvents = getDelegatedEventObject(null); - var syntheticEvents = getDelegatedEventObject(true); - function updateOrAddSyntheticEvent(name, dom) { - var eventsObject = dom.$EV; - if (!eventsObject) { - eventsObject = dom.$EV = getDelegatedEventObject(null); - } - if (!eventsObject[name]) { - if (++attachedEventCounts[name] === 1) { - attachedEvents[name] = attachEventToDocument(name); - } - } - return eventsObject; - } - function unmountSyntheticEvent(name, dom) { - var eventsObject = dom.$EV; - if (eventsObject && eventsObject[name]) { - if (--attachedEventCounts[name] === 0) { - document.removeEventListener(normalizeEventName(name), attachedEvents[name]); - attachedEvents[name] = null; - } - eventsObject[name] = null; - } - } - function handleSyntheticEvent(name, lastEvent, nextEvent, dom) { - if (isFunction(nextEvent)) { - updateOrAddSyntheticEvent(name, dom)[name] = nextEvent; - } - else if (isLinkEventObject(nextEvent)) { - if (isLastValueSameLinkEvent(lastEvent, nextEvent)) { - return; - } - updateOrAddSyntheticEvent(name, dom)[name] = nextEvent; - } - else { - unmountSyntheticEvent(name, dom); - } - } - // When browsers fully support event.composedPath we could loop it through instead of using parentNode property - function getTargetNode(event) { - return isFunction(event.composedPath) ? event.composedPath()[0] : event.target; - } - function dispatchEvents(event, isClick, name, eventData) { - var dom = getTargetNode(event); - do { - // Html Nodes can be nested fe: span inside button in that scenario browser does not handle disabled attribute on parent, - // because the event listener is on document.body - // Don't process clicks on disabled elements - if (isClick && dom.disabled) { - return; - } - var eventsObject = dom.$EV; - if (eventsObject) { - var currentEvent = eventsObject[name]; - if (currentEvent) { - // linkEvent object - eventData.dom = dom; - currentEvent.event ? currentEvent.event(currentEvent.data, event) : currentEvent(event); - if (event.cancelBubble) { - return; - } - } - } - dom = dom.parentNode; - } while (!isNull(dom)); - } - function stopPropagation() { - this.cancelBubble = true; - if (!this.immediatePropagationStopped) { - this.stopImmediatePropagation(); - } - } - function isDefaultPrevented() { - return this.defaultPrevented; - } - function isPropagationStopped() { - return this.cancelBubble; - } - function extendEventProperties(event) { - // Event data needs to be object to save reference to currentTarget getter - var eventData = { - dom: document - }; - event.isDefaultPrevented = isDefaultPrevented; - event.isPropagationStopped = isPropagationStopped; - event.stopPropagation = stopPropagation; - Object.defineProperty(event, 'currentTarget', { - configurable: true, - get: function get() { - return eventData.dom; - } - }); - return eventData; - } - function rootClickEvent(name) { - return function (event) { - if (event.button !== 0) { - // Firefox incorrectly triggers click event for mid/right mouse buttons. - // This bug has been active for 17 years. - // https://bugzilla.mozilla.org/show_bug.cgi?id=184051 - event.stopPropagation(); - return; - } - dispatchEvents(event, true, name, extendEventProperties(event)); - }; - } - function rootEvent(name) { - return function (event) { - dispatchEvents(event, false, name, extendEventProperties(event)); - }; - } - function attachEventToDocument(name) { - var attachedEvent = name === 'onClick' || name === 'onDblClick' ? rootClickEvent(name) : rootEvent(name); - document.addEventListener(normalizeEventName(name), attachedEvent); - return attachedEvent; - } - - function isSameInnerHTML(dom, innerHTML) { - var tempdom = document.createElement('i'); - tempdom.innerHTML = innerHTML; - return tempdom.innerHTML === dom.innerHTML; - } - - function triggerEventListener(props, methodName, e) { - if (props[methodName]) { - var listener = props[methodName]; - if (listener.event) { - listener.event(listener.data, e); - } - else { - listener(e); - } - } - else { - var nativeListenerName = methodName.toLowerCase(); - if (props[nativeListenerName]) { - props[nativeListenerName](e); - } - } - } - function createWrappedFunction(methodName, applyValue) { - var fnMethod = function (e) { - var vNode = this.$V; - // If vNode is gone by the time event fires, no-op - if (!vNode) { - return; - } - var props = vNode.props || EMPTY_OBJ; - var dom = vNode.dom; - if (isString(methodName)) { - triggerEventListener(props, methodName, e); - } - else { - for (var i = 0; i < methodName.length; ++i) { - triggerEventListener(props, methodName[i], e); - } - } - if (isFunction(applyValue)) { - var newVNode = this.$V; - var newProps = newVNode.props || EMPTY_OBJ; - applyValue(newProps, dom, false, newVNode); - } - }; - Object.defineProperty(fnMethod, 'wrapped', { - configurable: false, - enumerable: false, - value: true, - writable: false - }); - return fnMethod; - } - - function attachEvent(dom, eventName, handler) { - var previousKey = "$" + eventName; - var previousArgs = dom[previousKey]; - if (previousArgs) { - if (previousArgs[1].wrapped) { - return; - } - dom.removeEventListener(previousArgs[0], previousArgs[1]); - dom[previousKey] = null; - } - if (isFunction(handler)) { - dom.addEventListener(eventName, handler); - dom[previousKey] = [eventName, handler]; - } - } - - function isCheckedType(type) { - return type === 'checkbox' || type === 'radio'; - } - var onTextInputChange = createWrappedFunction('onInput', applyValueInput); - var wrappedOnChange = createWrappedFunction(['onClick', 'onChange'], applyValueInput); - /* tslint:disable-next-line:no-empty */ - function emptywrapper(event) { - event.stopPropagation(); - } - emptywrapper.wrapped = true; - function inputEvents(dom, nextPropsOrEmpty) { - if (isCheckedType(nextPropsOrEmpty.type)) { - attachEvent(dom, 'change', wrappedOnChange); - attachEvent(dom, 'click', emptywrapper); - } - else { - attachEvent(dom, 'input', onTextInputChange); - } - } - function applyValueInput(nextPropsOrEmpty, dom) { - var type = nextPropsOrEmpty.type; - var value = nextPropsOrEmpty.value; - var checked = nextPropsOrEmpty.checked; - var multiple = nextPropsOrEmpty.multiple; - var defaultValue = nextPropsOrEmpty.defaultValue; - var hasValue = !isNullOrUndef(value); - if (type && type !== dom.type) { - dom.setAttribute('type', type); - } - if (!isNullOrUndef(multiple) && multiple !== dom.multiple) { - dom.multiple = multiple; - } - if (!isNullOrUndef(defaultValue) && !hasValue) { - dom.defaultValue = defaultValue + ''; - } - if (isCheckedType(type)) { - if (hasValue) { - dom.value = value; - } - if (!isNullOrUndef(checked)) { - dom.checked = checked; - } - } - else { - if (hasValue && dom.value !== value) { - dom.defaultValue = value; - dom.value = value; - } - else if (!isNullOrUndef(checked)) { - dom.checked = checked; - } - } - } - - function updateChildOptions(vNode, value) { - if (vNode.type === 'option') { - updateChildOption(vNode, value); - } - else { - var children = vNode.children; - var flags = vNode.flags; - if (flags & 4 /* ComponentClass */) { - updateChildOptions(children.$LI, value); - } - else if (flags & 8 /* ComponentFunction */) { - updateChildOptions(children, value); - } - else if (vNode.childFlags === 2 /* HasVNodeChildren */) { - updateChildOptions(children, value); - } - else if (vNode.childFlags & 12 /* MultipleChildren */) { - for (var i = 0, len = children.length; i < len; ++i) { - updateChildOptions(children[i], value); - } - } - } - } - function updateChildOption(vNode, value) { - var props = vNode.props || EMPTY_OBJ; - var dom = vNode.dom; - // we do this as multiple may have changed - dom.value = props.value; - if (props.value === value || (isArray(value) && value.indexOf(props.value) !== -1)) { - dom.selected = true; - } - else if (!isNullOrUndef(value) || !isNullOrUndef(props.selected)) { - dom.selected = props.selected || false; - } - } - var onSelectChange = createWrappedFunction('onChange', applyValueSelect); - function selectEvents(dom) { - attachEvent(dom, 'change', onSelectChange); - } - function applyValueSelect(nextPropsOrEmpty, dom, mounting, vNode) { - var multiplePropInBoolean = Boolean(nextPropsOrEmpty.multiple); - if (!isNullOrUndef(nextPropsOrEmpty.multiple) && multiplePropInBoolean !== dom.multiple) { - dom.multiple = multiplePropInBoolean; - } - var index = nextPropsOrEmpty.selectedIndex; - if (index === -1) { - dom.selectedIndex = -1; - } - var childFlags = vNode.childFlags; - if (childFlags !== 1 /* HasInvalidChildren */) { - var value = nextPropsOrEmpty.value; - if (isNumber(index) && index > -1 && dom.options[index]) { - value = dom.options[index].value; - } - if (mounting && isNullOrUndef(value)) { - value = nextPropsOrEmpty.defaultValue; - } - updateChildOptions(vNode, value); - } - } - - var onTextareaInputChange = createWrappedFunction('onInput', applyValueTextArea); - var wrappedOnChange$1 = createWrappedFunction('onChange'); - function textAreaEvents(dom, nextPropsOrEmpty) { - attachEvent(dom, 'input', onTextareaInputChange); - if (nextPropsOrEmpty.onChange) { - attachEvent(dom, 'change', wrappedOnChange$1); - } - } - function applyValueTextArea(nextPropsOrEmpty, dom, mounting) { - var value = nextPropsOrEmpty.value; - var domValue = dom.value; - if (isNullOrUndef(value)) { - if (mounting) { - var defaultValue = nextPropsOrEmpty.defaultValue; - if (!isNullOrUndef(defaultValue) && defaultValue !== domValue) { - dom.defaultValue = defaultValue; - dom.value = defaultValue; - } - } - } - else if (domValue !== value) { - /* There is value so keep it controlled */ - dom.defaultValue = value; - dom.value = value; - } - } - - function processElement(flags, vNode, dom, nextPropsOrEmpty, mounting, isControlled) { - if (flags & 64 /* InputElement */) { - applyValueInput(nextPropsOrEmpty, dom); - } - else if (flags & 256 /* SelectElement */) { - applyValueSelect(nextPropsOrEmpty, dom, mounting, vNode); - } - else if (flags & 128 /* TextareaElement */) { - applyValueTextArea(nextPropsOrEmpty, dom, mounting); - } - if (isControlled) { - dom.$V = vNode; - } - } - function addFormElementEventHandlers(flags, dom, nextPropsOrEmpty) { - if (flags & 64 /* InputElement */) { - inputEvents(dom, nextPropsOrEmpty); - } - else if (flags & 256 /* SelectElement */) { - selectEvents(dom); - } - else if (flags & 128 /* TextareaElement */) { - textAreaEvents(dom, nextPropsOrEmpty); - } - } - function isControlledFormElement(nextPropsOrEmpty) { - return nextPropsOrEmpty.type && isCheckedType(nextPropsOrEmpty.type) ? !isNullOrUndef(nextPropsOrEmpty.checked) : !isNullOrUndef(nextPropsOrEmpty.value); - } - function unmountRef(ref) { - if (ref) { - if (!safeCall1(ref, null) && ref.current) { - ref.current = null; - } - } - } - function mountRef(ref, value, lifecycle) { - if (ref && (isFunction(ref) || ref.current !== void 0)) { - lifecycle.push(function () { - if (!safeCall1(ref, value) && ref.current !== void 0) { - ref.current = value; - } - }); - } - } - - function remove(vNode, parentDOM) { - unmount(vNode); - removeVNodeDOM(vNode, parentDOM); - } - function unmount(vNode) { - var flags = vNode.flags; - var children = vNode.children; - var ref; - if (flags & 481 /* Element */) { - ref = vNode.ref; - var props = vNode.props; - unmountRef(ref); - var childFlags = vNode.childFlags; - if (!isNull(props)) { - var keys = Object.keys(props); - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i]; - if (syntheticEvents[key]) { - unmountSyntheticEvent(key, vNode.dom); - } - } - } - if (childFlags & 12 /* MultipleChildren */) { - unmountAllChildren(children); - } - else if (childFlags === 2 /* HasVNodeChildren */) { - unmount(children); - } - } - else if (children) { - if (flags & 4 /* ComponentClass */) { - if (isFunction(children.componentWillUnmount)) { - children.componentWillUnmount(); - } - unmountRef(vNode.ref); - children.$UN = true; - unmount(children.$LI); - } - else if (flags & 8 /* ComponentFunction */) { - ref = vNode.ref; - if (!isNullOrUndef(ref) && isFunction(ref.onComponentWillUnmount)) { - ref.onComponentWillUnmount(findDOMfromVNode(vNode, true), vNode.props || EMPTY_OBJ); - } - unmount(children); - } - else if (flags & 1024 /* Portal */) { - remove(children, vNode.ref); - } - else if (flags & 8192 /* Fragment */) { - if (vNode.childFlags & 12 /* MultipleChildren */) { - unmountAllChildren(children); - } - } - } - } - function unmountAllChildren(children) { - for (var i = 0, len = children.length; i < len; ++i) { - unmount(children[i]); - } - } - function clearDOM(dom) { - // Optimization for clearing dom - dom.textContent = ''; - } - function removeAllChildren(dom, vNode, children) { - unmountAllChildren(children); - if (vNode.flags & 8192 /* Fragment */) { - removeVNodeDOM(vNode, dom); - } - else { - clearDOM(dom); - } - } - - function wrapLinkEvent(nextValue) { - // This variable makes sure there is no "this" context in callback - var ev = nextValue.event; - return function (e) { - ev(nextValue.data, e); - }; - } - function patchEvent(name, lastValue, nextValue, dom) { - if (isLinkEventObject(nextValue)) { - if (isLastValueSameLinkEvent(lastValue, nextValue)) { - return; - } - nextValue = wrapLinkEvent(nextValue); - } - attachEvent(dom, normalizeEventName(name), nextValue); - } - // We are assuming here that we come from patchProp routine - // -nextAttrValue cannot be null or undefined - function patchStyle(lastAttrValue, nextAttrValue, dom) { - if (isNullOrUndef(nextAttrValue)) { - dom.removeAttribute('style'); - return; - } - var domStyle = dom.style; - var style; - var value; - if (isString(nextAttrValue)) { - domStyle.cssText = nextAttrValue; - return; - } - if (!isNullOrUndef(lastAttrValue) && !isString(lastAttrValue)) { - for (style in nextAttrValue) { - // do not add a hasOwnProperty check here, it affects performance - value = nextAttrValue[style]; - if (value !== lastAttrValue[style]) { - domStyle.setProperty(style, value); - } - } - for (style in lastAttrValue) { - if (isNullOrUndef(nextAttrValue[style])) { - domStyle.removeProperty(style); - } - } - } - else { - for (style in nextAttrValue) { - value = nextAttrValue[style]; - domStyle.setProperty(style, value); - } - } - } - function patchDangerInnerHTML(lastValue, nextValue, lastVNode, dom) { - var lastHtml = (lastValue && lastValue.__html) || ''; - var nextHtml = (nextValue && nextValue.__html) || ''; - if (lastHtml !== nextHtml) { - if (!isNullOrUndef(nextHtml) && !isSameInnerHTML(dom, nextHtml)) { - if (!isNull(lastVNode)) { - if (lastVNode.childFlags & 12 /* MultipleChildren */) { - unmountAllChildren(lastVNode.children); - } - else if (lastVNode.childFlags === 2 /* HasVNodeChildren */) { - unmount(lastVNode.children); - } - lastVNode.children = null; - lastVNode.childFlags = 1 /* HasInvalidChildren */; - } - dom.innerHTML = nextHtml; - } - } - } - function patchProp(prop, lastValue, nextValue, dom, isSVG, hasControlledValue, lastVNode) { - switch (prop) { - case 'children': - case 'childrenType': - case 'className': - case 'defaultValue': - case 'key': - case 'multiple': - case 'ref': - case 'selectedIndex': - break; - case 'autoFocus': - dom.autofocus = !!nextValue; - break; - case 'allowfullscreen': - case 'autoplay': - case 'capture': - case 'checked': - case 'controls': - case 'default': - case 'disabled': - case 'hidden': - case 'indeterminate': - case 'loop': - case 'muted': - case 'novalidate': - case 'open': - case 'readOnly': - case 'required': - case 'reversed': - case 'scoped': - case 'seamless': - case 'selected': - dom[prop] = !!nextValue; - break; - case 'defaultChecked': - case 'value': - case 'volume': - if (hasControlledValue && prop === 'value') { - break; - } - var value = isNullOrUndef(nextValue) ? '' : nextValue; - if (dom[prop] !== value) { - dom[prop] = value; - } - break; - case 'style': - patchStyle(lastValue, nextValue, dom); - break; - case 'dangerouslySetInnerHTML': - patchDangerInnerHTML(lastValue, nextValue, lastVNode, dom); - break; - default: - if (syntheticEvents[prop]) { - handleSyntheticEvent(prop, lastValue, nextValue, dom); - } - else if (prop.charCodeAt(0) === 111 && prop.charCodeAt(1) === 110) { - patchEvent(prop, lastValue, nextValue, dom); - } - else if (isNullOrUndef(nextValue)) { - dom.removeAttribute(prop); - } - else if (isSVG && namespaces[prop]) { - // We optimize for isSVG being false - // If we end up in this path we can read property again - dom.setAttributeNS(namespaces[prop], prop, nextValue); - } - else { - dom.setAttribute(prop, nextValue); - } - break; - } - } - function mountProps(vNode, flags, props, dom, isSVG) { - var hasControlledValue = false; - var isFormElement = (flags & 448 /* FormElement */) > 0; - if (isFormElement) { - hasControlledValue = isControlledFormElement(props); - if (hasControlledValue) { - addFormElementEventHandlers(flags, dom, props); - } - } - for (var prop in props) { - // do not add a hasOwnProperty check here, it affects performance - patchProp(prop, null, props[prop], dom, isSVG, hasControlledValue, null); - } - if (isFormElement) { - processElement(flags, vNode, dom, props, true, hasControlledValue); - } - } - - function renderNewInput(instance, props, context) { - var nextInput = normalizeRoot(instance.render(props, instance.state, context)); - var childContext = context; - if (isFunction(instance.getChildContext)) { - childContext = combineFrom(context, instance.getChildContext()); - } - instance.$CX = childContext; - return nextInput; - } - function createClassComponentInstance(vNode, Component, props, context, isSVG, lifecycle) { - var instance = new Component(props, context); - var usesNewAPI = (instance.$N = Boolean(Component.getDerivedStateFromProps || instance.getSnapshotBeforeUpdate)); - instance.$SVG = isSVG; - instance.$L = lifecycle; - vNode.children = instance; - instance.$BS = false; - instance.context = context; - if (instance.props === EMPTY_OBJ) { - instance.props = props; - } - if (!usesNewAPI) { - if (isFunction(instance.componentWillMount)) { - instance.$BR = true; - instance.componentWillMount(); - var pending = instance.$PS; - if (!isNull(pending)) { - var state = instance.state; - if (isNull(state)) { - instance.state = pending; - } - else { - for (var key in pending) { - state[key] = pending[key]; - } - } - instance.$PS = null; - } - instance.$BR = false; - } - } - else { - instance.state = createDerivedState(instance, props, instance.state); - } - instance.$LI = renderNewInput(instance, props, context); - return instance; - } - function renderFunctionalComponent(vNode, context) { - var props = vNode.props || EMPTY_OBJ; - return vNode.flags & 32768 /* ForwardRef */ ? vNode.type.render(props, vNode.ref, context) : vNode.type(props, context); - } - - function mount(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var flags = (vNode.flags |= 16384 /* InUse */); - if (flags & 481 /* Element */) { - mountElement(vNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (flags & 4 /* ComponentClass */) { - mountClassComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (flags & 8 /* ComponentFunction */) { - mountFunctionalComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle); - mountFunctionalComponentCallbacks(vNode, lifecycle); - } - else if (flags & 512 /* Void */ || flags & 16 /* Text */) { - mountText(vNode, parentDOM, nextNode); - } - else if (flags & 8192 /* Fragment */) { - mountFragment(vNode, context, parentDOM, isSVG, nextNode, lifecycle); - } - else if (flags & 1024 /* Portal */) { - mountPortal(vNode, context, parentDOM, nextNode, lifecycle); - } - else ; - } - function mountPortal(vNode, context, parentDOM, nextNode, lifecycle) { - mount(vNode.children, vNode.ref, context, false, null, lifecycle); - var placeHolderVNode = createVoidVNode(); - mountText(placeHolderVNode, parentDOM, nextNode); - vNode.dom = placeHolderVNode.dom; - } - function mountFragment(vNode, context, parentDOM, isSVG, nextNode, lifecycle) { - var children = vNode.children; - var childFlags = vNode.childFlags; - // When fragment is optimized for multiple children, check if there is no children and change flag to invalid - // This is the only normalization always done, to keep optimization flags API same for fragments and regular elements - if (childFlags & 12 /* MultipleChildren */ && children.length === 0) { - childFlags = vNode.childFlags = 2 /* HasVNodeChildren */; - children = vNode.children = createVoidVNode(); - } - if (childFlags === 2 /* HasVNodeChildren */) { - mount(children, parentDOM, nextNode, isSVG, nextNode, lifecycle); - } - else { - mountArrayChildren(children, parentDOM, context, isSVG, nextNode, lifecycle); - } - } - function mountText(vNode, parentDOM, nextNode) { - var dom = (vNode.dom = document.createTextNode(vNode.children)); - if (!isNull(parentDOM)) { - insertOrAppend(parentDOM, dom, nextNode); - } - } - function mountElement(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var flags = vNode.flags; - var props = vNode.props; - var className = vNode.className; - var childFlags = vNode.childFlags; - var dom = (vNode.dom = documentCreateElement(vNode.type, (isSVG = isSVG || (flags & 32 /* SvgElement */) > 0))); - var children = vNode.children; - if (!isNullOrUndef(className) && className !== '') { - if (isSVG) { - dom.setAttribute('class', className); - } - else { - dom.className = className; - } - } - if (childFlags === 16 /* HasTextChildren */) { - setTextContent(dom, children); - } - else if (childFlags !== 1 /* HasInvalidChildren */) { - var childrenIsSVG = isSVG && vNode.type !== 'foreignObject'; - if (childFlags === 2 /* HasVNodeChildren */) { - if (children.flags & 16384 /* InUse */) { - vNode.children = children = directClone(children); - } - mount(children, dom, context, childrenIsSVG, null, lifecycle); - } - else if (childFlags === 8 /* HasKeyedChildren */ || childFlags === 4 /* HasNonKeyedChildren */) { - mountArrayChildren(children, dom, context, childrenIsSVG, null, lifecycle); - } - } - if (!isNull(parentDOM)) { - insertOrAppend(parentDOM, dom, nextNode); - } - if (!isNull(props)) { - mountProps(vNode, flags, props, dom, isSVG); - } - mountRef(vNode.ref, dom, lifecycle); - } - function mountArrayChildren(children, dom, context, isSVG, nextNode, lifecycle) { - for (var i = 0; i < children.length; ++i) { - var child = children[i]; - if (child.flags & 16384 /* InUse */) { - children[i] = child = directClone(child); - } - mount(child, dom, context, isSVG, nextNode, lifecycle); - } - } - function mountClassComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var instance = createClassComponentInstance(vNode, vNode.type, vNode.props || EMPTY_OBJ, context, isSVG, lifecycle); - mount(instance.$LI, parentDOM, instance.$CX, isSVG, nextNode, lifecycle); - mountClassComponentCallbacks(vNode.ref, instance, lifecycle); - } - function mountFunctionalComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - mount((vNode.children = normalizeRoot(renderFunctionalComponent(vNode, context))), parentDOM, context, isSVG, nextNode, lifecycle); - } - function createClassMountCallback(instance) { - return function () { - instance.componentDidMount(); - }; - } - function mountClassComponentCallbacks(ref, instance, lifecycle) { - mountRef(ref, instance, lifecycle); - if (isFunction(instance.componentDidMount)) { - lifecycle.push(createClassMountCallback(instance)); - } - } - function createOnMountCallback(ref, vNode) { - return function () { - ref.onComponentDidMount(findDOMfromVNode(vNode, true), vNode.props || EMPTY_OBJ); - }; - } - function mountFunctionalComponentCallbacks(vNode, lifecycle) { - var ref = vNode.ref; - if (!isNullOrUndef(ref)) { - safeCall1(ref.onComponentWillMount, vNode.props || EMPTY_OBJ); - if (isFunction(ref.onComponentDidMount)) { - lifecycle.push(createOnMountCallback(ref, vNode)); - } - } - } - - function replaceWithNewNode(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle) { - unmount(lastVNode); - if ((nextVNode.flags & lastVNode.flags & 2033 /* DOMRef */) !== 0) { - mount(nextVNode, null, context, isSVG, null, lifecycle); - // Single DOM operation, when we have dom references available - replaceChild(parentDOM, nextVNode.dom, lastVNode.dom); - } - else { - mount(nextVNode, parentDOM, context, isSVG, findDOMfromVNode(lastVNode, true), lifecycle); - removeVNodeDOM(lastVNode, parentDOM); - } - } - function patch(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var nextFlags = (nextVNode.flags |= 16384 /* InUse */); - if (lastVNode.flags !== nextFlags || lastVNode.type !== nextVNode.type || lastVNode.key !== nextVNode.key || nextFlags & 2048 /* ReCreate */) { - if (lastVNode.flags & 16384 /* InUse */) { - replaceWithNewNode(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle); - } - else { - // Last vNode is not in use, it has crashed at application level. Just mount nextVNode and ignore last one - mount(nextVNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - } - else if (nextFlags & 481 /* Element */) { - patchElement(lastVNode, nextVNode, context, isSVG, nextFlags, lifecycle); - } - else if (nextFlags & 4 /* ComponentClass */) { - patchClassComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (nextFlags & 8 /* ComponentFunction */) { - patchFunctionalComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (nextFlags & 16 /* Text */) { - patchText(lastVNode, nextVNode); - } - else if (nextFlags & 512 /* Void */) { - nextVNode.dom = lastVNode.dom; - } - else if (nextFlags & 8192 /* Fragment */) { - patchFragment(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle); - } - else { - patchPortal(lastVNode, nextVNode, context, lifecycle); - } - } - function patchSingleTextChild(lastChildren, nextChildren, parentDOM) { - if (lastChildren !== nextChildren) { - if (lastChildren !== '') { - parentDOM.firstChild.nodeValue = nextChildren; - } - else { - setTextContent(parentDOM, nextChildren); - } - } - } - function patchContentEditableChildren(dom, nextChildren) { - if (dom.textContent !== nextChildren) { - dom.textContent = nextChildren; - } - } - function patchFragment(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle) { - var lastChildren = lastVNode.children; - var nextChildren = nextVNode.children; - var lastChildFlags = lastVNode.childFlags; - var nextChildFlags = nextVNode.childFlags; - var nextNode = null; - // When fragment is optimized for multiple children, check if there is no children and change flag to invalid - // This is the only normalization always done, to keep optimization flags API same for fragments and regular elements - if (nextChildFlags & 12 /* MultipleChildren */ && nextChildren.length === 0) { - nextChildFlags = nextVNode.childFlags = 2 /* HasVNodeChildren */; - nextChildren = nextVNode.children = createVoidVNode(); - } - var nextIsSingle = (nextChildFlags & 2 /* HasVNodeChildren */) !== 0; - if (lastChildFlags & 12 /* MultipleChildren */) { - var lastLen = lastChildren.length; - // We need to know Fragment's edge node when - if ( - // It uses keyed algorithm - (lastChildFlags & 8 /* HasKeyedChildren */ && nextChildFlags & 8 /* HasKeyedChildren */) || - // It transforms from many to single - nextIsSingle || - // It will append more nodes - (!nextIsSingle && nextChildren.length > lastLen)) { - // When fragment has multiple children there is always at least one vNode - nextNode = findDOMfromVNode(lastChildren[lastLen - 1], false).nextSibling; - } - } - patchChildren(lastChildFlags, nextChildFlags, lastChildren, nextChildren, parentDOM, context, isSVG, nextNode, lastVNode, lifecycle); - } - function patchPortal(lastVNode, nextVNode, context, lifecycle) { - var lastContainer = lastVNode.ref; - var nextContainer = nextVNode.ref; - var nextChildren = nextVNode.children; - patchChildren(lastVNode.childFlags, nextVNode.childFlags, lastVNode.children, nextChildren, lastContainer, context, false, null, lastVNode, lifecycle); - nextVNode.dom = lastVNode.dom; - if (lastContainer !== nextContainer && !isInvalid(nextChildren)) { - var node = nextChildren.dom; - removeChild(lastContainer, node); - appendChild(nextContainer, node); - } - } - function patchElement(lastVNode, nextVNode, context, isSVG, nextFlags, lifecycle) { - var dom = (nextVNode.dom = lastVNode.dom); - var lastProps = lastVNode.props; - var nextProps = nextVNode.props; - var isFormElement = false; - var hasControlledValue = false; - var nextPropsOrEmpty; - isSVG = isSVG || (nextFlags & 32 /* SvgElement */) > 0; - // inlined patchProps -- starts -- - if (lastProps !== nextProps) { - var lastPropsOrEmpty = lastProps || EMPTY_OBJ; - nextPropsOrEmpty = nextProps || EMPTY_OBJ; - if (nextPropsOrEmpty !== EMPTY_OBJ) { - isFormElement = (nextFlags & 448 /* FormElement */) > 0; - if (isFormElement) { - hasControlledValue = isControlledFormElement(nextPropsOrEmpty); - } - for (var prop in nextPropsOrEmpty) { - var lastValue = lastPropsOrEmpty[prop]; - var nextValue = nextPropsOrEmpty[prop]; - if (lastValue !== nextValue) { - patchProp(prop, lastValue, nextValue, dom, isSVG, hasControlledValue, lastVNode); - } - } - } - if (lastPropsOrEmpty !== EMPTY_OBJ) { - for (var prop$1 in lastPropsOrEmpty) { - if (isNullOrUndef(nextPropsOrEmpty[prop$1]) && !isNullOrUndef(lastPropsOrEmpty[prop$1])) { - patchProp(prop$1, lastPropsOrEmpty[prop$1], null, dom, isSVG, hasControlledValue, lastVNode); - } - } - } - } - var nextChildren = nextVNode.children; - var nextClassName = nextVNode.className; - // inlined patchProps -- ends -- - if (lastVNode.className !== nextClassName) { - if (isNullOrUndef(nextClassName)) { - dom.removeAttribute('class'); - } - else if (isSVG) { - dom.setAttribute('class', nextClassName); - } - else { - dom.className = nextClassName; - } - } - if (nextFlags & 4096 /* ContentEditable */) { - patchContentEditableChildren(dom, nextChildren); - } - else { - patchChildren(lastVNode.childFlags, nextVNode.childFlags, lastVNode.children, nextChildren, dom, context, isSVG && nextVNode.type !== 'foreignObject', null, lastVNode, lifecycle); - } - if (isFormElement) { - processElement(nextFlags, nextVNode, dom, nextPropsOrEmpty, false, hasControlledValue); - } - var nextRef = nextVNode.ref; - var lastRef = lastVNode.ref; - if (lastRef !== nextRef) { - unmountRef(lastRef); - mountRef(nextRef, dom, lifecycle); - } - } - function replaceOneVNodeWithMultipleVNodes(lastChildren, nextChildren, parentDOM, context, isSVG, lifecycle) { - unmount(lastChildren); - mountArrayChildren(nextChildren, parentDOM, context, isSVG, findDOMfromVNode(lastChildren, true), lifecycle); - removeVNodeDOM(lastChildren, parentDOM); - } - function patchChildren(lastChildFlags, nextChildFlags, lastChildren, nextChildren, parentDOM, context, isSVG, nextNode, parentVNode, lifecycle) { - switch (lastChildFlags) { - case 2 /* HasVNodeChildren */: - switch (nextChildFlags) { - case 2 /* HasVNodeChildren */: - patch(lastChildren, nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - remove(lastChildren, parentDOM); - break; - case 16 /* HasTextChildren */: - unmount(lastChildren); - setTextContent(parentDOM, nextChildren); - break; - default: - replaceOneVNodeWithMultipleVNodes(lastChildren, nextChildren, parentDOM, context, isSVG, lifecycle); - break; - } - break; - case 1 /* HasInvalidChildren */: - switch (nextChildFlags) { - case 2 /* HasVNodeChildren */: - mount(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - break; - case 16 /* HasTextChildren */: - setTextContent(parentDOM, nextChildren); - break; - default: - mountArrayChildren(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - } - break; - case 16 /* HasTextChildren */: - switch (nextChildFlags) { - case 16 /* HasTextChildren */: - patchSingleTextChild(lastChildren, nextChildren, parentDOM); - break; - case 2 /* HasVNodeChildren */: - clearDOM(parentDOM); - mount(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - clearDOM(parentDOM); - break; - default: - clearDOM(parentDOM); - mountArrayChildren(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - } - break; - default: - switch (nextChildFlags) { - case 16 /* HasTextChildren */: - unmountAllChildren(lastChildren); - setTextContent(parentDOM, nextChildren); - break; - case 2 /* HasVNodeChildren */: - removeAllChildren(parentDOM, parentVNode, lastChildren); - mount(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - removeAllChildren(parentDOM, parentVNode, lastChildren); - break; - default: - var lastLength = lastChildren.length | 0; - var nextLength = nextChildren.length | 0; - // Fast path's for both algorithms - if (lastLength === 0) { - if (nextLength > 0) { - mountArrayChildren(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - } - } - else if (nextLength === 0) { - removeAllChildren(parentDOM, parentVNode, lastChildren); - } - else if (nextChildFlags === 8 /* HasKeyedChildren */ && lastChildFlags === 8 /* HasKeyedChildren */) { - patchKeyedChildren(lastChildren, nextChildren, parentDOM, context, isSVG, lastLength, nextLength, nextNode, parentVNode, lifecycle); - } - else { - patchNonKeyedChildren(lastChildren, nextChildren, parentDOM, context, isSVG, lastLength, nextLength, nextNode, lifecycle); - } - break; - } - break; - } - } - function createDidUpdate(instance, lastProps, lastState, snapshot, lifecycle) { - lifecycle.push(function () { - instance.componentDidUpdate(lastProps, lastState, snapshot); - }); - } - function updateClassComponent(instance, nextState, nextProps, parentDOM, context, isSVG, force, nextNode, lifecycle) { - var lastState = instance.state; - var lastProps = instance.props; - var usesNewAPI = Boolean(instance.$N); - var hasSCU = isFunction(instance.shouldComponentUpdate); - if (usesNewAPI) { - nextState = createDerivedState(instance, nextProps, nextState !== lastState ? combineFrom(lastState, nextState) : nextState); - } - if (force || !hasSCU || (hasSCU && instance.shouldComponentUpdate(nextProps, nextState, context))) { - if (!usesNewAPI && isFunction(instance.componentWillUpdate)) { - instance.componentWillUpdate(nextProps, nextState, context); - } - instance.props = nextProps; - instance.state = nextState; - instance.context = context; - var snapshot = null; - var nextInput = renderNewInput(instance, nextProps, context); - if (usesNewAPI && isFunction(instance.getSnapshotBeforeUpdate)) { - snapshot = instance.getSnapshotBeforeUpdate(lastProps, lastState); - } - patch(instance.$LI, nextInput, parentDOM, instance.$CX, isSVG, nextNode, lifecycle); - // Dont update Last input, until patch has been succesfully executed - instance.$LI = nextInput; - if (isFunction(instance.componentDidUpdate)) { - createDidUpdate(instance, lastProps, lastState, snapshot, lifecycle); - } - } - else { - instance.props = nextProps; - instance.state = nextState; - instance.context = context; - } - } - function patchClassComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var instance = (nextVNode.children = lastVNode.children); - // If Component has crashed, ignore it to stay functional - if (isNull(instance)) { - return; - } - instance.$L = lifecycle; - var nextProps = nextVNode.props || EMPTY_OBJ; - var nextRef = nextVNode.ref; - var lastRef = lastVNode.ref; - var nextState = instance.state; - if (!instance.$N) { - if (isFunction(instance.componentWillReceiveProps)) { - instance.$BR = true; - instance.componentWillReceiveProps(nextProps, context); - // If instance component was removed during its own update do nothing. - if (instance.$UN) { - return; - } - instance.$BR = false; - } - if (!isNull(instance.$PS)) { - nextState = combineFrom(nextState, instance.$PS); - instance.$PS = null; - } - } - updateClassComponent(instance, nextState, nextProps, parentDOM, context, isSVG, false, nextNode, lifecycle); - if (lastRef !== nextRef) { - unmountRef(lastRef); - mountRef(nextRef, instance, lifecycle); - } - } - function patchFunctionalComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var shouldUpdate = true; - var nextProps = nextVNode.props || EMPTY_OBJ; - var nextRef = nextVNode.ref; - var lastProps = lastVNode.props; - var nextHooksDefined = !isNullOrUndef(nextRef); - var lastInput = lastVNode.children; - if (nextHooksDefined && isFunction(nextRef.onComponentShouldUpdate)) { - shouldUpdate = nextRef.onComponentShouldUpdate(lastProps, nextProps); - } - if (shouldUpdate !== false) { - if (nextHooksDefined && isFunction(nextRef.onComponentWillUpdate)) { - nextRef.onComponentWillUpdate(lastProps, nextProps); - } - var nextInput = normalizeRoot(renderFunctionalComponent(nextVNode, context)); - patch(lastInput, nextInput, parentDOM, context, isSVG, nextNode, lifecycle); - nextVNode.children = nextInput; - if (nextHooksDefined && isFunction(nextRef.onComponentDidUpdate)) { - nextRef.onComponentDidUpdate(lastProps, nextProps); - } - } - else { - nextVNode.children = lastInput; - } - } - function patchText(lastVNode, nextVNode) { - var nextText = nextVNode.children; - var dom = (nextVNode.dom = lastVNode.dom); - if (nextText !== lastVNode.children) { - dom.nodeValue = nextText; - } - } - function patchNonKeyedChildren(lastChildren, nextChildren, dom, context, isSVG, lastChildrenLength, nextChildrenLength, nextNode, lifecycle) { - var commonLength = lastChildrenLength > nextChildrenLength ? nextChildrenLength : lastChildrenLength; - var i = 0; - var nextChild; - var lastChild; - for (; i < commonLength; ++i) { - nextChild = nextChildren[i]; - lastChild = lastChildren[i]; - if (nextChild.flags & 16384 /* InUse */) { - nextChild = nextChildren[i] = directClone(nextChild); - } - patch(lastChild, nextChild, dom, context, isSVG, nextNode, lifecycle); - lastChildren[i] = nextChild; - } - if (lastChildrenLength < nextChildrenLength) { - for (i = commonLength; i < nextChildrenLength; ++i) { - nextChild = nextChildren[i]; - if (nextChild.flags & 16384 /* InUse */) { - nextChild = nextChildren[i] = directClone(nextChild); - } - mount(nextChild, dom, context, isSVG, nextNode, lifecycle); - } - } - else if (lastChildrenLength > nextChildrenLength) { - for (i = commonLength; i < lastChildrenLength; ++i) { - remove(lastChildren[i], dom); - } - } - } - function patchKeyedChildren(a, b, dom, context, isSVG, aLength, bLength, outerEdge, parentVNode, lifecycle) { - var aEnd = aLength - 1; - var bEnd = bLength - 1; - var j = 0; - var aNode = a[j]; - var bNode = b[j]; - var nextPos; - var nextNode; - // Step 1 - // tslint:disable-next-line - outer: { - // Sync nodes with the same key at the beginning. - while (aNode.key === bNode.key) { - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - a[j] = bNode; - ++j; - if (j > aEnd || j > bEnd) { - break outer; - } - aNode = a[j]; - bNode = b[j]; - } - aNode = a[aEnd]; - bNode = b[bEnd]; - // Sync nodes with the same key at the end. - while (aNode.key === bNode.key) { - if (bNode.flags & 16384 /* InUse */) { - b[bEnd] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - a[aEnd] = bNode; - aEnd--; - bEnd--; - if (j > aEnd || j > bEnd) { - break outer; - } - aNode = a[aEnd]; - bNode = b[bEnd]; - } - } - if (j > aEnd) { - if (j <= bEnd) { - nextPos = bEnd + 1; - nextNode = nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge; - while (j <= bEnd) { - bNode = b[j]; - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - ++j; - mount(bNode, dom, context, isSVG, nextNode, lifecycle); - } - } - } - else if (j > bEnd) { - while (j <= aEnd) { - remove(a[j++], dom); - } - } - else { - patchKeyedChildrenComplex(a, b, context, aLength, bLength, aEnd, bEnd, j, dom, isSVG, outerEdge, parentVNode, lifecycle); - } - } - function patchKeyedChildrenComplex(a, b, context, aLength, bLength, aEnd, bEnd, j, dom, isSVG, outerEdge, parentVNode, lifecycle) { - var aNode; - var bNode; - var nextPos; - var i = 0; - var aStart = j; - var bStart = j; - var aLeft = aEnd - j + 1; - var bLeft = bEnd - j + 1; - var sources = new Int32Array(bLeft + 1); - // Keep track if its possible to remove whole DOM using textContent = ''; - var canRemoveWholeContent = aLeft === aLength; - var moved = false; - var pos = 0; - var patched = 0; - // When sizes are small, just loop them through - if (bLength < 4 || (aLeft | bLeft) < 32) { - for (i = aStart; i <= aEnd; ++i) { - aNode = a[i]; - if (patched < bLeft) { - for (j = bStart; j <= bEnd; j++) { - bNode = b[j]; - if (aNode.key === bNode.key) { - sources[j - bStart] = i + 1; - if (canRemoveWholeContent) { - canRemoveWholeContent = false; - while (aStart < i) { - remove(a[aStart++], dom); - } - } - if (pos > j) { - moved = true; - } - else { - pos = j; - } - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - ++patched; - break; - } - } - if (!canRemoveWholeContent && j > bEnd) { - remove(aNode, dom); - } - } - else if (!canRemoveWholeContent) { - remove(aNode, dom); - } - } - } - else { - var keyIndex = {}; - // Map keys by their index - for (i = bStart; i <= bEnd; ++i) { - keyIndex[b[i].key] = i; - } - // Try to patch same keys - for (i = aStart; i <= aEnd; ++i) { - aNode = a[i]; - if (patched < bLeft) { - j = keyIndex[aNode.key]; - if (j !== void 0) { - if (canRemoveWholeContent) { - canRemoveWholeContent = false; - while (i > aStart) { - remove(a[aStart++], dom); - } - } - sources[j - bStart] = i + 1; - if (pos > j) { - moved = true; - } - else { - pos = j; - } - bNode = b[j]; - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - ++patched; - } - else if (!canRemoveWholeContent) { - remove(aNode, dom); - } - } - else if (!canRemoveWholeContent) { - remove(aNode, dom); - } - } - } - // fast-path: if nothing patched remove all old and add all new - if (canRemoveWholeContent) { - removeAllChildren(dom, parentVNode, a); - mountArrayChildren(b, dom, context, isSVG, outerEdge, lifecycle); - } - else if (moved) { - var seq = lis_algorithm(sources); - j = seq.length - 1; - for (i = bLeft - 1; i >= 0; i--) { - if (sources[i] === 0) { - pos = i + bStart; - bNode = b[pos]; - if (bNode.flags & 16384 /* InUse */) { - b[pos] = bNode = directClone(bNode); - } - nextPos = pos + 1; - mount(bNode, dom, context, isSVG, nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge, lifecycle); - } - else if (j < 0 || i !== seq[j]) { - pos = i + bStart; - bNode = b[pos]; - nextPos = pos + 1; - moveVNodeDOM(bNode, dom, nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge); - } - else { - j--; - } - } - } - else if (patched !== bLeft) { - // when patched count doesn't match b length we need to insert those new ones - // loop backwards so we can use insertBefore - for (i = bLeft - 1; i >= 0; i--) { - if (sources[i] === 0) { - pos = i + bStart; - bNode = b[pos]; - if (bNode.flags & 16384 /* InUse */) { - b[pos] = bNode = directClone(bNode); - } - nextPos = pos + 1; - mount(bNode, dom, context, isSVG, nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge, lifecycle); - } - } - } - } - var result; - var p; - var maxLen = 0; - // https://en.wikipedia.org/wiki/Longest_increasing_subsequence - function lis_algorithm(arr) { - var arrI = 0; - var i = 0; - var j = 0; - var k = 0; - var u = 0; - var v = 0; - var c = 0; - var len = arr.length; - if (len > maxLen) { - maxLen = len; - result = new Int32Array(len); - p = new Int32Array(len); - } - for (; i < len; ++i) { - arrI = arr[i]; - if (arrI !== 0) { - j = result[k]; - if (arr[j] < arrI) { - p[i] = j; - result[++k] = i; - continue; - } - u = 0; - v = k; - while (u < v) { - c = (u + v) >> 1; - if (arr[result[c]] < arrI) { - u = c + 1; - } - else { - v = c; - } - } - if (arrI < arr[result[u]]) { - if (u > 0) { - p[i] = result[u - 1]; - } - result[u] = i; - } - } - } - u = k + 1; - var seq = new Int32Array(u); - v = result[u - 1]; - while (u-- > 0) { - seq[u] = v; - v = p[v]; - result[u] = 0; - } - return seq; - } - - var hasDocumentAvailable = typeof document !== 'undefined'; - if (hasDocumentAvailable) { - /* - * Defining $EV and $V properties on Node.prototype - * fixes v8 "wrong map" de-optimization - */ - if (window.Node) { - Node.prototype.$EV = null; - Node.prototype.$V = null; - } - } - function __render(input, parentDOM, callback, context) { - var lifecycle = []; - var rootInput = parentDOM.$V; - if (isNullOrUndef(rootInput)) { - if (!isNullOrUndef(input)) { - if (input.flags & 16384 /* InUse */) { - input = directClone(input); - } - mount(input, parentDOM, context, false, null, lifecycle); - parentDOM.$V = input; - rootInput = input; - } - } - else { - if (isNullOrUndef(input)) { - remove(rootInput, parentDOM); - parentDOM.$V = null; - } - else { - if (input.flags & 16384 /* InUse */) { - input = directClone(input); - } - patch(rootInput, input, parentDOM, context, false, null, lifecycle); - rootInput = parentDOM.$V = input; - } - } - callAll(lifecycle); - if (isFunction(callback)) { - callback(); - } - if (isFunction(options.renderComplete)) { - options.renderComplete(rootInput, parentDOM); - } - } - function render(input, parentDOM, callback, context) { - if ( callback === void 0 ) callback = null; - if ( context === void 0 ) context = EMPTY_OBJ; - - __render(input, parentDOM, callback, context); - } - typeof Promise !== 'undefined' - ? Promise.resolve().then.bind(Promise.resolve()) - : function (a) { - window.setTimeout(a, 0); - }; - - var elem = document.getElementById('app'); - startFPSMonitor(); - startMemMonitor(); - initProfiler('view update'); - - function renderBenchmark(dbs) { - var length = dbs.length; - var databases = []; - - for (var i = 0; i < length; i++) { - var db = dbs[i]; - var lastSample = db.lastSample; - var children = [createVNode(1, 'td', 'dbname', db.dbname, 16, null, null, null), createVNode(1, 'td', 'query-count', createVNode(1, 'span', lastSample.countClassName, lastSample.nbQueries, 16, null, null, null), 2, null, null, null)]; - - for (var i2 = 0; i2 < 5; i2++) { - var query = lastSample.topFiveQueries[i2]; - children.push(createVNode(1, 'td', query.elapsedClassName, [createVNode(1, 'div', null, query.formatElapsed, 16, null, null, null), createVNode(1, 'div', 'popover left', [createVNode(1, 'div', 'popover-content', query.query, 16, null, null, null), createVNode(1, 'div', 'arrow', null, 1, null, null, null)], 4, null, null, null)], 4, null, null, null)); - } - - databases.push(createVNode(1, 'tr', null, children, 4, null, null, null)); - } - - render(createVNode(1, 'table', 'table table-striped', createVNode(1, 'tbody', null, databases, 4, null, null, null), 2, null, null, null), elem); - } - - function loop() { - var dbs = ENV.generateData(false).toArray(); - startProfile('view update'); - renderBenchmark(dbs); - endProfile('view update'); - } - - setInterval(loop, 0); - -}()); +!function(){"use strict";var e,n,t=function(e,n,t,r){this.min=e,this.max=n,this.mean=t,this.last=r},r=function(){function e(e){this.samples=[],this.maxSamples=e,this._i=-1}return e.prototype.addSample=function(e){this._i=(this._i+1)%this.maxSamples,this.samples[this._i]=e},e.prototype.each=function(e){for(var n=this.samples,t=0;tr&&(r=a),i+=a}var o=e[this._i],u=i/e.length;return new t(n,r,u,o)},e}(),i=[],l=-1,a=(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var t in n)n.hasOwnProperty(t)&&(e[t]=n[t])},function(n,t){function r(){this.constructor=n}e(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=function(){function e(e){var n=this;this._sync=function(){n.sync(),n._dirty=!1},this.name=e,this.element=document.createElement("div"),this.element.style.cssText="padding: 2px;background-color: #020;font-family: monospace;font-size: 12px;color: #0f0",this._dirty=!1,this.invalidate()}return e.prototype.invalidate=function(){var e;this._dirty||(this._dirty=!0,e=this._sync,i.push(e),-1===l&&requestAnimationFrame((function(e){l=-1;var n=i;i=[];for(var t=0;t0,c=b(o),s=x(o)&&o[0]===D;u||c||s?(t=t||n.slice(0,l),(u||s)&&(a=G(a)),(c||s)&&(a.key=D+l),t.push(a)):t&&t.push(a),a.flags|=65536}}r=0===(t=t||n).length?1:8}else(t=n).flags|=65536,81920&n.flags&&(t=G(n)),r=2;return e.children=t,e.childFlags=r,e}function Q(e){if(g(e)||v(e))return R(e,null);if(h(e))return j(e,0,null);return 16384&e.flags?G(e):e}var J="http://www.w3.org/1999/xlink",Y="http://www.w3.org/XML/1998/namespace",Z={"xlink:actuate":J,"xlink:arcrole":J,"xlink:href":J,"xlink:role":J,"xlink:show":J,"xlink:title":J,"xlink:type":J,"xml:base":Y,"xml:lang":Y,"xml:space":Y};function ee(e){return{onClick:e,onDblClick:e,onFocusIn:e,onFocusOut:e,onKeyDown:e,onKeyPress:e,onKeyUp:e,onMouseDown:e,onMouseMove:e,onMouseUp:e,onTouchEnd:e,onTouchMove:e,onTouchStart:e}}var ne=ee(0),te=ee(null),re=ee(!0);function ie(e,n){var t=n.$EV;return t||(t=n.$EV=ee(null)),t[e]||1===++ne[e]&&(te[e]=ve(e)),t}function le(e,n){var t=n.$EV;t&&t[e]&&(0===--ne[e]&&(document.removeEventListener($(e),te[e]),te[e]=null),t[e]=null)}function ae(e,n,t,r){if(y(t))ie(e,r)[e]=t;else if(C(t)){if(A(n,t))return;ie(e,r)[e]=t}else le(e,r)}function oe(e){return y(e.composedPath)?e.composedPath()[0]:e.target}function ue(e,n,t,r){var i=oe(e);do{if(n&&i.disabled)return;var l=i.$EV;if(l){var a=l[t];if(a&&(r.dom=i,a.event?a.event(a.data,e):a(e),e.cancelBubble))return}i=i.parentNode}while(!b(i))}function ce(){this.cancelBubble=!0,this.immediatePropagationStopped||this.stopImmediatePropagation()}function se(){return this.defaultPrevented}function fe(){return this.cancelBubble}function de(e){var n={dom:document};return e.isDefaultPrevented=se,e.isPropagationStopped=fe,e.stopPropagation=ce,Object.defineProperty(e,"currentTarget",{configurable:!0,get:function(){return n.dom}}),n}function pe(e){return function(n){if(0!==n.button)return void n.stopPropagation();ue(n,!0,e,de(n))}}function he(e){return function(n){ue(n,!1,e,de(n))}}function ve(e){var n="onClick"===e||"onDblClick"===e?pe(e):he(e);return document.addEventListener($(e),n),n}function me(e,n){var t=document.createElement("i");return t.innerHTML=n,t.innerHTML===e.innerHTML}function ge(e,n,t){if(e[n]){var r=e[n];r.event?r.event(r.data,t):r(t)}else{var i=n.toLowerCase();e[i]&&e[i](t)}}function ye(e,n){var t=function(t){var r=this.$V;if(!r)return;var i=r.props||w,l=r.dom;if(x(e))ge(i,e,t);else for(var a=0;a-1&&n.options[l]&&(a=n.options[l].value),t&&m(a)&&(a=e.defaultValue),Te(r,a)}}var Ne,Ee,He=ye("onInput",Ie),Le=ye("onChange");function _e(e,n){xe(e,"input",He),n.onChange&&xe(e,"change",Le)}function Ie(e,n,t){var r=e.value,i=n.value;if(m(r)){if(t){var l=e.defaultValue;m(l)||l===i||(n.defaultValue=l,n.value=l)}}else i!==r&&(n.defaultValue=r,n.value=r)}function Ue(e,n,t,r,i,l){64&e?Fe(r,t):256&e?Ve(r,t,i,n):128&e&&Ie(r,t,i),l&&(t.$V=n)}function Ae(e,n,t){64&e?$e(n,t):256&e?Pe(n):128&e&&_e(n,t)}function Be(e){return e.type&&be(e.type)?!m(e.checked):!m(e.value)}function De(e){e&&!B(e,null)&&e.current&&(e.current=null)}function We(e,n,t){e&&(y(e)||void 0!==e.current)&&t.push((function(){B(e,n)||void 0===e.current||(e.current=n)}))}function Oe(e,n){Re(e),H(e,n)}function Re(e){var n,t=e.flags,r=e.children;if(481&t){n=e.ref;var i=e.props;De(n);var l=e.childFlags;if(!b(i))for(var a=Object.keys(i),o=0,u=a.length;o0;for(var o in a&&(l=Be(t))&&Ae(n,r,t),t)Je(o,null,t[o],r,i,l,null);a&&Ue(n,e,r,t,!0,l)}function Ze(e,n,t){var r=Q(e.render(n,e.state,t)),i=t;return y(e.getChildContext)&&(i=k(t,e.getChildContext())),e.$CX=i,r}function en(e,n,t,r,i,l){var a=new n(t,r),o=a.$N=Boolean(n.getDerivedStateFromProps||a.getSnapshotBeforeUpdate);if(a.$SVG=i,a.$L=l,e.children=a,a.$BS=!1,a.context=r,a.props===w&&(a.props=t),o)a.state=_(a,t,a.state);else if(y(a.componentWillMount)){a.$BR=!0,a.componentWillMount();var u=a.$PS;if(!b(u)){var c=a.state;if(b(c))a.state=u;else for(var s in u)c[s]=u[s];a.$PS=null}a.$BR=!1}return a.$LI=Ze(a,t,r),a}function nn(e,n){var t=e.props||w;return 32768&e.flags?e.type.render(t,e.ref,n):e.type(t,n)}function tn(e,n,t,r,i,l){var a=e.flags|=16384;481&a?on(e,n,t,r,i,l):4&a?cn(e,n,t,r,i,l):8&a?(sn(e,n,t,r,i,l),hn(e,l)):512&a||16&a?an(e,n,i):8192&a?ln(e,t,n,r,i,l):1024&a&&rn(e,t,n,i,l)}function rn(e,n,t,r,i){tn(e.children,e.ref,n,!1,null,i);var l=X();an(l,t,r),e.dom=l.dom}function ln(e,n,t,r,i,l){var a=e.children,o=e.childFlags;12&o&&0===a.length&&(o=e.childFlags=2,a=e.children=X()),2===o?tn(a,t,i,r,i,l):un(a,t,n,r,i,l)}function an(e,n,t){var r=e.dom=document.createTextNode(e.children);b(n)||T(n,r,t)}function on(e,n,t,r,i,l){var a=e.flags,o=e.props,u=e.className,c=e.childFlags,s=e.dom=M(e.type,r=r||(32&a)>0),f=e.children;if(m(u)||""===u||(r?s.setAttribute("class",u):s.className=u),16===c)U(s,f);else if(1!==c){var d=r&&"foreignObject"!==e.type;2===c?(16384&f.flags&&(e.children=f=G(f)),tn(f,s,t,d,null,l)):8!==c&&4!==c||un(f,s,t,d,null,l)}b(n)||T(n,s,i),b(o)||Ye(e,a,o,s,r),We(e.ref,s,l)}function un(e,n,t,r,i,l){for(var a=0;ad)&&(s=E(a[d-1],!1).nextSibling)}wn(u,c,a,o,t,r,i,s,e,l)}function bn(e,n,t,r){var i=e.ref,l=n.ref,a=n.children;if(wn(e.childFlags,n.childFlags,e.children,a,i,t,!1,null,e,r),n.dom=e.dom,i!==l&&!g(a)){var o=a.dom;P(i,o),F(l,o)}}function kn(e,n,t,r,i,l){var a,o=n.dom=e.dom,u=e.props,c=n.props,s=!1,f=!1;if(r=r||(32&i)>0,u!==c){var d=u||w;if((a=c||w)!==w)for(var p in(s=(448&i)>0)&&(f=Be(a)),a){var h=d[p],v=a[p];h!==v&&Je(p,h,v,o,r,f,e)}if(d!==w)for(var g in d)m(a[g])&&!m(d[g])&&Je(g,d[g],null,o,r,f,e)}var y=n.children,x=n.className;e.className!==x&&(m(x)?o.removeAttribute("class"):r?o.setAttribute("class",x):o.className=x),4096&i?yn(o,y):wn(e.childFlags,n.childFlags,e.children,y,o,t,r&&"foreignObject"!==n.type,null,e,l),s&&Ue(i,n,o,a,!1,f);var b=n.ref,k=e.ref;k!==b&&(De(k),We(b,o,l))}function Cn(e,n,t,r,i,l){Re(e),un(n,t,r,i,E(e,!0),l),H(e,t)}function wn(e,n,t,r,i,l,a,o,u,c){switch(e){case 2:switch(n){case 2:mn(t,r,i,l,a,o,c);break;case 1:Oe(t,i);break;case 16:Re(t),U(i,r);break;default:Cn(t,r,i,l,a,c)}break;case 1:switch(n){case 2:tn(r,i,l,a,o,c);break;case 1:break;case 16:U(i,r);break;default:un(r,i,l,a,o,c)}break;case 16:switch(n){case 16:gn(t,r,i);break;case 2:qe(i),tn(r,i,l,a,o,c);break;case 1:qe(i);break;default:qe(i),un(r,i,l,a,o,c)}break;default:switch(n){case 16:je(t),U(i,r);break;case 2:Ge(i,u,t),tn(r,i,l,a,o,c);break;case 1:Ge(i,u,t);break;default:var s=0|t.length,f=0|r.length;0===s?f>0&&un(r,i,l,a,o,c):0===f?Ge(i,u,t):8===n&&8===e?Vn(t,r,i,l,a,s,f,o,u,c):Pn(t,r,i,l,a,s,f,o,c)}}}function $n(e,n,t,r,i){i.push((function(){e.componentDidUpdate(n,t,r)}))}function Fn(e,n,t,r,i,l,a,o,u){var c=e.state,s=e.props,f=Boolean(e.$N),d=y(e.shouldComponentUpdate);if(f&&(n=_(e,t,n!==c?k(c,n):n)),a||!d||d&&e.shouldComponentUpdate(t,n,i)){!f&&y(e.componentWillUpdate)&&e.componentWillUpdate(t,n,i),e.props=t,e.state=n,e.context=i;var p=null,h=Ze(e,t,i);f&&y(e.getSnapshotBeforeUpdate)&&(p=e.getSnapshotBeforeUpdate(s,c)),mn(e.$LI,h,r,e.$CX,l,o,u),e.$LI=h,y(e.componentDidUpdate)&&$n(e,s,c,p,u)}else e.props=t,e.state=n,e.context=i}function Tn(e,n,t,r,i,l,a){var o=n.children=e.children;if(b(o))return;o.$L=a;var u=n.props||w,c=n.ref,s=e.ref,f=o.state;if(!o.$N){if(y(o.componentWillReceiveProps)){if(o.$BR=!0,o.componentWillReceiveProps(u,r),o.$UN)return;o.$BR=!1}b(o.$PS)||(f=k(f,o.$PS),o.$PS=null)}Fn(o,f,u,t,r,i,!1,l,a),s!==c&&(De(s),We(c,o,a))}function Mn(e,n,t,r,i,l,a){var o=!0,u=n.props||w,c=n.ref,s=e.props,f=!m(c),d=e.children;if(f&&y(c.onComponentShouldUpdate)&&(o=c.onComponentShouldUpdate(s,u)),!1!==o){f&&y(c.onComponentWillUpdate)&&c.onComponentWillUpdate(s,u);var p=Q(nn(n,r));mn(d,p,t,r,i,l,a),n.children=p,f&&y(c.onComponentDidUpdate)&&c.onComponentDidUpdate(s,u)}else n.children=d}function Sn(e,n){var t=n.children,r=n.dom=e.dom;t!==e.children&&(r.nodeValue=t)}function Pn(e,n,t,r,i,l,a,o,u){for(var c,s,f=l>a?a:l,d=0;da)for(d=f;dd||h>p)break e;v=e[h],m=n[h]}for(v=e[d],m=n[p];v.key===m.key;){if(16384&m.flags&&(n[p]=m=G(m)),mn(v,m,t,r,i,o,c),e[d]=m,p--,h>--d||h>p)break e;v=e[d],m=n[p]}}if(h>d){if(h<=p)for(f=(s=p+1)p)for(;h<=d;)Oe(e[h++],t);else Nn(e,n,r,l,a,d,p,h,t,i,o,u,c)}function Nn(e,n,t,r,i,l,a,o,u,c,s,f,d){var p,h,v,m=0,g=o,y=o,x=l-o+1,b=a-o+1,k=new Int32Array(b+1),C=x===r,w=!1,$=0,F=0;if(i<4||(x|b)<32)for(m=g;m<=l;++m)if(p=e[m],Fo?w=!0:$=o,16384&h.flags&&(n[o]=h=G(h)),mn(p,h,u,t,c,s,d),++F;break}!C&&o>a&&Oe(p,u)}else C||Oe(p,u);else{var T={};for(m=y;m<=a;++m)T[n[m].key]=m;for(m=g;m<=l;++m)if(p=e[m],Fg;)Oe(e[g++],u);k[o-y]=m+1,$>o?w=!0:$=o,16384&(h=n[o]).flags&&(n[o]=h=G(h)),mn(p,h,u,t,c,s,d),++F}else C||Oe(p,u);else C||Oe(p,u)}if(C)Ge(u,f,e),un(n,u,t,c,s,d);else if(w){var M=Hn(k);for(o=M.length-1,m=b-1;m>=0;m--)0===k[m]?(16384&(h=n[$=m+y]).flags&&(n[$]=h=G(h)),tn(h,u,t,c,(v=$+1)=0;m--)0===k[m]&&(16384&(h=n[$=m+y]).flags&&(n[$]=h=G(h)),tn(h,u,t,c,(v=$+1)En&&(En=u,Ne=new Int32Array(u),Ee=new Int32Array(u));t>1]]0&&(Ee[t]=Ne[l-1]),Ne[l]=t)}l=i+1;var c=new Int32Array(l);for(a=Ne[l-1];l-- >0;)c[l]=a,a=Ee[a],Ne[l]=0;return c}function Ln(e,n,t,r){var i=[],l=n.$V;m(l)?m(e)||(16384&e.flags&&(e=G(e)),tn(e,n,r,!1,null,i),n.$V=e,l=e):m(e)?(Oe(l,n),n.$V=null):(16384&e.flags&&(e=G(e)),mn(l,e,n,r,!1,null,i),l=n.$V=e),V(i),y(t)&&t(),y(I.renderComplete)&&I.renderComplete(l,n)}"undefined"!==typeof document&&window.Node&&(Node.prototype.$EV=null,Node.prototype.$V=null),"undefined"!==typeof Promise&&Promise.resolve().then.bind(Promise.resolve());var _n=document.getElementById("app");function In(e){for(var n,t,r,i=e.length,l=[],a=0;a0&&(a+=.01652892561983471*(1e3/(n-l)-a)),l=n,t.addSample(a),i.invalidate(),requestAnimationFrame(e)}))}(),function(e){if(void 0===e&&(e=n.HideMin|n.HideMean),s(),void 0===performance.memory)return;var t=new r(100),i=new u("Memory",e,"MB",t);c.appendChild(i.element),function e(){t.addSample(Math.round(performance.memory.usedJSHeapSize/1048576)),i.invalidate(),setTimeout(e,30)}()}(),function(e,n){void 0===n&&(n=0),s();var t=d[e];void 0===t&&(d[e]=t=new f(e,"ms",n),c.appendChild(t.widget.element))}("view update"),setInterval((function(){var e,n=ENV.generateData(!1).toArray();void 0!==(e=d["view update"])&&(e.startTime=performance.now()),In(n),p("view update")}),0)}(); diff --git a/docs/event-test/dist/bundle.js b/docs/event-test/dist/bundle.js index 2b67a36b7..e08e387dc 100644 --- a/docs/event-test/dist/bundle.js +++ b/docs/event-test/dist/bundle.js @@ -1,2143 +1 @@ -(function () { - 'use strict'; - - var isArray = Array.isArray; - function isStringOrNumber(o) { - var type = typeof o; - return type === 'string' || type === 'number'; - } - function isNullOrUndef(o) { - return o === void 0 || o === null; - } - function isInvalid(o) { - return o === null || o === false || o === true || o === void 0; - } - function isFunction(o) { - return typeof o === 'function'; - } - function isString(o) { - return typeof o === 'string'; - } - function isNumber(o) { - return typeof o === 'number'; - } - function isNull(o) { - return o === null; - } - function isUndefined(o) { - return o === void 0; - } - function combineFrom(first, second) { - var out = {}; - if (first) { - for (var key in first) { - out[key] = first[key]; - } - } - if (second) { - for (var key$1 in second) { - out[key$1] = second[key$1]; - } - } - return out; - } - - /** - * Links given data to event as first parameter - * @param {*} data data to be linked, it will be available in function as first parameter - * @param {Function} event Function to be called when event occurs - * @returns {{data: *, event: Function}} - */ - function linkEvent(data, event) { - if (isFunction(event)) { - return { data: data, event: event }; - } - return null; // Return null when event is invalid, to avoid creating unnecessary event handlers - } - // object.event should always be function, otherwise its badly created object. - function isLinkEventObject(o) { - return !isNull(o) && typeof o === 'object'; - } - - // We need EMPTY_OBJ defined in one place. - // Its used for comparison so we cant inline it into shared - var EMPTY_OBJ = {}; - function normalizeEventName(name) { - return name.substr(2).toLowerCase(); - } - function appendChild(parentDOM, dom) { - parentDOM.appendChild(dom); - } - function insertOrAppend(parentDOM, newNode, nextNode) { - if (isNull(nextNode)) { - appendChild(parentDOM, newNode); - } - else { - parentDOM.insertBefore(newNode, nextNode); - } - } - function documentCreateElement(tag, isSVG) { - if (isSVG) { - return document.createElementNS('http://www.w3.org/2000/svg', tag); - } - return document.createElement(tag); - } - function replaceChild(parentDOM, newDom, lastDom) { - parentDOM.replaceChild(newDom, lastDom); - } - function removeChild(parentDOM, childNode) { - parentDOM.removeChild(childNode); - } - function callAll(arrayFn) { - for (var i = 0; i < arrayFn.length; i++) { - arrayFn[i](); - } - } - function findChildVNode(vNode, startEdge, flags) { - var children = vNode.children; - if (flags & 4 /* ComponentClass */) { - return children.$LI; - } - if (flags & 8192 /* Fragment */) { - return vNode.childFlags === 2 /* HasVNodeChildren */ ? children : children[startEdge ? 0 : children.length - 1]; - } - return children; - } - function findDOMfromVNode(vNode, startEdge) { - var flags; - while (vNode) { - flags = vNode.flags; - if (flags & 2033 /* DOMRef */) { - return vNode.dom; - } - vNode = findChildVNode(vNode, startEdge, flags); - } - return null; - } - function removeVNodeDOM(vNode, parentDOM) { - do { - var flags = vNode.flags; - if (flags & 2033 /* DOMRef */) { - removeChild(parentDOM, vNode.dom); - return; - } - var children = vNode.children; - if (flags & 4 /* ComponentClass */) { - vNode = children.$LI; - } - if (flags & 8 /* ComponentFunction */) { - vNode = children; - } - if (flags & 8192 /* Fragment */) { - if (vNode.childFlags === 2 /* HasVNodeChildren */) { - vNode = children; - } - else { - for (var i = 0, len = children.length; i < len; ++i) { - removeVNodeDOM(children[i], parentDOM); - } - return; - } - } - } while (vNode); - } - function moveVNodeDOM(vNode, parentDOM, nextNode) { - do { - var flags = vNode.flags; - if (flags & 2033 /* DOMRef */) { - insertOrAppend(parentDOM, vNode.dom, nextNode); - return; - } - var children = vNode.children; - if (flags & 4 /* ComponentClass */) { - vNode = children.$LI; - } - if (flags & 8 /* ComponentFunction */) { - vNode = children; - } - if (flags & 8192 /* Fragment */) { - if (vNode.childFlags === 2 /* HasVNodeChildren */) { - vNode = children; - } - else { - for (var i = 0, len = children.length; i < len; ++i) { - moveVNodeDOM(children[i], parentDOM, nextNode); - } - return; - } - } - } while (vNode); - } - function createDerivedState(instance, nextProps, state) { - if (instance.constructor.getDerivedStateFromProps) { - return combineFrom(state, instance.constructor.getDerivedStateFromProps(nextProps, state)); - } - return state; - } - var options = { - componentComparator: null, - createVNode: null, - renderComplete: null - }; - function setTextContent(dom, children) { - dom.textContent = children; - } - // Calling this function assumes, nextValue is linkEvent - function isLastValueSameLinkEvent(lastValue, nextValue) { - return (isLinkEventObject(lastValue) && - lastValue.event === nextValue.event && - lastValue.data === nextValue.data); - } - function mergeUnsetProperties(to, from) { - for (var propName in from) { - if (isUndefined(to[propName])) { - to[propName] = from[propName]; - } - } - return to; - } - function safeCall1(method, arg1) { - return !!isFunction(method) && (method(arg1), true); - } - - var keyPrefix = '$'; - function V(childFlags, children, className, flags, key, props, ref, type) { - this.childFlags = childFlags; - this.children = children; - this.className = className; - this.dom = null; - this.flags = flags; - this.key = key === void 0 ? null : key; - this.props = props === void 0 ? null : props; - this.ref = ref === void 0 ? null : ref; - this.type = type; - } - function createVNode(flags, type, className, children, childFlags, props, key, ref) { - var childFlag = childFlags === void 0 ? 1 /* HasInvalidChildren */ : childFlags; - var vNode = new V(childFlag, children, className, flags, key, props, ref, type); - if (childFlag === 0 /* UnknownChildren */) { - normalizeChildren(vNode, vNode.children); - } - return vNode; - } - function mergeDefaultHooks(flags, type, ref) { - if (flags & 4 /* ComponentClass */) { - return ref; - } - var defaultHooks = (flags & 32768 /* ForwardRef */ ? type.render : type).defaultHooks; - if (isNullOrUndef(defaultHooks)) { - return ref; - } - if (isNullOrUndef(ref)) { - return defaultHooks; - } - return mergeUnsetProperties(ref, defaultHooks); - } - function mergeDefaultProps(flags, type, props) { - // set default props - var defaultProps = (flags & 32768 /* ForwardRef */ ? type.render : type).defaultProps; - if (isNullOrUndef(defaultProps)) { - return props; - } - if (isNullOrUndef(props)) { - return combineFrom(defaultProps, null); - } - return mergeUnsetProperties(props, defaultProps); - } - function resolveComponentFlags(flags, type) { - if (flags & 12 /* ComponentKnown */) { - return flags; - } - if (type.prototype && type.prototype.render) { - return 4 /* ComponentClass */; - } - if (type.render) { - return 32776 /* ForwardRefComponent */; - } - return 8 /* ComponentFunction */; - } - function createComponentVNode(flags, type, props, key, ref) { - flags = resolveComponentFlags(flags, type); - var vNode = new V(1 /* HasInvalidChildren */, null, null, flags, key, mergeDefaultProps(flags, type, props), mergeDefaultHooks(flags, type, ref), type); - return vNode; - } - function createTextVNode(text, key) { - return new V(1 /* HasInvalidChildren */, isNullOrUndef(text) || text === true || text === false ? '' : text, null, 16 /* Text */, key, null, null, null); - } - function createFragment(children, childFlags, key) { - var fragment = createVNode(8192 /* Fragment */, 8192 /* Fragment */, null, children, childFlags, null, key, null); - switch (fragment.childFlags) { - case 1 /* HasInvalidChildren */: - fragment.children = createVoidVNode(); - fragment.childFlags = 2 /* HasVNodeChildren */; - break; - case 16 /* HasTextChildren */: - fragment.children = [createTextVNode(children)]; - fragment.childFlags = 4 /* HasNonKeyedChildren */; - break; - } - return fragment; - } - /* - * Fragment is different than normal vNode, - * because when it needs to be cloned we need to clone its children too - * But not normalize, because otherwise those possibly get KEY and re-mount - */ - function cloneFragment(vNodeToClone) { - var oldChildren = vNodeToClone.children; - var childFlags = vNodeToClone.childFlags; - return createFragment(childFlags === 2 /* HasVNodeChildren */ ? directClone(oldChildren) : oldChildren.map(directClone), childFlags, vNodeToClone.key); - } - function directClone(vNodeToClone) { - var flags = vNodeToClone.flags & -16385 /* ClearInUse */; - var props = vNodeToClone.props; - if (flags & 14 /* Component */) { - if (!isNull(props)) { - var propsToClone = props; - props = {}; - for (var key in propsToClone) { - props[key] = propsToClone[key]; - } - } - } - if ((flags & 8192 /* Fragment */) === 0) { - return new V(vNodeToClone.childFlags, vNodeToClone.children, vNodeToClone.className, flags, vNodeToClone.key, props, vNodeToClone.ref, vNodeToClone.type); - } - return cloneFragment(vNodeToClone); - } - function createVoidVNode() { - return createTextVNode('', null); - } - function _normalizeVNodes(nodes, result, index, currentKey) { - for (var len = nodes.length; index < len; index++) { - var n = nodes[index]; - if (!isInvalid(n)) { - var newKey = currentKey + keyPrefix + index; - if (isArray(n)) { - _normalizeVNodes(n, result, 0, newKey); - } - else { - if (isStringOrNumber(n)) { - n = createTextVNode(n, newKey); - } - else { - var oldKey = n.key; - var isPrefixedKey = isString(oldKey) && oldKey[0] === keyPrefix; - if (n.flags & 81920 /* InUseOrNormalized */ || isPrefixedKey) { - n = directClone(n); - } - n.flags |= 65536 /* Normalized */; - if (!isPrefixedKey) { - if (isNull(oldKey)) { - n.key = newKey; - } - else { - n.key = currentKey + oldKey; - } - } - else if (oldKey.substring(0, currentKey.length) !== currentKey) { - n.key = currentKey + oldKey; - } - } - result.push(n); - } - } - } - } - function normalizeChildren(vNode, children) { - var newChildren; - var newChildFlags = 1 /* HasInvalidChildren */; - // Don't change children to match strict equal (===) true in patching - if (isInvalid(children)) { - newChildren = children; - } - else if (isStringOrNumber(children)) { - newChildFlags = 16 /* HasTextChildren */; - newChildren = children; - } - else if (isArray(children)) { - var len = children.length; - for (var i = 0; i < len; ++i) { - var n = children[i]; - if (isInvalid(n) || isArray(n)) { - newChildren = newChildren || children.slice(0, i); - _normalizeVNodes(children, newChildren, i, ''); - break; - } - else if (isStringOrNumber(n)) { - newChildren = newChildren || children.slice(0, i); - newChildren.push(createTextVNode(n, keyPrefix + i)); - } - else { - var key = n.key; - var needsCloning = (n.flags & 81920 /* InUseOrNormalized */) > 0; - var isNullKey = isNull(key); - var isPrefixed = isString(key) && key[0] === keyPrefix; - if (needsCloning || isNullKey || isPrefixed) { - newChildren = newChildren || children.slice(0, i); - if (needsCloning || isPrefixed) { - n = directClone(n); - } - if (isNullKey || isPrefixed) { - n.key = keyPrefix + i; - } - newChildren.push(n); - } - else if (newChildren) { - newChildren.push(n); - } - n.flags |= 65536 /* Normalized */; - } - } - newChildren = newChildren || children; - if (newChildren.length === 0) { - newChildFlags = 1 /* HasInvalidChildren */; - } - else { - newChildFlags = 8 /* HasKeyedChildren */; - } - } - else { - newChildren = children; - newChildren.flags |= 65536 /* Normalized */; - if (children.flags & 81920 /* InUseOrNormalized */) { - newChildren = directClone(children); - } - newChildFlags = 2 /* HasVNodeChildren */; - } - vNode.children = newChildren; - vNode.childFlags = newChildFlags; - return vNode; - } - function normalizeRoot(input) { - if (isInvalid(input) || isStringOrNumber(input)) { - return createTextVNode(input, null); - } - if (isArray(input)) { - return createFragment(input, 0 /* UnknownChildren */, null); - } - return input.flags & 16384 /* InUse */ ? directClone(input) : input; - } - - var xlinkNS = 'http://www.w3.org/1999/xlink'; - var xmlNS = 'http://www.w3.org/XML/1998/namespace'; - var namespaces = { - 'xlink:actuate': xlinkNS, - 'xlink:arcrole': xlinkNS, - 'xlink:href': xlinkNS, - 'xlink:role': xlinkNS, - 'xlink:show': xlinkNS, - 'xlink:title': xlinkNS, - 'xlink:type': xlinkNS, - 'xml:base': xmlNS, - 'xml:lang': xmlNS, - 'xml:space': xmlNS - }; - - function getDelegatedEventObject(v) { - return { - onClick: v, - onDblClick: v, - onFocusIn: v, - onFocusOut: v, - onKeyDown: v, - onKeyPress: v, - onKeyUp: v, - onMouseDown: v, - onMouseMove: v, - onMouseUp: v, - onTouchEnd: v, - onTouchMove: v, - onTouchStart: v - }; - } - var attachedEventCounts = getDelegatedEventObject(0); - var attachedEvents = getDelegatedEventObject(null); - var syntheticEvents = getDelegatedEventObject(true); - function updateOrAddSyntheticEvent(name, dom) { - var eventsObject = dom.$EV; - if (!eventsObject) { - eventsObject = dom.$EV = getDelegatedEventObject(null); - } - if (!eventsObject[name]) { - if (++attachedEventCounts[name] === 1) { - attachedEvents[name] = attachEventToDocument(name); - } - } - return eventsObject; - } - function unmountSyntheticEvent(name, dom) { - var eventsObject = dom.$EV; - if (eventsObject && eventsObject[name]) { - if (--attachedEventCounts[name] === 0) { - document.removeEventListener(normalizeEventName(name), attachedEvents[name]); - attachedEvents[name] = null; - } - eventsObject[name] = null; - } - } - function handleSyntheticEvent(name, lastEvent, nextEvent, dom) { - if (isFunction(nextEvent)) { - updateOrAddSyntheticEvent(name, dom)[name] = nextEvent; - } - else if (isLinkEventObject(nextEvent)) { - if (isLastValueSameLinkEvent(lastEvent, nextEvent)) { - return; - } - updateOrAddSyntheticEvent(name, dom)[name] = nextEvent; - } - else { - unmountSyntheticEvent(name, dom); - } - } - // When browsers fully support event.composedPath we could loop it through instead of using parentNode property - function getTargetNode(event) { - return isFunction(event.composedPath) ? event.composedPath()[0] : event.target; - } - function dispatchEvents(event, isClick, name, eventData) { - var dom = getTargetNode(event); - do { - // Html Nodes can be nested fe: span inside button in that scenario browser does not handle disabled attribute on parent, - // because the event listener is on document.body - // Don't process clicks on disabled elements - if (isClick && dom.disabled) { - return; - } - var eventsObject = dom.$EV; - if (eventsObject) { - var currentEvent = eventsObject[name]; - if (currentEvent) { - // linkEvent object - eventData.dom = dom; - currentEvent.event ? currentEvent.event(currentEvent.data, event) : currentEvent(event); - if (event.cancelBubble) { - return; - } - } - } - dom = dom.parentNode; - } while (!isNull(dom)); - } - function stopPropagation() { - this.cancelBubble = true; - if (!this.immediatePropagationStopped) { - this.stopImmediatePropagation(); - } - } - function isDefaultPrevented() { - return this.defaultPrevented; - } - function isPropagationStopped() { - return this.cancelBubble; - } - function extendEventProperties(event) { - // Event data needs to be object to save reference to currentTarget getter - var eventData = { - dom: document - }; - event.isDefaultPrevented = isDefaultPrevented; - event.isPropagationStopped = isPropagationStopped; - event.stopPropagation = stopPropagation; - Object.defineProperty(event, 'currentTarget', { - configurable: true, - get: function get() { - return eventData.dom; - } - }); - return eventData; - } - function rootClickEvent(name) { - return function (event) { - if (event.button !== 0) { - // Firefox incorrectly triggers click event for mid/right mouse buttons. - // This bug has been active for 17 years. - // https://bugzilla.mozilla.org/show_bug.cgi?id=184051 - event.stopPropagation(); - return; - } - dispatchEvents(event, true, name, extendEventProperties(event)); - }; - } - function rootEvent(name) { - return function (event) { - dispatchEvents(event, false, name, extendEventProperties(event)); - }; - } - function attachEventToDocument(name) { - var attachedEvent = name === 'onClick' || name === 'onDblClick' ? rootClickEvent(name) : rootEvent(name); - document.addEventListener(normalizeEventName(name), attachedEvent); - return attachedEvent; - } - - function isSameInnerHTML(dom, innerHTML) { - var tempdom = document.createElement('i'); - tempdom.innerHTML = innerHTML; - return tempdom.innerHTML === dom.innerHTML; - } - - function triggerEventListener(props, methodName, e) { - if (props[methodName]) { - var listener = props[methodName]; - if (listener.event) { - listener.event(listener.data, e); - } - else { - listener(e); - } - } - else { - var nativeListenerName = methodName.toLowerCase(); - if (props[nativeListenerName]) { - props[nativeListenerName](e); - } - } - } - function createWrappedFunction(methodName, applyValue) { - var fnMethod = function (e) { - var vNode = this.$V; - // If vNode is gone by the time event fires, no-op - if (!vNode) { - return; - } - var props = vNode.props || EMPTY_OBJ; - var dom = vNode.dom; - if (isString(methodName)) { - triggerEventListener(props, methodName, e); - } - else { - for (var i = 0; i < methodName.length; ++i) { - triggerEventListener(props, methodName[i], e); - } - } - if (isFunction(applyValue)) { - var newVNode = this.$V; - var newProps = newVNode.props || EMPTY_OBJ; - applyValue(newProps, dom, false, newVNode); - } - }; - Object.defineProperty(fnMethod, 'wrapped', { - configurable: false, - enumerable: false, - value: true, - writable: false - }); - return fnMethod; - } - - function attachEvent(dom, eventName, handler) { - var previousKey = "$" + eventName; - var previousArgs = dom[previousKey]; - if (previousArgs) { - if (previousArgs[1].wrapped) { - return; - } - dom.removeEventListener(previousArgs[0], previousArgs[1]); - dom[previousKey] = null; - } - if (isFunction(handler)) { - dom.addEventListener(eventName, handler); - dom[previousKey] = [eventName, handler]; - } - } - - function isCheckedType(type) { - return type === 'checkbox' || type === 'radio'; - } - var onTextInputChange = createWrappedFunction('onInput', applyValueInput); - var wrappedOnChange = createWrappedFunction(['onClick', 'onChange'], applyValueInput); - /* tslint:disable-next-line:no-empty */ - function emptywrapper(event) { - event.stopPropagation(); - } - emptywrapper.wrapped = true; - function inputEvents(dom, nextPropsOrEmpty) { - if (isCheckedType(nextPropsOrEmpty.type)) { - attachEvent(dom, 'change', wrappedOnChange); - attachEvent(dom, 'click', emptywrapper); - } - else { - attachEvent(dom, 'input', onTextInputChange); - } - } - function applyValueInput(nextPropsOrEmpty, dom) { - var type = nextPropsOrEmpty.type; - var value = nextPropsOrEmpty.value; - var checked = nextPropsOrEmpty.checked; - var multiple = nextPropsOrEmpty.multiple; - var defaultValue = nextPropsOrEmpty.defaultValue; - var hasValue = !isNullOrUndef(value); - if (type && type !== dom.type) { - dom.setAttribute('type', type); - } - if (!isNullOrUndef(multiple) && multiple !== dom.multiple) { - dom.multiple = multiple; - } - if (!isNullOrUndef(defaultValue) && !hasValue) { - dom.defaultValue = defaultValue + ''; - } - if (isCheckedType(type)) { - if (hasValue) { - dom.value = value; - } - if (!isNullOrUndef(checked)) { - dom.checked = checked; - } - } - else { - if (hasValue && dom.value !== value) { - dom.defaultValue = value; - dom.value = value; - } - else if (!isNullOrUndef(checked)) { - dom.checked = checked; - } - } - } - - function updateChildOptions(vNode, value) { - if (vNode.type === 'option') { - updateChildOption(vNode, value); - } - else { - var children = vNode.children; - var flags = vNode.flags; - if (flags & 4 /* ComponentClass */) { - updateChildOptions(children.$LI, value); - } - else if (flags & 8 /* ComponentFunction */) { - updateChildOptions(children, value); - } - else if (vNode.childFlags === 2 /* HasVNodeChildren */) { - updateChildOptions(children, value); - } - else if (vNode.childFlags & 12 /* MultipleChildren */) { - for (var i = 0, len = children.length; i < len; ++i) { - updateChildOptions(children[i], value); - } - } - } - } - function updateChildOption(vNode, value) { - var props = vNode.props || EMPTY_OBJ; - var dom = vNode.dom; - // we do this as multiple may have changed - dom.value = props.value; - if (props.value === value || (isArray(value) && value.indexOf(props.value) !== -1)) { - dom.selected = true; - } - else if (!isNullOrUndef(value) || !isNullOrUndef(props.selected)) { - dom.selected = props.selected || false; - } - } - var onSelectChange = createWrappedFunction('onChange', applyValueSelect); - function selectEvents(dom) { - attachEvent(dom, 'change', onSelectChange); - } - function applyValueSelect(nextPropsOrEmpty, dom, mounting, vNode) { - var multiplePropInBoolean = Boolean(nextPropsOrEmpty.multiple); - if (!isNullOrUndef(nextPropsOrEmpty.multiple) && multiplePropInBoolean !== dom.multiple) { - dom.multiple = multiplePropInBoolean; - } - var index = nextPropsOrEmpty.selectedIndex; - if (index === -1) { - dom.selectedIndex = -1; - } - var childFlags = vNode.childFlags; - if (childFlags !== 1 /* HasInvalidChildren */) { - var value = nextPropsOrEmpty.value; - if (isNumber(index) && index > -1 && dom.options[index]) { - value = dom.options[index].value; - } - if (mounting && isNullOrUndef(value)) { - value = nextPropsOrEmpty.defaultValue; - } - updateChildOptions(vNode, value); - } - } - - var onTextareaInputChange = createWrappedFunction('onInput', applyValueTextArea); - var wrappedOnChange$1 = createWrappedFunction('onChange'); - function textAreaEvents(dom, nextPropsOrEmpty) { - attachEvent(dom, 'input', onTextareaInputChange); - if (nextPropsOrEmpty.onChange) { - attachEvent(dom, 'change', wrappedOnChange$1); - } - } - function applyValueTextArea(nextPropsOrEmpty, dom, mounting) { - var value = nextPropsOrEmpty.value; - var domValue = dom.value; - if (isNullOrUndef(value)) { - if (mounting) { - var defaultValue = nextPropsOrEmpty.defaultValue; - if (!isNullOrUndef(defaultValue) && defaultValue !== domValue) { - dom.defaultValue = defaultValue; - dom.value = defaultValue; - } - } - } - else if (domValue !== value) { - /* There is value so keep it controlled */ - dom.defaultValue = value; - dom.value = value; - } - } - - function processElement(flags, vNode, dom, nextPropsOrEmpty, mounting, isControlled) { - if (flags & 64 /* InputElement */) { - applyValueInput(nextPropsOrEmpty, dom); - } - else if (flags & 256 /* SelectElement */) { - applyValueSelect(nextPropsOrEmpty, dom, mounting, vNode); - } - else if (flags & 128 /* TextareaElement */) { - applyValueTextArea(nextPropsOrEmpty, dom, mounting); - } - if (isControlled) { - dom.$V = vNode; - } - } - function addFormElementEventHandlers(flags, dom, nextPropsOrEmpty) { - if (flags & 64 /* InputElement */) { - inputEvents(dom, nextPropsOrEmpty); - } - else if (flags & 256 /* SelectElement */) { - selectEvents(dom); - } - else if (flags & 128 /* TextareaElement */) { - textAreaEvents(dom, nextPropsOrEmpty); - } - } - function isControlledFormElement(nextPropsOrEmpty) { - return nextPropsOrEmpty.type && isCheckedType(nextPropsOrEmpty.type) ? !isNullOrUndef(nextPropsOrEmpty.checked) : !isNullOrUndef(nextPropsOrEmpty.value); - } - function unmountRef(ref) { - if (ref) { - if (!safeCall1(ref, null) && ref.current) { - ref.current = null; - } - } - } - function mountRef(ref, value, lifecycle) { - if (ref && (isFunction(ref) || ref.current !== void 0)) { - lifecycle.push(function () { - if (!safeCall1(ref, value) && ref.current !== void 0) { - ref.current = value; - } - }); - } - } - - function remove(vNode, parentDOM) { - unmount(vNode); - removeVNodeDOM(vNode, parentDOM); - } - function unmount(vNode) { - var flags = vNode.flags; - var children = vNode.children; - var ref; - if (flags & 481 /* Element */) { - ref = vNode.ref; - var props = vNode.props; - unmountRef(ref); - var childFlags = vNode.childFlags; - if (!isNull(props)) { - var keys = Object.keys(props); - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i]; - if (syntheticEvents[key]) { - unmountSyntheticEvent(key, vNode.dom); - } - } - } - if (childFlags & 12 /* MultipleChildren */) { - unmountAllChildren(children); - } - else if (childFlags === 2 /* HasVNodeChildren */) { - unmount(children); - } - } - else if (children) { - if (flags & 4 /* ComponentClass */) { - if (isFunction(children.componentWillUnmount)) { - children.componentWillUnmount(); - } - unmountRef(vNode.ref); - children.$UN = true; - unmount(children.$LI); - } - else if (flags & 8 /* ComponentFunction */) { - ref = vNode.ref; - if (!isNullOrUndef(ref) && isFunction(ref.onComponentWillUnmount)) { - ref.onComponentWillUnmount(findDOMfromVNode(vNode, true), vNode.props || EMPTY_OBJ); - } - unmount(children); - } - else if (flags & 1024 /* Portal */) { - remove(children, vNode.ref); - } - else if (flags & 8192 /* Fragment */) { - if (vNode.childFlags & 12 /* MultipleChildren */) { - unmountAllChildren(children); - } - } - } - } - function unmountAllChildren(children) { - for (var i = 0, len = children.length; i < len; ++i) { - unmount(children[i]); - } - } - function clearDOM(dom) { - // Optimization for clearing dom - dom.textContent = ''; - } - function removeAllChildren(dom, vNode, children) { - unmountAllChildren(children); - if (vNode.flags & 8192 /* Fragment */) { - removeVNodeDOM(vNode, dom); - } - else { - clearDOM(dom); - } - } - - function wrapLinkEvent(nextValue) { - // This variable makes sure there is no "this" context in callback - var ev = nextValue.event; - return function (e) { - ev(nextValue.data, e); - }; - } - function patchEvent(name, lastValue, nextValue, dom) { - if (isLinkEventObject(nextValue)) { - if (isLastValueSameLinkEvent(lastValue, nextValue)) { - return; - } - nextValue = wrapLinkEvent(nextValue); - } - attachEvent(dom, normalizeEventName(name), nextValue); - } - // We are assuming here that we come from patchProp routine - // -nextAttrValue cannot be null or undefined - function patchStyle(lastAttrValue, nextAttrValue, dom) { - if (isNullOrUndef(nextAttrValue)) { - dom.removeAttribute('style'); - return; - } - var domStyle = dom.style; - var style; - var value; - if (isString(nextAttrValue)) { - domStyle.cssText = nextAttrValue; - return; - } - if (!isNullOrUndef(lastAttrValue) && !isString(lastAttrValue)) { - for (style in nextAttrValue) { - // do not add a hasOwnProperty check here, it affects performance - value = nextAttrValue[style]; - if (value !== lastAttrValue[style]) { - domStyle.setProperty(style, value); - } - } - for (style in lastAttrValue) { - if (isNullOrUndef(nextAttrValue[style])) { - domStyle.removeProperty(style); - } - } - } - else { - for (style in nextAttrValue) { - value = nextAttrValue[style]; - domStyle.setProperty(style, value); - } - } - } - function patchDangerInnerHTML(lastValue, nextValue, lastVNode, dom) { - var lastHtml = (lastValue && lastValue.__html) || ''; - var nextHtml = (nextValue && nextValue.__html) || ''; - if (lastHtml !== nextHtml) { - if (!isNullOrUndef(nextHtml) && !isSameInnerHTML(dom, nextHtml)) { - if (!isNull(lastVNode)) { - if (lastVNode.childFlags & 12 /* MultipleChildren */) { - unmountAllChildren(lastVNode.children); - } - else if (lastVNode.childFlags === 2 /* HasVNodeChildren */) { - unmount(lastVNode.children); - } - lastVNode.children = null; - lastVNode.childFlags = 1 /* HasInvalidChildren */; - } - dom.innerHTML = nextHtml; - } - } - } - function patchProp(prop, lastValue, nextValue, dom, isSVG, hasControlledValue, lastVNode) { - switch (prop) { - case 'children': - case 'childrenType': - case 'className': - case 'defaultValue': - case 'key': - case 'multiple': - case 'ref': - case 'selectedIndex': - break; - case 'autoFocus': - dom.autofocus = !!nextValue; - break; - case 'allowfullscreen': - case 'autoplay': - case 'capture': - case 'checked': - case 'controls': - case 'default': - case 'disabled': - case 'hidden': - case 'indeterminate': - case 'loop': - case 'muted': - case 'novalidate': - case 'open': - case 'readOnly': - case 'required': - case 'reversed': - case 'scoped': - case 'seamless': - case 'selected': - dom[prop] = !!nextValue; - break; - case 'defaultChecked': - case 'value': - case 'volume': - if (hasControlledValue && prop === 'value') { - break; - } - var value = isNullOrUndef(nextValue) ? '' : nextValue; - if (dom[prop] !== value) { - dom[prop] = value; - } - break; - case 'style': - patchStyle(lastValue, nextValue, dom); - break; - case 'dangerouslySetInnerHTML': - patchDangerInnerHTML(lastValue, nextValue, lastVNode, dom); - break; - default: - if (syntheticEvents[prop]) { - handleSyntheticEvent(prop, lastValue, nextValue, dom); - } - else if (prop.charCodeAt(0) === 111 && prop.charCodeAt(1) === 110) { - patchEvent(prop, lastValue, nextValue, dom); - } - else if (isNullOrUndef(nextValue)) { - dom.removeAttribute(prop); - } - else if (isSVG && namespaces[prop]) { - // We optimize for isSVG being false - // If we end up in this path we can read property again - dom.setAttributeNS(namespaces[prop], prop, nextValue); - } - else { - dom.setAttribute(prop, nextValue); - } - break; - } - } - function mountProps(vNode, flags, props, dom, isSVG) { - var hasControlledValue = false; - var isFormElement = (flags & 448 /* FormElement */) > 0; - if (isFormElement) { - hasControlledValue = isControlledFormElement(props); - if (hasControlledValue) { - addFormElementEventHandlers(flags, dom, props); - } - } - for (var prop in props) { - // do not add a hasOwnProperty check here, it affects performance - patchProp(prop, null, props[prop], dom, isSVG, hasControlledValue, null); - } - if (isFormElement) { - processElement(flags, vNode, dom, props, true, hasControlledValue); - } - } - - function renderNewInput(instance, props, context) { - var nextInput = normalizeRoot(instance.render(props, instance.state, context)); - var childContext = context; - if (isFunction(instance.getChildContext)) { - childContext = combineFrom(context, instance.getChildContext()); - } - instance.$CX = childContext; - return nextInput; - } - function createClassComponentInstance(vNode, Component, props, context, isSVG, lifecycle) { - var instance = new Component(props, context); - var usesNewAPI = (instance.$N = Boolean(Component.getDerivedStateFromProps || instance.getSnapshotBeforeUpdate)); - instance.$SVG = isSVG; - instance.$L = lifecycle; - vNode.children = instance; - instance.$BS = false; - instance.context = context; - if (instance.props === EMPTY_OBJ) { - instance.props = props; - } - if (!usesNewAPI) { - if (isFunction(instance.componentWillMount)) { - instance.$BR = true; - instance.componentWillMount(); - var pending = instance.$PS; - if (!isNull(pending)) { - var state = instance.state; - if (isNull(state)) { - instance.state = pending; - } - else { - for (var key in pending) { - state[key] = pending[key]; - } - } - instance.$PS = null; - } - instance.$BR = false; - } - } - else { - instance.state = createDerivedState(instance, props, instance.state); - } - instance.$LI = renderNewInput(instance, props, context); - return instance; - } - function renderFunctionalComponent(vNode, context) { - var props = vNode.props || EMPTY_OBJ; - return vNode.flags & 32768 /* ForwardRef */ ? vNode.type.render(props, vNode.ref, context) : vNode.type(props, context); - } - - function mount(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var flags = (vNode.flags |= 16384 /* InUse */); - if (flags & 481 /* Element */) { - mountElement(vNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (flags & 4 /* ComponentClass */) { - mountClassComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (flags & 8 /* ComponentFunction */) { - mountFunctionalComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle); - mountFunctionalComponentCallbacks(vNode, lifecycle); - } - else if (flags & 512 /* Void */ || flags & 16 /* Text */) { - mountText(vNode, parentDOM, nextNode); - } - else if (flags & 8192 /* Fragment */) { - mountFragment(vNode, context, parentDOM, isSVG, nextNode, lifecycle); - } - else if (flags & 1024 /* Portal */) { - mountPortal(vNode, context, parentDOM, nextNode, lifecycle); - } - else ; - } - function mountPortal(vNode, context, parentDOM, nextNode, lifecycle) { - mount(vNode.children, vNode.ref, context, false, null, lifecycle); - var placeHolderVNode = createVoidVNode(); - mountText(placeHolderVNode, parentDOM, nextNode); - vNode.dom = placeHolderVNode.dom; - } - function mountFragment(vNode, context, parentDOM, isSVG, nextNode, lifecycle) { - var children = vNode.children; - var childFlags = vNode.childFlags; - // When fragment is optimized for multiple children, check if there is no children and change flag to invalid - // This is the only normalization always done, to keep optimization flags API same for fragments and regular elements - if (childFlags & 12 /* MultipleChildren */ && children.length === 0) { - childFlags = vNode.childFlags = 2 /* HasVNodeChildren */; - children = vNode.children = createVoidVNode(); - } - if (childFlags === 2 /* HasVNodeChildren */) { - mount(children, parentDOM, nextNode, isSVG, nextNode, lifecycle); - } - else { - mountArrayChildren(children, parentDOM, context, isSVG, nextNode, lifecycle); - } - } - function mountText(vNode, parentDOM, nextNode) { - var dom = (vNode.dom = document.createTextNode(vNode.children)); - if (!isNull(parentDOM)) { - insertOrAppend(parentDOM, dom, nextNode); - } - } - function mountElement(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var flags = vNode.flags; - var props = vNode.props; - var className = vNode.className; - var childFlags = vNode.childFlags; - var dom = (vNode.dom = documentCreateElement(vNode.type, (isSVG = isSVG || (flags & 32 /* SvgElement */) > 0))); - var children = vNode.children; - if (!isNullOrUndef(className) && className !== '') { - if (isSVG) { - dom.setAttribute('class', className); - } - else { - dom.className = className; - } - } - if (childFlags === 16 /* HasTextChildren */) { - setTextContent(dom, children); - } - else if (childFlags !== 1 /* HasInvalidChildren */) { - var childrenIsSVG = isSVG && vNode.type !== 'foreignObject'; - if (childFlags === 2 /* HasVNodeChildren */) { - if (children.flags & 16384 /* InUse */) { - vNode.children = children = directClone(children); - } - mount(children, dom, context, childrenIsSVG, null, lifecycle); - } - else if (childFlags === 8 /* HasKeyedChildren */ || childFlags === 4 /* HasNonKeyedChildren */) { - mountArrayChildren(children, dom, context, childrenIsSVG, null, lifecycle); - } - } - if (!isNull(parentDOM)) { - insertOrAppend(parentDOM, dom, nextNode); - } - if (!isNull(props)) { - mountProps(vNode, flags, props, dom, isSVG); - } - mountRef(vNode.ref, dom, lifecycle); - } - function mountArrayChildren(children, dom, context, isSVG, nextNode, lifecycle) { - for (var i = 0; i < children.length; ++i) { - var child = children[i]; - if (child.flags & 16384 /* InUse */) { - children[i] = child = directClone(child); - } - mount(child, dom, context, isSVG, nextNode, lifecycle); - } - } - function mountClassComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var instance = createClassComponentInstance(vNode, vNode.type, vNode.props || EMPTY_OBJ, context, isSVG, lifecycle); - mount(instance.$LI, parentDOM, instance.$CX, isSVG, nextNode, lifecycle); - mountClassComponentCallbacks(vNode.ref, instance, lifecycle); - } - function mountFunctionalComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - mount((vNode.children = normalizeRoot(renderFunctionalComponent(vNode, context))), parentDOM, context, isSVG, nextNode, lifecycle); - } - function createClassMountCallback(instance) { - return function () { - instance.componentDidMount(); - }; - } - function mountClassComponentCallbacks(ref, instance, lifecycle) { - mountRef(ref, instance, lifecycle); - if (isFunction(instance.componentDidMount)) { - lifecycle.push(createClassMountCallback(instance)); - } - } - function createOnMountCallback(ref, vNode) { - return function () { - ref.onComponentDidMount(findDOMfromVNode(vNode, true), vNode.props || EMPTY_OBJ); - }; - } - function mountFunctionalComponentCallbacks(vNode, lifecycle) { - var ref = vNode.ref; - if (!isNullOrUndef(ref)) { - safeCall1(ref.onComponentWillMount, vNode.props || EMPTY_OBJ); - if (isFunction(ref.onComponentDidMount)) { - lifecycle.push(createOnMountCallback(ref, vNode)); - } - } - } - - function replaceWithNewNode(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle) { - unmount(lastVNode); - if ((nextVNode.flags & lastVNode.flags & 2033 /* DOMRef */) !== 0) { - mount(nextVNode, null, context, isSVG, null, lifecycle); - // Single DOM operation, when we have dom references available - replaceChild(parentDOM, nextVNode.dom, lastVNode.dom); - } - else { - mount(nextVNode, parentDOM, context, isSVG, findDOMfromVNode(lastVNode, true), lifecycle); - removeVNodeDOM(lastVNode, parentDOM); - } - } - function patch(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var nextFlags = (nextVNode.flags |= 16384 /* InUse */); - if (lastVNode.flags !== nextFlags || lastVNode.type !== nextVNode.type || lastVNode.key !== nextVNode.key || nextFlags & 2048 /* ReCreate */) { - if (lastVNode.flags & 16384 /* InUse */) { - replaceWithNewNode(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle); - } - else { - // Last vNode is not in use, it has crashed at application level. Just mount nextVNode and ignore last one - mount(nextVNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - } - else if (nextFlags & 481 /* Element */) { - patchElement(lastVNode, nextVNode, context, isSVG, nextFlags, lifecycle); - } - else if (nextFlags & 4 /* ComponentClass */) { - patchClassComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (nextFlags & 8 /* ComponentFunction */) { - patchFunctionalComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (nextFlags & 16 /* Text */) { - patchText(lastVNode, nextVNode); - } - else if (nextFlags & 512 /* Void */) { - nextVNode.dom = lastVNode.dom; - } - else if (nextFlags & 8192 /* Fragment */) { - patchFragment(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle); - } - else { - patchPortal(lastVNode, nextVNode, context, lifecycle); - } - } - function patchSingleTextChild(lastChildren, nextChildren, parentDOM) { - if (lastChildren !== nextChildren) { - if (lastChildren !== '') { - parentDOM.firstChild.nodeValue = nextChildren; - } - else { - setTextContent(parentDOM, nextChildren); - } - } - } - function patchContentEditableChildren(dom, nextChildren) { - if (dom.textContent !== nextChildren) { - dom.textContent = nextChildren; - } - } - function patchFragment(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle) { - var lastChildren = lastVNode.children; - var nextChildren = nextVNode.children; - var lastChildFlags = lastVNode.childFlags; - var nextChildFlags = nextVNode.childFlags; - var nextNode = null; - // When fragment is optimized for multiple children, check if there is no children and change flag to invalid - // This is the only normalization always done, to keep optimization flags API same for fragments and regular elements - if (nextChildFlags & 12 /* MultipleChildren */ && nextChildren.length === 0) { - nextChildFlags = nextVNode.childFlags = 2 /* HasVNodeChildren */; - nextChildren = nextVNode.children = createVoidVNode(); - } - var nextIsSingle = (nextChildFlags & 2 /* HasVNodeChildren */) !== 0; - if (lastChildFlags & 12 /* MultipleChildren */) { - var lastLen = lastChildren.length; - // We need to know Fragment's edge node when - if ( - // It uses keyed algorithm - (lastChildFlags & 8 /* HasKeyedChildren */ && nextChildFlags & 8 /* HasKeyedChildren */) || - // It transforms from many to single - nextIsSingle || - // It will append more nodes - (!nextIsSingle && nextChildren.length > lastLen)) { - // When fragment has multiple children there is always at least one vNode - nextNode = findDOMfromVNode(lastChildren[lastLen - 1], false).nextSibling; - } - } - patchChildren(lastChildFlags, nextChildFlags, lastChildren, nextChildren, parentDOM, context, isSVG, nextNode, lastVNode, lifecycle); - } - function patchPortal(lastVNode, nextVNode, context, lifecycle) { - var lastContainer = lastVNode.ref; - var nextContainer = nextVNode.ref; - var nextChildren = nextVNode.children; - patchChildren(lastVNode.childFlags, nextVNode.childFlags, lastVNode.children, nextChildren, lastContainer, context, false, null, lastVNode, lifecycle); - nextVNode.dom = lastVNode.dom; - if (lastContainer !== nextContainer && !isInvalid(nextChildren)) { - var node = nextChildren.dom; - removeChild(lastContainer, node); - appendChild(nextContainer, node); - } - } - function patchElement(lastVNode, nextVNode, context, isSVG, nextFlags, lifecycle) { - var dom = (nextVNode.dom = lastVNode.dom); - var lastProps = lastVNode.props; - var nextProps = nextVNode.props; - var isFormElement = false; - var hasControlledValue = false; - var nextPropsOrEmpty; - isSVG = isSVG || (nextFlags & 32 /* SvgElement */) > 0; - // inlined patchProps -- starts -- - if (lastProps !== nextProps) { - var lastPropsOrEmpty = lastProps || EMPTY_OBJ; - nextPropsOrEmpty = nextProps || EMPTY_OBJ; - if (nextPropsOrEmpty !== EMPTY_OBJ) { - isFormElement = (nextFlags & 448 /* FormElement */) > 0; - if (isFormElement) { - hasControlledValue = isControlledFormElement(nextPropsOrEmpty); - } - for (var prop in nextPropsOrEmpty) { - var lastValue = lastPropsOrEmpty[prop]; - var nextValue = nextPropsOrEmpty[prop]; - if (lastValue !== nextValue) { - patchProp(prop, lastValue, nextValue, dom, isSVG, hasControlledValue, lastVNode); - } - } - } - if (lastPropsOrEmpty !== EMPTY_OBJ) { - for (var prop$1 in lastPropsOrEmpty) { - if (isNullOrUndef(nextPropsOrEmpty[prop$1]) && !isNullOrUndef(lastPropsOrEmpty[prop$1])) { - patchProp(prop$1, lastPropsOrEmpty[prop$1], null, dom, isSVG, hasControlledValue, lastVNode); - } - } - } - } - var nextChildren = nextVNode.children; - var nextClassName = nextVNode.className; - // inlined patchProps -- ends -- - if (lastVNode.className !== nextClassName) { - if (isNullOrUndef(nextClassName)) { - dom.removeAttribute('class'); - } - else if (isSVG) { - dom.setAttribute('class', nextClassName); - } - else { - dom.className = nextClassName; - } - } - if (nextFlags & 4096 /* ContentEditable */) { - patchContentEditableChildren(dom, nextChildren); - } - else { - patchChildren(lastVNode.childFlags, nextVNode.childFlags, lastVNode.children, nextChildren, dom, context, isSVG && nextVNode.type !== 'foreignObject', null, lastVNode, lifecycle); - } - if (isFormElement) { - processElement(nextFlags, nextVNode, dom, nextPropsOrEmpty, false, hasControlledValue); - } - var nextRef = nextVNode.ref; - var lastRef = lastVNode.ref; - if (lastRef !== nextRef) { - unmountRef(lastRef); - mountRef(nextRef, dom, lifecycle); - } - } - function replaceOneVNodeWithMultipleVNodes(lastChildren, nextChildren, parentDOM, context, isSVG, lifecycle) { - unmount(lastChildren); - mountArrayChildren(nextChildren, parentDOM, context, isSVG, findDOMfromVNode(lastChildren, true), lifecycle); - removeVNodeDOM(lastChildren, parentDOM); - } - function patchChildren(lastChildFlags, nextChildFlags, lastChildren, nextChildren, parentDOM, context, isSVG, nextNode, parentVNode, lifecycle) { - switch (lastChildFlags) { - case 2 /* HasVNodeChildren */: - switch (nextChildFlags) { - case 2 /* HasVNodeChildren */: - patch(lastChildren, nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - remove(lastChildren, parentDOM); - break; - case 16 /* HasTextChildren */: - unmount(lastChildren); - setTextContent(parentDOM, nextChildren); - break; - default: - replaceOneVNodeWithMultipleVNodes(lastChildren, nextChildren, parentDOM, context, isSVG, lifecycle); - break; - } - break; - case 1 /* HasInvalidChildren */: - switch (nextChildFlags) { - case 2 /* HasVNodeChildren */: - mount(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - break; - case 16 /* HasTextChildren */: - setTextContent(parentDOM, nextChildren); - break; - default: - mountArrayChildren(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - } - break; - case 16 /* HasTextChildren */: - switch (nextChildFlags) { - case 16 /* HasTextChildren */: - patchSingleTextChild(lastChildren, nextChildren, parentDOM); - break; - case 2 /* HasVNodeChildren */: - clearDOM(parentDOM); - mount(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - clearDOM(parentDOM); - break; - default: - clearDOM(parentDOM); - mountArrayChildren(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - } - break; - default: - switch (nextChildFlags) { - case 16 /* HasTextChildren */: - unmountAllChildren(lastChildren); - setTextContent(parentDOM, nextChildren); - break; - case 2 /* HasVNodeChildren */: - removeAllChildren(parentDOM, parentVNode, lastChildren); - mount(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - removeAllChildren(parentDOM, parentVNode, lastChildren); - break; - default: - var lastLength = lastChildren.length | 0; - var nextLength = nextChildren.length | 0; - // Fast path's for both algorithms - if (lastLength === 0) { - if (nextLength > 0) { - mountArrayChildren(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - } - } - else if (nextLength === 0) { - removeAllChildren(parentDOM, parentVNode, lastChildren); - } - else if (nextChildFlags === 8 /* HasKeyedChildren */ && lastChildFlags === 8 /* HasKeyedChildren */) { - patchKeyedChildren(lastChildren, nextChildren, parentDOM, context, isSVG, lastLength, nextLength, nextNode, parentVNode, lifecycle); - } - else { - patchNonKeyedChildren(lastChildren, nextChildren, parentDOM, context, isSVG, lastLength, nextLength, nextNode, lifecycle); - } - break; - } - break; - } - } - function createDidUpdate(instance, lastProps, lastState, snapshot, lifecycle) { - lifecycle.push(function () { - instance.componentDidUpdate(lastProps, lastState, snapshot); - }); - } - function updateClassComponent(instance, nextState, nextProps, parentDOM, context, isSVG, force, nextNode, lifecycle) { - var lastState = instance.state; - var lastProps = instance.props; - var usesNewAPI = Boolean(instance.$N); - var hasSCU = isFunction(instance.shouldComponentUpdate); - if (usesNewAPI) { - nextState = createDerivedState(instance, nextProps, nextState !== lastState ? combineFrom(lastState, nextState) : nextState); - } - if (force || !hasSCU || (hasSCU && instance.shouldComponentUpdate(nextProps, nextState, context))) { - if (!usesNewAPI && isFunction(instance.componentWillUpdate)) { - instance.componentWillUpdate(nextProps, nextState, context); - } - instance.props = nextProps; - instance.state = nextState; - instance.context = context; - var snapshot = null; - var nextInput = renderNewInput(instance, nextProps, context); - if (usesNewAPI && isFunction(instance.getSnapshotBeforeUpdate)) { - snapshot = instance.getSnapshotBeforeUpdate(lastProps, lastState); - } - patch(instance.$LI, nextInput, parentDOM, instance.$CX, isSVG, nextNode, lifecycle); - // Dont update Last input, until patch has been succesfully executed - instance.$LI = nextInput; - if (isFunction(instance.componentDidUpdate)) { - createDidUpdate(instance, lastProps, lastState, snapshot, lifecycle); - } - } - else { - instance.props = nextProps; - instance.state = nextState; - instance.context = context; - } - } - function patchClassComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var instance = (nextVNode.children = lastVNode.children); - // If Component has crashed, ignore it to stay functional - if (isNull(instance)) { - return; - } - instance.$L = lifecycle; - var nextProps = nextVNode.props || EMPTY_OBJ; - var nextRef = nextVNode.ref; - var lastRef = lastVNode.ref; - var nextState = instance.state; - if (!instance.$N) { - if (isFunction(instance.componentWillReceiveProps)) { - instance.$BR = true; - instance.componentWillReceiveProps(nextProps, context); - // If instance component was removed during its own update do nothing. - if (instance.$UN) { - return; - } - instance.$BR = false; - } - if (!isNull(instance.$PS)) { - nextState = combineFrom(nextState, instance.$PS); - instance.$PS = null; - } - } - updateClassComponent(instance, nextState, nextProps, parentDOM, context, isSVG, false, nextNode, lifecycle); - if (lastRef !== nextRef) { - unmountRef(lastRef); - mountRef(nextRef, instance, lifecycle); - } - } - function patchFunctionalComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var shouldUpdate = true; - var nextProps = nextVNode.props || EMPTY_OBJ; - var nextRef = nextVNode.ref; - var lastProps = lastVNode.props; - var nextHooksDefined = !isNullOrUndef(nextRef); - var lastInput = lastVNode.children; - if (nextHooksDefined && isFunction(nextRef.onComponentShouldUpdate)) { - shouldUpdate = nextRef.onComponentShouldUpdate(lastProps, nextProps); - } - if (shouldUpdate !== false) { - if (nextHooksDefined && isFunction(nextRef.onComponentWillUpdate)) { - nextRef.onComponentWillUpdate(lastProps, nextProps); - } - var nextInput = normalizeRoot(renderFunctionalComponent(nextVNode, context)); - patch(lastInput, nextInput, parentDOM, context, isSVG, nextNode, lifecycle); - nextVNode.children = nextInput; - if (nextHooksDefined && isFunction(nextRef.onComponentDidUpdate)) { - nextRef.onComponentDidUpdate(lastProps, nextProps); - } - } - else { - nextVNode.children = lastInput; - } - } - function patchText(lastVNode, nextVNode) { - var nextText = nextVNode.children; - var dom = (nextVNode.dom = lastVNode.dom); - if (nextText !== lastVNode.children) { - dom.nodeValue = nextText; - } - } - function patchNonKeyedChildren(lastChildren, nextChildren, dom, context, isSVG, lastChildrenLength, nextChildrenLength, nextNode, lifecycle) { - var commonLength = lastChildrenLength > nextChildrenLength ? nextChildrenLength : lastChildrenLength; - var i = 0; - var nextChild; - var lastChild; - for (; i < commonLength; ++i) { - nextChild = nextChildren[i]; - lastChild = lastChildren[i]; - if (nextChild.flags & 16384 /* InUse */) { - nextChild = nextChildren[i] = directClone(nextChild); - } - patch(lastChild, nextChild, dom, context, isSVG, nextNode, lifecycle); - lastChildren[i] = nextChild; - } - if (lastChildrenLength < nextChildrenLength) { - for (i = commonLength; i < nextChildrenLength; ++i) { - nextChild = nextChildren[i]; - if (nextChild.flags & 16384 /* InUse */) { - nextChild = nextChildren[i] = directClone(nextChild); - } - mount(nextChild, dom, context, isSVG, nextNode, lifecycle); - } - } - else if (lastChildrenLength > nextChildrenLength) { - for (i = commonLength; i < lastChildrenLength; ++i) { - remove(lastChildren[i], dom); - } - } - } - function patchKeyedChildren(a, b, dom, context, isSVG, aLength, bLength, outerEdge, parentVNode, lifecycle) { - var aEnd = aLength - 1; - var bEnd = bLength - 1; - var j = 0; - var aNode = a[j]; - var bNode = b[j]; - var nextPos; - var nextNode; - // Step 1 - // tslint:disable-next-line - outer: { - // Sync nodes with the same key at the beginning. - while (aNode.key === bNode.key) { - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - a[j] = bNode; - ++j; - if (j > aEnd || j > bEnd) { - break outer; - } - aNode = a[j]; - bNode = b[j]; - } - aNode = a[aEnd]; - bNode = b[bEnd]; - // Sync nodes with the same key at the end. - while (aNode.key === bNode.key) { - if (bNode.flags & 16384 /* InUse */) { - b[bEnd] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - a[aEnd] = bNode; - aEnd--; - bEnd--; - if (j > aEnd || j > bEnd) { - break outer; - } - aNode = a[aEnd]; - bNode = b[bEnd]; - } - } - if (j > aEnd) { - if (j <= bEnd) { - nextPos = bEnd + 1; - nextNode = nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge; - while (j <= bEnd) { - bNode = b[j]; - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - ++j; - mount(bNode, dom, context, isSVG, nextNode, lifecycle); - } - } - } - else if (j > bEnd) { - while (j <= aEnd) { - remove(a[j++], dom); - } - } - else { - patchKeyedChildrenComplex(a, b, context, aLength, bLength, aEnd, bEnd, j, dom, isSVG, outerEdge, parentVNode, lifecycle); - } - } - function patchKeyedChildrenComplex(a, b, context, aLength, bLength, aEnd, bEnd, j, dom, isSVG, outerEdge, parentVNode, lifecycle) { - var aNode; - var bNode; - var nextPos; - var i = 0; - var aStart = j; - var bStart = j; - var aLeft = aEnd - j + 1; - var bLeft = bEnd - j + 1; - var sources = new Int32Array(bLeft + 1); - // Keep track if its possible to remove whole DOM using textContent = ''; - var canRemoveWholeContent = aLeft === aLength; - var moved = false; - var pos = 0; - var patched = 0; - // When sizes are small, just loop them through - if (bLength < 4 || (aLeft | bLeft) < 32) { - for (i = aStart; i <= aEnd; ++i) { - aNode = a[i]; - if (patched < bLeft) { - for (j = bStart; j <= bEnd; j++) { - bNode = b[j]; - if (aNode.key === bNode.key) { - sources[j - bStart] = i + 1; - if (canRemoveWholeContent) { - canRemoveWholeContent = false; - while (aStart < i) { - remove(a[aStart++], dom); - } - } - if (pos > j) { - moved = true; - } - else { - pos = j; - } - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - ++patched; - break; - } - } - if (!canRemoveWholeContent && j > bEnd) { - remove(aNode, dom); - } - } - else if (!canRemoveWholeContent) { - remove(aNode, dom); - } - } - } - else { - var keyIndex = {}; - // Map keys by their index - for (i = bStart; i <= bEnd; ++i) { - keyIndex[b[i].key] = i; - } - // Try to patch same keys - for (i = aStart; i <= aEnd; ++i) { - aNode = a[i]; - if (patched < bLeft) { - j = keyIndex[aNode.key]; - if (j !== void 0) { - if (canRemoveWholeContent) { - canRemoveWholeContent = false; - while (i > aStart) { - remove(a[aStart++], dom); - } - } - sources[j - bStart] = i + 1; - if (pos > j) { - moved = true; - } - else { - pos = j; - } - bNode = b[j]; - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - ++patched; - } - else if (!canRemoveWholeContent) { - remove(aNode, dom); - } - } - else if (!canRemoveWholeContent) { - remove(aNode, dom); - } - } - } - // fast-path: if nothing patched remove all old and add all new - if (canRemoveWholeContent) { - removeAllChildren(dom, parentVNode, a); - mountArrayChildren(b, dom, context, isSVG, outerEdge, lifecycle); - } - else if (moved) { - var seq = lis_algorithm(sources); - j = seq.length - 1; - for (i = bLeft - 1; i >= 0; i--) { - if (sources[i] === 0) { - pos = i + bStart; - bNode = b[pos]; - if (bNode.flags & 16384 /* InUse */) { - b[pos] = bNode = directClone(bNode); - } - nextPos = pos + 1; - mount(bNode, dom, context, isSVG, nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge, lifecycle); - } - else if (j < 0 || i !== seq[j]) { - pos = i + bStart; - bNode = b[pos]; - nextPos = pos + 1; - moveVNodeDOM(bNode, dom, nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge); - } - else { - j--; - } - } - } - else if (patched !== bLeft) { - // when patched count doesn't match b length we need to insert those new ones - // loop backwards so we can use insertBefore - for (i = bLeft - 1; i >= 0; i--) { - if (sources[i] === 0) { - pos = i + bStart; - bNode = b[pos]; - if (bNode.flags & 16384 /* InUse */) { - b[pos] = bNode = directClone(bNode); - } - nextPos = pos + 1; - mount(bNode, dom, context, isSVG, nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge, lifecycle); - } - } - } - } - var result; - var p; - var maxLen = 0; - // https://en.wikipedia.org/wiki/Longest_increasing_subsequence - function lis_algorithm(arr) { - var arrI = 0; - var i = 0; - var j = 0; - var k = 0; - var u = 0; - var v = 0; - var c = 0; - var len = arr.length; - if (len > maxLen) { - maxLen = len; - result = new Int32Array(len); - p = new Int32Array(len); - } - for (; i < len; ++i) { - arrI = arr[i]; - if (arrI !== 0) { - j = result[k]; - if (arr[j] < arrI) { - p[i] = j; - result[++k] = i; - continue; - } - u = 0; - v = k; - while (u < v) { - c = (u + v) >> 1; - if (arr[result[c]] < arrI) { - u = c + 1; - } - else { - v = c; - } - } - if (arrI < arr[result[u]]) { - if (u > 0) { - p[i] = result[u - 1]; - } - result[u] = i; - } - } - } - u = k + 1; - var seq = new Int32Array(u); - v = result[u - 1]; - while (u-- > 0) { - seq[u] = v; - v = p[v]; - result[u] = 0; - } - return seq; - } - - var hasDocumentAvailable = typeof document !== 'undefined'; - if (hasDocumentAvailable) { - /* - * Defining $EV and $V properties on Node.prototype - * fixes v8 "wrong map" de-optimization - */ - if (window.Node) { - Node.prototype.$EV = null; - Node.prototype.$V = null; - } - } - function __render(input, parentDOM, callback, context) { - var lifecycle = []; - var rootInput = parentDOM.$V; - if (isNullOrUndef(rootInput)) { - if (!isNullOrUndef(input)) { - if (input.flags & 16384 /* InUse */) { - input = directClone(input); - } - mount(input, parentDOM, context, false, null, lifecycle); - parentDOM.$V = input; - rootInput = input; - } - } - else { - if (isNullOrUndef(input)) { - remove(rootInput, parentDOM); - parentDOM.$V = null; - } - else { - if (input.flags & 16384 /* InUse */) { - input = directClone(input); - } - patch(rootInput, input, parentDOM, context, false, null, lifecycle); - rootInput = parentDOM.$V = input; - } - } - callAll(lifecycle); - if (isFunction(callback)) { - callback(); - } - if (isFunction(options.renderComplete)) { - options.renderComplete(rootInput, parentDOM); - } - } - function render(input, parentDOM, callback, context) { - if ( callback === void 0 ) callback = null; - if ( context === void 0 ) context = EMPTY_OBJ; - - __render(input, parentDOM, callback, context); - } - typeof Promise !== 'undefined' - ? Promise.resolve().then.bind(Promise.resolve()) - : function (a) { - window.setTimeout(a, 0); - }; - - function hoistedEvent(e) { - console.log("ok", e); - } - - function hoistedNonSyntheticEvents() { - var listItems = []; - - for (var i = 0; i < numberOfNodes; i++) { - listItems.push(createVNode(1, "li", null, i, 16, { - "onclick": hoistedEvent - }, null, null)); - } - - return createVNode(1, "ul", null, listItems, 4, null, null, null); - } - - function hoistedLinkEventNonSynthetic() { - var listItems = []; - - for (var i = 0; i < numberOfNodes; i++) { - listItems.push(createVNode(1, "li", null, i, 16, { - "onclick": linkEvent(i, hoistedEvent) - }, null, null)); - } - - return createVNode(1, "ul", null, listItems, 4, null, null, null); - } - - function hoistedSyntheticEvents() { - var listItems = []; - - for (var i = 0; i < numberOfNodes; i++) { - listItems.push(createVNode(1, "li", null, i, 16, { - "onClick": hoistedEvent - }, null, null)); - } - - return createVNode(1, "ul", null, listItems, 4, null, null, null); - } - - function newFuncsNonSyntheticEvents() { - var listItems = []; - - for (var i = 0; i < numberOfNodes; i++) { - listItems.push(createVNode(1, "li", null, i, 16, { - "onclick": function onclick() { - console.log("ok"); - } - }, null, null)); - } - - return createVNode(1, "ul", null, listItems, 4, null, null, null); - } - - var numberOfNodes = 500; - var waitMs = 30; - var patchCounter = 7; - var iterations = 10; - var warmUpIterations = 3; - var roots = [hoistedNonSyntheticEvents, hoistedLinkEventNonSynthetic, hoistedSyntheticEvents, newFuncsNonSyntheticEvents]; - var names = ['hoistedNonSyntheticEvents', 'hoistedLinkEventNonSynthetic', 'hoistedSyntheticEvents', 'newFuncsNonSyntheticEvents']; - - var getAvg = function getAvg(arr) { - return arr.reduce(function (a, b) { - return a + b; - }, 0) / arr.length; - }; - - var getMin = function getMin(arr) { - return Math.min.apply(Math, arr); - }; - - var getMax = function getMax(arr) { - return Math.max.apply(Math, arr); - }; - - function Results(_ref) { - var results = _ref.results; - var rows = []; - - for (var i = 0; i < results.length; i++) { - var testData = results[i]; - var testCases = ['mount', 'patch', 'unmount']; - rows.push(createVNode(1, "div", "test-name", testData.name, 0, null, null, null)); - - for (var j = 0; j < testCases.length; j++) { - var testCase = testCases[j]; - var result = testData[testCase]; - rows.push(createVNode(1, "div", "test-part", testCase, 0, null, null, null)); - rows.push(createVNode(1, "div", "test-result", [createTextVNode("Avg: "), result.avg], 0, null, null, null)); - rows.push(createVNode(1, "div", "test-result", [createTextVNode("Min: "), result.min], 0, null, null, null)); - rows.push(createVNode(1, "div", "test-result", [createTextVNode("Max: "), result.max], 0, null, null, null)); - } - } - - return createVNode(1, "div", "results", rows, 4, null, null, null); - } - - document.addEventListener('DOMContentLoaded', function (e) { - var container = document.querySelector('#App'); - var result = []; - var mountTimes = []; - var patchTimes = []; - var unmountTimes = []; - var i = 0; - - for (var q = 0; q < warmUpIterations; q++) { - for (var qw = 0; qw < roots.length; qw++) { - render(createComponentVNode(1 << 3, roots[qw]), container); - } - } - - render(null, container); - - function mountTest(finishCallback) { - var start = performance.now(); // Mount - - render(createComponentVNode(1 << 3, roots[i]), container); - var end = performance.now(); - mountTimes.push(end - start); - setTimeout(patchTest, waitMs, finishCallback); - } - - function patchTest(finishCallback) { - var start = performance.now(); // Patch loop - - for (var p = 0; p < patchCounter; p++) { - render(createComponentVNode(1 << 3, roots[i]), container); - } - - var end = performance.now(); - patchTimes.push(end - start); - setTimeout(unmountTest, waitMs, finishCallback); - } - - function unmountTest(finishCallback) { - var start = performance.now(); // Mount - - render(null, container); - var end = performance.now(); - unmountTimes.push(end - start); - setTimeout(finishCallback, waitMs); - } - - var iterationCounter = 0; - - function startRound() { - if (iterationCounter < iterations && i < roots.length) { - iterationCounter++; - setTimeout(mountTest, waitMs, startRound); - } else if (i < roots.length) { - result.push({ - name: names[i], - mount: { - min: getMin(mountTimes), - avg: getAvg(mountTimes), - max: getMax(mountTimes) - }, - patch: { - min: getMin(patchTimes), - avg: getAvg(patchTimes), - max: getMax(patchTimes) - }, - unmount: { - min: getMin(unmountTimes), - avg: getAvg(unmountTimes), - max: getMax(unmountTimes) - } - }); - mountTimes = []; - patchTimes = []; - unmountTimes = []; - i++; - iterationCounter = 0; - startRound(); // Go next - } else { - // Finished! - setTimeout(function () { - render(createComponentVNode(2, Results, { - "results": result - }, null, null), container); - }, 1000); - } - } - - startRound(); - }); - -}()); +!function(){"use strict";var e=Array.isArray;function n(e){var n=typeof e;return"string"===n||"number"===n}function t(e){return void 0===e||null===e}function r(e){return null===e||!1===e||!0===e||void 0===e}function l(e){return"function"===typeof e}function o(e){return"string"===typeof e}function i(e){return null===e}function u(e,n){var t={};if(e)for(var r in e)t[r]=e[r];if(n)for(var l in n)t[l]=n[l];return t}function a(e,n){if(l(n))return{data:e,event:n};return null}function c(e){return!i(e)&&"object"===typeof e}var f={};function s(e){return e.substr(2).toLowerCase()}function d(e,n){e.appendChild(n)}function p(e,n,t){i(t)?d(e,n):e.insertBefore(n,t)}function v(e,n){if(n)return document.createElementNS("http://www.w3.org/2000/svg",e);return document.createElement(e)}function h(e,n,t){e.replaceChild(n,t)}function m(e,n){e.removeChild(n)}function g(e){for(var n=0;n0,v=i(d),h=o(d)&&d[0]===L;p||v||h?(u=u||l.slice(0,f),(p||h)&&(s=B(s)),(v||h)&&(s.key=L+f),u.push(s)):u&&u.push(s),s.flags|=65536}}a=0===(u=u||l).length?1:8}else(u=l).flags|=65536,81920&l.flags&&(u=B(l)),a=2;return t.children=u,t.childFlags=a,t}function H(t){if(r(t)||n(t))return E(t,null);if(e(t))return D(t,0,null);return 16384&t.flags?B(t):t}var R="http://www.w3.org/1999/xlink",X="http://www.w3.org/XML/1998/namespace",_={"xlink:actuate":R,"xlink:arcrole":R,"xlink:href":R,"xlink:role":R,"xlink:show":R,"xlink:title":R,"xlink:type":R,"xml:base":X,"xml:lang":X,"xml:space":X};function K(e){return{onClick:e,onDblClick:e,onFocusIn:e,onFocusOut:e,onKeyDown:e,onKeyPress:e,onKeyUp:e,onMouseDown:e,onMouseMove:e,onMouseUp:e,onTouchEnd:e,onTouchMove:e,onTouchStart:e}}var q=K(0),G=K(null),z=K(!0);function J(e,n){var t=n.$EV;return t||(t=n.$EV=K(null)),t[e]||1===++q[e]&&(G[e]=ue(e)),t}function Q(e,n){var t=n.$EV;t&&t[e]&&(0===--q[e]&&(document.removeEventListener(s(e),G[e]),G[e]=null),t[e]=null)}function Y(e,n,t,r){if(l(t))J(e,r)[e]=t;else if(c(t)){if(x(n,t))return;J(e,r)[e]=t}else Q(e,r)}function Z(e){return l(e.composedPath)?e.composedPath()[0]:e.target}function ee(e,n,t,r){var l=Z(e);do{if(n&&l.disabled)return;var o=l.$EV;if(o){var u=o[t];if(u&&(r.dom=l,u.event?u.event(u.data,e):u(e),e.cancelBubble))return}l=l.parentNode}while(!i(l))}function ne(){this.cancelBubble=!0,this.immediatePropagationStopped||this.stopImmediatePropagation()}function te(){return this.defaultPrevented}function re(){return this.cancelBubble}function le(e){var n={dom:document};return e.isDefaultPrevented=te,e.isPropagationStopped=re,e.stopPropagation=ne,Object.defineProperty(e,"currentTarget",{configurable:!0,get:function(){return n.dom}}),n}function oe(e){return function(n){if(0!==n.button)return void n.stopPropagation();ee(n,!0,e,le(n))}}function ie(e){return function(n){ee(n,!1,e,le(n))}}function ue(e){var n="onClick"===e||"onDblClick"===e?oe(e):ie(e);return document.addEventListener(s(e),n),n}function ae(e,n){var t=document.createElement("i");return t.innerHTML=n,t.innerHTML===e.innerHTML}function ce(e,n,t){if(e[n]){var r=e[n];r.event?r.event(r.data,t):r(t)}else{var l=n.toLowerCase();e[l]&&e[l](t)}}function fe(e,n){var t=function(t){var r=this.$V;if(!r)return;var i=r.props||f,u=r.dom;if(o(e))ce(i,e,t);else for(var a=0;a-1&&n.options[i]&&(u=n.options[i].value),r&&t(u)&&(u=e.defaultValue),ye(l,u)}}var $e,Fe,xe=fe("onInput",Le),Pe=fe("onChange");function Se(e,n){se(e,"input",xe),n.onChange&&se(e,"change",Pe)}function Le(e,n,r){var l=e.value,o=n.value;if(t(l)){if(r){var i=e.defaultValue;t(i)||i===o||(n.defaultValue=i,n.value=i)}}else o!==l&&(n.defaultValue=l,n.value=l)}function Me(e,n,t,r,l,o){64&e?ge(r,t):256&e?Ce(r,t,l,n):128&e&&Le(r,t,l),o&&(t.$V=n)}function Ve(e,n,t){64&e?me(n,t):256&e?we(n):128&e&&Se(n,t)}function Ne(e){return e.type&&de(e.type)?!t(e.checked):!t(e.value)}function Ue(e){e&&!S(e,null)&&e.current&&(e.current=null)}function Ie(e,n,t){e&&(l(e)||void 0!==e.current)&&t.push((function(){S(e,n)||void 0===e.current||(e.current=n)}))}function Ae(e,n){Ee(e),b(e,n)}function Ee(e){var n,r=e.flags,o=e.children;if(481&r){n=e.ref;var u=e.props;Ue(n);var a=e.childFlags;if(!i(u))for(var c=Object.keys(u),s=0,d=c.length;s0;for(var u in i&&(o=Ne(t))&&Ve(n,r,t),t)Re(u,null,t[u],r,l,o,null);i&&Me(n,e,r,t,!0,o)}function _e(e,n,t){var r=H(e.render(n,e.state,t)),o=t;return l(e.getChildContext)&&(o=u(t,e.getChildContext())),e.$CX=o,r}function Ke(e,n,t,r,o,u){var a=new n(t,r),c=a.$N=Boolean(n.getDerivedStateFromProps||a.getSnapshotBeforeUpdate);if(a.$SVG=o,a.$L=u,e.children=a,a.$BS=!1,a.context=r,a.props===f&&(a.props=t),c)a.state=C(a,t,a.state);else if(l(a.componentWillMount)){a.$BR=!0,a.componentWillMount();var s=a.$PS;if(!i(s)){var d=a.state;if(i(d))a.state=s;else for(var p in s)d[p]=s[p];a.$PS=null}a.$BR=!1}return a.$LI=_e(a,t,r),a}function qe(e,n){var t=e.props||f;return 32768&e.flags?e.type.render(t,e.ref,n):e.type(t,n)}function Ge(e,n,t,r,l,o){var i=e.flags|=16384;481&i?Ye(e,n,t,r,l,o):4&i?en(e,n,t,r,l,o):8&i?(nn(e,n,t,r,l,o),on(e,o)):512&i||16&i?Qe(e,n,l):8192&i?Je(e,t,n,r,l,o):1024&i&&ze(e,t,n,l,o)}function ze(e,n,t,r,l){Ge(e.children,e.ref,n,!1,null,l);var o=W();Qe(o,t,r),e.dom=o.dom}function Je(e,n,t,r,l,o){var i=e.children,u=e.childFlags;12&u&&0===i.length&&(u=e.childFlags=2,i=e.children=W()),2===u?Ge(i,t,l,r,l,o):Ze(i,t,n,r,l,o)}function Qe(e,n,t){var r=e.dom=document.createTextNode(e.children);i(n)||p(n,r,t)}function Ye(e,n,r,l,o,u){var a=e.flags,c=e.props,f=e.className,s=e.childFlags,d=e.dom=v(e.type,l=l||(32&a)>0),h=e.children;if(t(f)||""===f||(l?d.setAttribute("class",f):d.className=f),16===s)F(d,h);else if(1!==s){var m=l&&"foreignObject"!==e.type;2===s?(16384&h.flags&&(e.children=h=B(h)),Ge(h,d,r,m,null,u)):8!==s&&4!==s||Ze(h,d,r,m,null,u)}i(n)||p(n,d,o),i(c)||Xe(e,a,c,d,l),Ie(e.ref,d,u)}function Ze(e,n,t,r,l,o){for(var i=0;id)&&(f=k(i[d-1],!1).nextSibling)}hn(a,c,i,u,t,r,l,f,e,o)}function dn(e,n,t,l){var o=e.ref,i=n.ref,u=n.children;if(hn(e.childFlags,n.childFlags,e.children,u,o,t,!1,null,e,l),n.dom=e.dom,o!==i&&!r(u)){var a=u.dom;m(o,a),d(i,a)}}function pn(e,n,r,l,o,i){var u,a=n.dom=e.dom,c=e.props,s=n.props,d=!1,p=!1;if(l=l||(32&o)>0,c!==s){var v=c||f;if((u=s||f)!==f)for(var h in(d=(448&o)>0)&&(p=Ne(u)),u){var m=v[h],g=u[h];m!==g&&Re(h,m,g,a,l,p,e)}if(v!==f)for(var y in v)t(u[y])&&!t(v[y])&&Re(y,v[y],null,a,l,p,e)}var k=n.children,b=n.className;e.className!==b&&(t(b)?a.removeAttribute("class"):l?a.setAttribute("class",b):a.className=b),4096&o?fn(a,k):hn(e.childFlags,n.childFlags,e.children,k,a,r,l&&"foreignObject"!==n.type,null,e,i),d&&Me(o,n,a,u,!1,p);var w=n.ref,C=e.ref;C!==w&&(Ue(C),Ie(w,a,i))}function vn(e,n,t,r,l,o){Ee(e),Ze(n,t,r,l,k(e,!0),o),b(e,t)}function hn(e,n,t,r,l,o,i,u,a,c){switch(e){case 2:switch(n){case 2:an(t,r,l,o,i,u,c);break;case 1:Ae(t,l);break;case 16:Ee(t),F(l,r);break;default:vn(t,r,l,o,i,c)}break;case 1:switch(n){case 2:Ge(r,l,o,i,u,c);break;case 1:break;case 16:F(l,r);break;default:Ze(r,l,o,i,u,c)}break;case 16:switch(n){case 16:cn(t,r,l);break;case 2:Te(l),Ge(r,l,o,i,u,c);break;case 1:Te(l);break;default:Te(l),Ze(r,l,o,i,u,c)}break;default:switch(n){case 16:De(t),F(l,r);break;case 2:Be(l,a,t),Ge(r,l,o,i,u,c);break;case 1:Be(l,a,t);break;default:var f=0|t.length,s=0|r.length;0===f?s>0&&Ze(r,l,o,i,u,c):0===s?Be(l,a,t):8===n&&8===e?Cn(t,r,l,o,i,f,s,u,a,c):wn(t,r,l,o,i,f,s,u,c)}}}function mn(e,n,t,r,l){l.push((function(){e.componentDidUpdate(n,t,r)}))}function gn(e,n,t,r,o,i,a,c,f){var s=e.state,d=e.props,p=Boolean(e.$N),v=l(e.shouldComponentUpdate);if(p&&(n=C(e,t,n!==s?u(s,n):n)),a||!v||v&&e.shouldComponentUpdate(t,n,o)){!p&&l(e.componentWillUpdate)&&e.componentWillUpdate(t,n,o),e.props=t,e.state=n,e.context=o;var h=null,m=_e(e,t,o);p&&l(e.getSnapshotBeforeUpdate)&&(h=e.getSnapshotBeforeUpdate(d,s)),an(e.$LI,m,r,e.$CX,i,c,f),e.$LI=m,l(e.componentDidUpdate)&&mn(e,d,s,h,f)}else e.props=t,e.state=n,e.context=o}function yn(e,n,t,r,o,a,c){var s=n.children=e.children;if(i(s))return;s.$L=c;var d=n.props||f,p=n.ref,v=e.ref,h=s.state;if(!s.$N){if(l(s.componentWillReceiveProps)){if(s.$BR=!0,s.componentWillReceiveProps(d,r),s.$UN)return;s.$BR=!1}i(s.$PS)||(h=u(h,s.$PS),s.$PS=null)}gn(s,h,d,t,r,o,!1,a,c),v!==p&&(Ue(v),Ie(p,s,c))}function kn(e,n,r,o,i,u,a){var c=!0,s=n.props||f,d=n.ref,p=e.props,v=!t(d),h=e.children;if(v&&l(d.onComponentShouldUpdate)&&(c=d.onComponentShouldUpdate(p,s)),!1!==c){v&&l(d.onComponentWillUpdate)&&d.onComponentWillUpdate(p,s);var m=H(qe(n,o));an(h,m,r,o,i,u,a),n.children=m,v&&l(d.onComponentDidUpdate)&&d.onComponentDidUpdate(p,s)}else n.children=h}function bn(e,n){var t=n.children,r=n.dom=e.dom;t!==e.children&&(r.nodeValue=t)}function wn(e,n,t,r,l,o,i,u,a){for(var c,f,s=o>i?i:o,d=0;di)for(d=s;dd||v>p)break e;h=e[v],m=n[v]}for(h=e[d],m=n[p];h.key===m.key;){if(16384&m.flags&&(n[p]=m=B(m)),an(h,m,t,r,l,u,c),e[d]=m,p--,v>--d||v>p)break e;h=e[d],m=n[p]}}if(v>d){if(v<=p)for(s=(f=p+1)p)for(;v<=d;)Ae(e[v++],t);else $n(e,n,r,o,i,d,p,v,t,l,u,a,c)}function $n(e,n,t,r,l,o,i,u,a,c,f,s,d){var p,v,h,m=0,g=u,y=u,b=o-u+1,C=i-u+1,$=new Int32Array(C+1),F=b===r,x=!1,P=0,S=0;if(l<4||(b|C)<32)for(m=g;m<=o;++m)if(p=e[m],Su?x=!0:P=u,16384&v.flags&&(n[u]=v=B(v)),an(p,v,a,t,c,f,d),++S;break}!F&&u>i&&Ae(p,a)}else F||Ae(p,a);else{var L={};for(m=y;m<=i;++m)L[n[m].key]=m;for(m=g;m<=o;++m)if(p=e[m],Sg;)Ae(e[g++],a);$[u-y]=m+1,P>u?x=!0:P=u,16384&(v=n[u]).flags&&(n[u]=v=B(v)),an(p,v,a,t,c,f,d),++S}else F||Ae(p,a);else F||Ae(p,a)}if(F)Be(a,s,e),Ze(n,a,t,c,f,d);else if(x){var M=xn($);for(u=M.length-1,m=C-1;m>=0;m--)0===$[m]?(16384&(v=n[P=m+y]).flags&&(n[P]=v=B(v)),Ge(v,a,t,c,(h=P+1)=0;m--)0===$[m]&&(16384&(v=n[P=m+y]).flags&&(n[P]=v=B(v)),Ge(v,a,t,c,(h=P+1)Fn&&(Fn=a,$e=new Int32Array(a),Fe=new Int32Array(a));t>1]]0&&(Fe[t]=$e[o-1]),$e[o]=t)}o=l+1;var c=new Int32Array(o);for(i=$e[o-1];o-- >0;)c[o]=i,i=Fe[i],$e[o]=0;return c}function Pn(e,n,r,o){var i=[],u=n.$V;t(u)?t(e)||(16384&e.flags&&(e=B(e)),Ge(e,n,o,!1,null,i),n.$V=e,u=e):t(e)?(Ae(u,n),n.$V=null):(16384&e.flags&&(e=B(e)),an(u,e,n,o,!1,null,i),u=n.$V=e),g(i),l(r)&&r(),l($.renderComplete)&&$.renderComplete(u,n)}function Sn(e,n,t,r){void 0===t&&(t=null),void 0===r&&(r=f),Pn(e,n,t,r)}function Ln(e){console.log("ok",e)}"undefined"!==typeof document&&window.Node&&(Node.prototype.$EV=null,Node.prototype.$V=null),"undefined"!==typeof Promise&&Promise.resolve().then.bind(Promise.resolve());var Mn=500,Vn=[function(){for(var e=[],n=0;n 0; - var isNullKey = isNull$3(key); - var isPrefixed = isString$3(key) && key[0] === keyPrefix$1; - if (needsCloning || isNullKey || isPrefixed) { - newChildren = newChildren || children.slice(0, i); - if (needsCloning || isPrefixed) { - n = directClone$1(n); - } - if (isNullKey || isPrefixed) { - n.key = keyPrefix$1 + i; - } - newChildren.push(n); - } - else if (newChildren) { - newChildren.push(n); - } - n.flags |= 65536 /* Normalized */; - } - } - newChildren = newChildren || children; - if (newChildren.length === 0) { - newChildFlags = 1 /* HasInvalidChildren */; - } - else { - newChildFlags = 8 /* HasKeyedChildren */; - } - } - else { - newChildren = children; - newChildren.flags |= 65536 /* Normalized */; - if (children.flags & 81920 /* InUseOrNormalized */) { - newChildren = directClone$1(children); - } - newChildFlags = 2 /* HasVNodeChildren */; - } - vNode.children = newChildren; - vNode.childFlags = newChildFlags; - return vNode; - } - - function triggerEventListener$1(props, methodName, e) { - if (props[methodName]) { - var listener = props[methodName]; - if (listener.event) { - listener.event(listener.data, e); - } - else { - listener(e); - } - } - else { - var nativeListenerName = methodName.toLowerCase(); - if (props[nativeListenerName]) { - props[nativeListenerName](e); - } - } - } - function createWrappedFunction$1(methodName, applyValue) { - var fnMethod = function (e) { - var vNode = this.$V; - // If vNode is gone by the time event fires, no-op - if (!vNode) { - return; - } - var props = vNode.props || EMPTY_OBJ$1; - var dom = vNode.dom; - if (isString$3(methodName)) { - triggerEventListener$1(props, methodName, e); - } - else { - for (var i = 0; i < methodName.length; ++i) { - triggerEventListener$1(props, methodName[i], e); - } - } - if (isFunction$4(applyValue)) { - var newVNode = this.$V; - var newProps = newVNode.props || EMPTY_OBJ$1; - applyValue(newProps, dom, false, newVNode); - } - }; - Object.defineProperty(fnMethod, 'wrapped', { - configurable: false, - enumerable: false, - value: true, - writable: false - }); - return fnMethod; - } - - function isCheckedType$1(type) { - return type === 'checkbox' || type === 'radio'; - } - createWrappedFunction$1('onInput', applyValueInput$1); - createWrappedFunction$1(['onClick', 'onChange'], applyValueInput$1); - function applyValueInput$1(nextPropsOrEmpty, dom) { - var type = nextPropsOrEmpty.type; - var value = nextPropsOrEmpty.value; - var checked = nextPropsOrEmpty.checked; - var multiple = nextPropsOrEmpty.multiple; - var defaultValue = nextPropsOrEmpty.defaultValue; - var hasValue = !isNullOrUndef$4(value); - if (type && type !== dom.type) { - dom.setAttribute('type', type); - } - if (!isNullOrUndef$4(multiple) && multiple !== dom.multiple) { - dom.multiple = multiple; - } - if (!isNullOrUndef$4(defaultValue) && !hasValue) { - dom.defaultValue = defaultValue + ''; - } - if (isCheckedType$1(type)) { - if (hasValue) { - dom.value = value; - } - if (!isNullOrUndef$4(checked)) { - dom.checked = checked; - } - } - else { - if (hasValue && dom.value !== value) { - dom.defaultValue = value; - dom.value = value; - } - else if (!isNullOrUndef$4(checked)) { - dom.checked = checked; - } - } - } - - function updateChildOptions$1(vNode, value) { - if (vNode.type === 'option') { - updateChildOption$1(vNode, value); - } - else { - var children = vNode.children; - var flags = vNode.flags; - if (flags & 4 /* ComponentClass */) { - updateChildOptions$1(children.$LI, value); - } - else if (flags & 8 /* ComponentFunction */) { - updateChildOptions$1(children, value); - } - else if (vNode.childFlags === 2 /* HasVNodeChildren */) { - updateChildOptions$1(children, value); - } - else if (vNode.childFlags & 12 /* MultipleChildren */) { - for (var i = 0, len = children.length; i < len; ++i) { - updateChildOptions$1(children[i], value); - } - } - } - } - function updateChildOption$1(vNode, value) { - var props = vNode.props || EMPTY_OBJ$1; - var dom = vNode.dom; - // we do this as multiple may have changed - dom.value = props.value; - if (props.value === value || (isArray$2(value) && value.indexOf(props.value) !== -1)) { - dom.selected = true; - } - else if (!isNullOrUndef$4(value) || !isNullOrUndef$4(props.selected)) { - dom.selected = props.selected || false; - } - } - createWrappedFunction$1('onChange', applyValueSelect$1); - function applyValueSelect$1(nextPropsOrEmpty, dom, mounting, vNode) { - var multiplePropInBoolean = Boolean(nextPropsOrEmpty.multiple); - if (!isNullOrUndef$4(nextPropsOrEmpty.multiple) && multiplePropInBoolean !== dom.multiple) { - dom.multiple = multiplePropInBoolean; - } - var index = nextPropsOrEmpty.selectedIndex; - if (index === -1) { - dom.selectedIndex = -1; - } - var childFlags = vNode.childFlags; - if (childFlags !== 1 /* HasInvalidChildren */) { - var value = nextPropsOrEmpty.value; - if (isNumber$2(index) && index > -1 && dom.options[index]) { - value = dom.options[index].value; - } - if (mounting && isNullOrUndef$4(value)) { - value = nextPropsOrEmpty.defaultValue; - } - updateChildOptions$1(vNode, value); - } - } - - createWrappedFunction$1('onInput', applyValueTextArea$1); - createWrappedFunction$1('onChange'); - function applyValueTextArea$1(nextPropsOrEmpty, dom, mounting) { - var value = nextPropsOrEmpty.value; - var domValue = dom.value; - if (isNullOrUndef$4(value)) { - if (mounting) { - var defaultValue = nextPropsOrEmpty.defaultValue; - if (!isNullOrUndef$4(defaultValue) && defaultValue !== domValue) { - dom.defaultValue = defaultValue; - dom.value = defaultValue; - } - } - } - else if (domValue !== value) { - /* There is value so keep it controlled */ - dom.defaultValue = value; - dom.value = value; - } - } - - var hasDocumentAvailable$1 = typeof document !== 'undefined'; - if (hasDocumentAvailable$1) { - /* - * Defining $EV and $V properties on Node.prototype - * fixes v8 "wrong map" de-optimization - */ - if (window.Node) { - Node.prototype.$EV = null; - Node.prototype.$V = null; - } - } - typeof Promise !== 'undefined' - ? Promise.resolve().then.bind(Promise.resolve()) - : function (a) { - window.setTimeout(a, 0); - }; - - var isArray$1 = Array.isArray; - - function isStringOrNumber(o) { - var type = typeof o; - return type === 'string' || type === 'number'; - } - - function isNullOrUndef$3(o) { - return o === void 0 || o === null; - } - - function isInvalid$2(o) { - return o === null || o === false || o === true || o === void 0; - } - - function isFunction$3(o) { - return typeof o === 'function'; - } - - function isString$2(o) { - return typeof o === 'string'; - } - - function isNumber$1(o) { - return typeof o === 'number'; - } - - function isNull$2(o) { - return o === null; - } - - function isUndefined$1(o) { - return o === void 0; - } - - function combineFrom$1(first, second) { - var out = {}; - - if (first) { - for (var key in first) { - out[key] = first[key]; - } - } - - if (second) { - for (var key$1 in second) { - out[key$1] = second[key$1]; - } - } - - return out; - } - /** - * Links given data to event as first parameter - * @param {*} data data to be linked, it will be available in function as first parameter - * @param {Function} event Function to be called when event occurs - * @returns {{data: *, event: Function}} - */ - - - function linkEvent(data, event) { - if (isFunction$3(event)) { - return { - data: data, - event: event - }; - } - - return null; // Return null when event is invalid, to avoid creating unnecessary event handlers - } // object.event should always be function, otherwise its badly created object. - - - function isLinkEventObject(o) { - return !isNull$2(o) && typeof o === 'object'; - } // We need EMPTY_OBJ defined in one place. - // Its used for comparison so we cant inline it into shared - - - var EMPTY_OBJ = {}; - var Fragment = '$F'; - - var AnimationQueues = function AnimationQueues() { - this.componentDidAppear = []; - this.componentWillDisappear = []; - this.componentWillMove = []; - }; - - function normalizeEventName(name) { - return name.substr(2).toLowerCase(); - } - - function appendChild(parentDOM, dom) { - parentDOM.appendChild(dom); - } - - function insertOrAppend(parentDOM, newNode, nextNode) { - if (isNull$2(nextNode)) { - appendChild(parentDOM, newNode); - } else { - parentDOM.insertBefore(newNode, nextNode); - } - } - - function documentCreateElement(tag, isSVG) { - if (isSVG) { - return document.createElementNS('http://www.w3.org/2000/svg', tag); - } - - return document.createElement(tag); - } - - function replaceChild(parentDOM, newDom, lastDom) { - parentDOM.replaceChild(newDom, lastDom); - } - - function removeChild(parentDOM, childNode) { - parentDOM.removeChild(childNode); - } - - function callAll(arrayFn) { - for (var i = 0; i < arrayFn.length; i++) { - arrayFn[i](); - } - } - - function findChildVNode(vNode, startEdge, flags) { - var children = vNode.children; - - if (flags & 4 - /* ComponentClass */ - ) { - return children.$LI; - } - - if (flags & 8192 - /* Fragment */ - ) { - return vNode.childFlags === 2 - /* HasVNodeChildren */ - ? children : children[startEdge ? 0 : children.length - 1]; - } - - return children; - } - - function findDOMfromVNode(vNode, startEdge) { - var flags; - - while (vNode) { - flags = vNode.flags; - - if (flags & 2033 - /* DOMRef */ - ) { - return vNode.dom; - } - - vNode = findChildVNode(vNode, startEdge, flags); - } - - return null; - } - - function callAllAnimationHooks(animationQueue, callback) { - var animationsLeft = animationQueue.length; // Picking from the top because it is faster, invocation order should be irrelevant - // since all animations are to be run and we can't predict the order in which they complete. - - var fn; - - while ((fn = animationQueue.pop()) !== undefined) { - fn(function () { - if (--animationsLeft <= 0 && isFunction$3(callback)) { - callback(); - } - }); - } - } - - function callAllMoveAnimationHooks(animationQueue) { - // Start the animations. - for (var i = 0; i < animationQueue.length; i++) { - animationQueue[i].fn(); - } // Perform the actual DOM moves when all measurements of initial - // position have been performed. The rest of the animations are done - // async. - - - for (var i$1 = 0; i$1 < animationQueue.length; i$1++) { - var tmp = animationQueue[i$1]; - insertOrAppend(tmp.parent, tmp.dom, tmp.next); - } - - animationQueue.splice(0, animationQueue.length); - } - - function clearVNodeDOM(vNode, parentDOM, deferredRemoval) { - do { - var flags = vNode.flags; - - if (flags & 2033 - /* DOMRef */ - ) { - // On deferred removals the node might disappear because of later operations - if (!deferredRemoval || vNode.dom.parentNode === parentDOM) { - removeChild(parentDOM, vNode.dom); - } - - return; - } - - var children = vNode.children; - - if (flags & 4 - /* ComponentClass */ - ) { - vNode = children.$LI; - } - - if (flags & 8 - /* ComponentFunction */ - ) { - vNode = children; - } - - if (flags & 8192 - /* Fragment */ - ) { - if (vNode.childFlags === 2 - /* HasVNodeChildren */ - ) { - vNode = children; - } else { - for (var i = 0, len = children.length; i < len; ++i) { - clearVNodeDOM(children[i], parentDOM, false); - } - - return; - } - } - } while (vNode); - } - - function createDeferComponentClassRemovalCallback(vNode, parentDOM) { - return function () { - // Mark removal as deferred to trigger check that node still exists - clearVNodeDOM(vNode, parentDOM, true); - }; - } - - function removeVNodeDOM(vNode, parentDOM, animations) { - if (animations.componentWillDisappear.length > 0) { - // Wait until animations are finished before removing actual dom nodes - callAllAnimationHooks(animations.componentWillDisappear, createDeferComponentClassRemovalCallback(vNode, parentDOM)); - } else { - clearVNodeDOM(vNode, parentDOM, false); - } - } - - function addMoveAnimationHook(animations, parentVNode, refOrInstance, dom, parentDOM, nextNode, flags, props) { - animations.componentWillMove.push({ - dom: dom, - fn: function fn() { - if (flags & 4 - /* ComponentClass */ - ) { - refOrInstance.componentWillMove(parentVNode, parentDOM, dom, props); - } else if (flags & 8 - /* ComponentFunction */ - ) { - refOrInstance.onComponentWillMove(parentVNode, parentDOM, dom, props); - } - }, - next: nextNode, - parent: parentDOM - }); - } - - function moveVNodeDOM(parentVNode, vNode, parentDOM, nextNode, animations) { - var refOrInstance; - var instanceProps; - var instanceFlags = vNode.flags; - - do { - var flags = vNode.flags; - - if (flags & 2033 - /* DOMRef */ - ) { - if (!isNullOrUndef$3(refOrInstance) && (isFunction$3(refOrInstance.componentWillMove) || isFunction$3(refOrInstance.onComponentWillMove))) { - addMoveAnimationHook(animations, parentVNode, refOrInstance, vNode.dom, parentDOM, nextNode, instanceFlags, instanceProps); - } else { - // TODO: Should we delay this too to support mixing animated moves with regular? - insertOrAppend(parentDOM, vNode.dom, nextNode); - } - - return; - } - - var children = vNode.children; - - if (flags & 4 - /* ComponentClass */ - ) { - refOrInstance = vNode.children; - instanceProps = vNode.props; - vNode = children.$LI; - } - - if (flags & 8 - /* ComponentFunction */ - ) { - refOrInstance = vNode.ref; - instanceProps = vNode.props; - vNode = children; - } - - if (flags & 8192 - /* Fragment */ - ) { - if (vNode.childFlags === 2 - /* HasVNodeChildren */ - ) { - vNode = children; - } else { - for (var i = 0, len = children.length; i < len; ++i) { - moveVNodeDOM(parentVNode, children[i], parentDOM, nextNode, animations); - } - - return; - } - } - } while (vNode); - } - - function createDerivedState(instance, nextProps, state) { - if (instance.constructor.getDerivedStateFromProps) { - return combineFrom$1(state, instance.constructor.getDerivedStateFromProps(nextProps, state)); - } - - return state; - } - - var renderCheck = { - v: false - }; - var options = { - componentComparator: null, - createVNode: null, - renderComplete: null - }; - - function setTextContent(dom, children) { - dom.textContent = children; - } // Calling this function assumes, nextValue is linkEvent - - - function isLastValueSameLinkEvent(lastValue, nextValue) { - return isLinkEventObject(lastValue) && lastValue.event === nextValue.event && lastValue.data === nextValue.data; - } - - function mergeUnsetProperties(to, from) { - for (var propName in from) { - if (isUndefined$1(to[propName])) { - to[propName] = from[propName]; - } - } - - return to; - } - - function safeCall1(method, arg1) { - return !!isFunction$3(method) && (method(arg1), true); - } - - var keyPrefix = '$'; - - function V(childFlags, children, className, flags, key, props, ref, type) { - this.childFlags = childFlags; - this.children = children; - this.className = className; - this.dom = null; - this.flags = flags; - this.key = key === void 0 ? null : key; - this.props = props === void 0 ? null : props; - this.ref = ref === void 0 ? null : ref; - this.type = type; - } - - function createVNode(flags, type, className, children, childFlags, props, key, ref) { - var childFlag = childFlags === void 0 ? 1 - /* HasInvalidChildren */ - : childFlags; - var vNode = new V(childFlag, children, className, flags, key, props, ref, type); - - if (options.createVNode) { - options.createVNode(vNode); - } - - if (childFlag === 0 - /* UnknownChildren */ - ) { - normalizeChildren(vNode, vNode.children); - } - - return vNode; - } - - function mergeDefaultHooks(flags, type, ref) { - if (flags & 4 - /* ComponentClass */ - ) { - return ref; - } - - var defaultHooks = (flags & 32768 - /* ForwardRef */ - ? type.render : type).defaultHooks; - - if (isNullOrUndef$3(defaultHooks)) { - return ref; - } - - if (isNullOrUndef$3(ref)) { - return defaultHooks; - } - - return mergeUnsetProperties(ref, defaultHooks); - } - - function mergeDefaultProps(flags, type, props) { - // set default props - var defaultProps = (flags & 32768 - /* ForwardRef */ - ? type.render : type).defaultProps; - - if (isNullOrUndef$3(defaultProps)) { - return props; - } - - if (isNullOrUndef$3(props)) { - return combineFrom$1(defaultProps, null); - } - - return mergeUnsetProperties(props, defaultProps); - } - - function resolveComponentFlags(flags, type) { - if (flags & 12 - /* ComponentKnown */ - ) { - return flags; - } - - if (type.prototype && type.prototype.render) { - return 4 - /* ComponentClass */ - ; - } - - if (type.render) { - return 32776 - /* ForwardRefComponent */ - ; - } - - return 8 - /* ComponentFunction */ - ; - } - - function createComponentVNode(flags, type, props, key, ref) { - flags = resolveComponentFlags(flags, type); - var vNode = new V(1 - /* HasInvalidChildren */ - , null, null, flags, key, mergeDefaultProps(flags, type, props), mergeDefaultHooks(flags, type, ref), type); - - if (options.createVNode) { - options.createVNode(vNode); - } - - return vNode; - } - - function createTextVNode(text, key) { - return new V(1 - /* HasInvalidChildren */ - , isNullOrUndef$3(text) || text === true || text === false ? '' : text, null, 16 - /* Text */ - , key, null, null, null); - } - - function createFragment(children, childFlags, key) { - var fragment = createVNode(8192 - /* Fragment */ - , 8192 - /* Fragment */ - , null, children, childFlags, null, key, null); - - switch (fragment.childFlags) { - case 1 - /* HasInvalidChildren */ - : - fragment.children = createVoidVNode(); - fragment.childFlags = 2 - /* HasVNodeChildren */ - ; - break; - - case 16 - /* HasTextChildren */ - : - fragment.children = [createTextVNode(children)]; - fragment.childFlags = 4 - /* HasNonKeyedChildren */ - ; - break; - } - - return fragment; - } - - function normalizeProps(vNode) { - var props = vNode.props; - - if (props) { - var flags = vNode.flags; - - if (flags & 481 - /* Element */ - ) { - if (props.children !== void 0 && isNullOrUndef$3(vNode.children)) { - normalizeChildren(vNode, props.children); - } - - if (props.className !== void 0) { - if (isNullOrUndef$3(vNode.className)) { - vNode.className = props.className || null; - } - - props.className = undefined; - } - } - - if (props.key !== void 0) { - vNode.key = props.key; - props.key = undefined; - } - - if (props.ref !== void 0) { - if (flags & 8 - /* ComponentFunction */ - ) { - vNode.ref = combineFrom$1(vNode.ref, props.ref); - } else { - vNode.ref = props.ref; - } - - props.ref = undefined; - } - } - - return vNode; - } - /* - * Fragment is different than normal vNode, - * because when it needs to be cloned we need to clone its children too - * But not normalize, because otherwise those possibly get KEY and re-mount - */ - - - function cloneFragment(vNodeToClone) { - var oldChildren = vNodeToClone.children; - var childFlags = vNodeToClone.childFlags; - return createFragment(childFlags === 2 - /* HasVNodeChildren */ - ? directClone(oldChildren) : oldChildren.map(directClone), childFlags, vNodeToClone.key); - } - - function directClone(vNodeToClone) { - var flags = vNodeToClone.flags & -16385 - /* ClearInUse */ - ; - var props = vNodeToClone.props; - - if (flags & 14 - /* Component */ - ) { - if (!isNull$2(props)) { - var propsToClone = props; - props = {}; - - for (var key in propsToClone) { - props[key] = propsToClone[key]; - } - } - } - - if ((flags & 8192 - /* Fragment */ - ) === 0) { - return new V(vNodeToClone.childFlags, vNodeToClone.children, vNodeToClone.className, flags, vNodeToClone.key, props, vNodeToClone.ref, vNodeToClone.type); - } - - return cloneFragment(vNodeToClone); - } - - function createVoidVNode() { - return createTextVNode('', null); - } - - function createPortal(children, container) { - var normalizedRoot = normalizeRoot(children); - return createVNode(1024 - /* Portal */ - , 1024 - /* Portal */ - , null, normalizedRoot, 0 - /* UnknownChildren */ - , null, normalizedRoot.key, container); - } - - function _normalizeVNodes(nodes, result, index, currentKey) { - for (var len = nodes.length; index < len; index++) { - var n = nodes[index]; - - if (!isInvalid$2(n)) { - var newKey = currentKey + keyPrefix + index; - - if (isArray$1(n)) { - _normalizeVNodes(n, result, 0, newKey); - } else { - if (isStringOrNumber(n)) { - n = createTextVNode(n, newKey); - } else { - var oldKey = n.key; - var isPrefixedKey = isString$2(oldKey) && oldKey[0] === keyPrefix; - - if (n.flags & 81920 - /* InUseOrNormalized */ - || isPrefixedKey) { - n = directClone(n); - } - - n.flags |= 65536 - /* Normalized */ - ; - - if (!isPrefixedKey) { - if (isNull$2(oldKey)) { - n.key = newKey; - } else { - n.key = currentKey + oldKey; - } - } else if (oldKey.substring(0, currentKey.length) !== currentKey) { - n.key = currentKey + oldKey; - } - } - - result.push(n); - } - } - } - } - - function getFlagsForElementVnode(type) { - switch (type) { - case 'svg': - return 32 - /* SvgElement */ - ; - - case 'input': - return 64 - /* InputElement */ - ; - - case 'select': - return 256 - /* SelectElement */ - ; - - case 'textarea': - return 128 - /* TextareaElement */ - ; - - case Fragment: - return 8192 - /* Fragment */ - ; - - default: - return 1 - /* HtmlElement */ - ; - } - } - - function normalizeChildren(vNode, children) { - var newChildren; - var newChildFlags = 1 - /* HasInvalidChildren */ - ; // Don't change children to match strict equal (===) true in patching - - if (isInvalid$2(children)) { - newChildren = children; - } else if (isStringOrNumber(children)) { - newChildFlags = 16 - /* HasTextChildren */ - ; - newChildren = children; - } else if (isArray$1(children)) { - var len = children.length; - - for (var i = 0; i < len; ++i) { - var n = children[i]; - - if (isInvalid$2(n) || isArray$1(n)) { - newChildren = newChildren || children.slice(0, i); - - _normalizeVNodes(children, newChildren, i, ''); - - break; - } else if (isStringOrNumber(n)) { - newChildren = newChildren || children.slice(0, i); - newChildren.push(createTextVNode(n, keyPrefix + i)); - } else { - var key = n.key; - var needsCloning = (n.flags & 81920 - /* InUseOrNormalized */ - ) > 0; - var isNullKey = isNull$2(key); - var isPrefixed = isString$2(key) && key[0] === keyPrefix; - - if (needsCloning || isNullKey || isPrefixed) { - newChildren = newChildren || children.slice(0, i); - - if (needsCloning || isPrefixed) { - n = directClone(n); - } - - if (isNullKey || isPrefixed) { - n.key = keyPrefix + i; - } - - newChildren.push(n); - } else if (newChildren) { - newChildren.push(n); - } - - n.flags |= 65536 - /* Normalized */ - ; - } - } - - newChildren = newChildren || children; - - if (newChildren.length === 0) { - newChildFlags = 1 - /* HasInvalidChildren */ - ; - } else { - newChildFlags = 8 - /* HasKeyedChildren */ - ; - } - } else { - newChildren = children; - newChildren.flags |= 65536 - /* Normalized */ - ; - - if (children.flags & 81920 - /* InUseOrNormalized */ - ) { - newChildren = directClone(children); - } - - newChildFlags = 2 - /* HasVNodeChildren */ - ; - } - - vNode.children = newChildren; - vNode.childFlags = newChildFlags; - return vNode; - } - - function normalizeRoot(input) { - if (isInvalid$2(input) || isStringOrNumber(input)) { - return createTextVNode(input, null); - } - - if (isArray$1(input)) { - return createFragment(input, 0 - /* UnknownChildren */ - , null); - } - - return input.flags & 16384 - /* InUse */ - ? directClone(input) : input; - } - - var xlinkNS = 'http://www.w3.org/1999/xlink'; - var xmlNS = 'http://www.w3.org/XML/1998/namespace'; - var namespaces = { - 'xlink:actuate': xlinkNS, - 'xlink:arcrole': xlinkNS, - 'xlink:href': xlinkNS, - 'xlink:role': xlinkNS, - 'xlink:show': xlinkNS, - 'xlink:title': xlinkNS, - 'xlink:type': xlinkNS, - 'xml:base': xmlNS, - 'xml:lang': xmlNS, - 'xml:space': xmlNS - }; - - function getDelegatedEventObject(v) { - return { - onClick: v, - onDblClick: v, - onFocusIn: v, - onFocusOut: v, - onKeyDown: v, - onKeyPress: v, - onKeyUp: v, - onMouseDown: v, - onMouseMove: v, - onMouseUp: v, - onTouchEnd: v, - onTouchMove: v, - onTouchStart: v - }; - } - - var attachedEventCounts = getDelegatedEventObject(0); - var attachedEvents = getDelegatedEventObject(null); - var syntheticEvents = getDelegatedEventObject(true); - - function updateOrAddSyntheticEvent(name, dom) { - var eventsObject = dom.$EV; - - if (!eventsObject) { - eventsObject = dom.$EV = getDelegatedEventObject(null); - } - - if (!eventsObject[name]) { - if (++attachedEventCounts[name] === 1) { - attachedEvents[name] = attachEventToDocument(name); - } - } - - return eventsObject; - } - - function unmountSyntheticEvent(name, dom) { - var eventsObject = dom.$EV; - - if (eventsObject && eventsObject[name]) { - if (--attachedEventCounts[name] === 0) { - document.removeEventListener(normalizeEventName(name), attachedEvents[name]); - attachedEvents[name] = null; - } - - eventsObject[name] = null; - } - } - - function handleSyntheticEvent(name, lastEvent, nextEvent, dom) { - if (isFunction$3(nextEvent)) { - updateOrAddSyntheticEvent(name, dom)[name] = nextEvent; - } else if (isLinkEventObject(nextEvent)) { - if (isLastValueSameLinkEvent(lastEvent, nextEvent)) { - return; - } - - updateOrAddSyntheticEvent(name, dom)[name] = nextEvent; - } else { - unmountSyntheticEvent(name, dom); - } - } // When browsers fully support event.composedPath we could loop it through instead of using parentNode property - - - function getTargetNode(event) { - return isFunction$3(event.composedPath) ? event.composedPath()[0] : event.target; - } - - function dispatchEvents(event, isClick, name, eventData) { - var dom = getTargetNode(event); - - do { - // Html Nodes can be nested fe: span inside button in that scenario browser does not handle disabled attribute on parent, - // because the event listener is on document.body - // Don't process clicks on disabled elements - if (isClick && dom.disabled) { - return; - } - - var eventsObject = dom.$EV; - - if (eventsObject) { - var currentEvent = eventsObject[name]; - - if (currentEvent) { - // linkEvent object - eventData.dom = dom; - currentEvent.event ? currentEvent.event(currentEvent.data, event) : currentEvent(event); - - if (event.cancelBubble) { - return; - } - } - } - - dom = dom.parentNode; - } while (!isNull$2(dom)); - } - - function stopPropagation() { - this.cancelBubble = true; - - if (!this.immediatePropagationStopped) { - this.stopImmediatePropagation(); - } - } - - function isDefaultPrevented() { - return this.defaultPrevented; - } - - function isPropagationStopped() { - return this.cancelBubble; - } - - function extendEventProperties(event) { - // Event data needs to be object to save reference to currentTarget getter - var eventData = { - dom: document - }; - event.isDefaultPrevented = isDefaultPrevented; - event.isPropagationStopped = isPropagationStopped; - event.stopPropagation = stopPropagation; - Object.defineProperty(event, 'currentTarget', { - configurable: true, - get: function get() { - return eventData.dom; - } - }); - return eventData; - } - - function rootClickEvent(name) { - return function (event) { - if (event.button !== 0) { - // Firefox incorrectly triggers click event for mid/right mouse buttons. - // This bug has been active for 17 years. - // https://bugzilla.mozilla.org/show_bug.cgi?id=184051 - event.stopPropagation(); - return; - } - - dispatchEvents(event, true, name, extendEventProperties(event)); - }; - } - - function rootEvent(name) { - return function (event) { - dispatchEvents(event, false, name, extendEventProperties(event)); - }; - } - - function attachEventToDocument(name) { - var attachedEvent = name === 'onClick' || name === 'onDblClick' ? rootClickEvent(name) : rootEvent(name); - document.addEventListener(normalizeEventName(name), attachedEvent); - return attachedEvent; - } - - function isSameInnerHTML$1(dom, innerHTML) { - var tempdom = document.createElement('i'); - tempdom.innerHTML = innerHTML; - return tempdom.innerHTML === dom.innerHTML; - } - - function triggerEventListener(props, methodName, e) { - if (props[methodName]) { - var listener = props[methodName]; - - if (listener.event) { - listener.event(listener.data, e); - } else { - listener(e); - } - } else { - var nativeListenerName = methodName.toLowerCase(); - - if (props[nativeListenerName]) { - props[nativeListenerName](e); - } - } - } - - function createWrappedFunction(methodName, applyValue) { - var fnMethod = function fnMethod(e) { - var vNode = this.$V; // If vNode is gone by the time event fires, no-op - - if (!vNode) { - return; - } - - var props = vNode.props || EMPTY_OBJ; - var dom = vNode.dom; - - if (isString$2(methodName)) { - triggerEventListener(props, methodName, e); - } else { - for (var i = 0; i < methodName.length; ++i) { - triggerEventListener(props, methodName[i], e); - } - } - - if (isFunction$3(applyValue)) { - var newVNode = this.$V; - var newProps = newVNode.props || EMPTY_OBJ; - applyValue(newProps, dom, false, newVNode); - } - }; - - Object.defineProperty(fnMethod, 'wrapped', { - configurable: false, - enumerable: false, - value: true, - writable: false - }); - return fnMethod; - } - - function attachEvent(dom, eventName, handler) { - var previousKey = "$" + eventName; - var previousArgs = dom[previousKey]; - - if (previousArgs) { - if (previousArgs[1].wrapped) { - return; - } - - dom.removeEventListener(previousArgs[0], previousArgs[1]); - dom[previousKey] = null; - } - - if (isFunction$3(handler)) { - dom.addEventListener(eventName, handler); - dom[previousKey] = [eventName, handler]; - } - } - - function isCheckedType(type) { - return type === 'checkbox' || type === 'radio'; - } - - var onTextInputChange = createWrappedFunction('onInput', applyValueInput); - var wrappedOnChange$1 = createWrappedFunction(['onClick', 'onChange'], applyValueInput); - /* tslint:disable-next-line:no-empty */ - - function emptywrapper(event) { - event.stopPropagation(); - } - - emptywrapper.wrapped = true; - - function inputEvents(dom, nextPropsOrEmpty) { - if (isCheckedType(nextPropsOrEmpty.type)) { - attachEvent(dom, 'change', wrappedOnChange$1); - attachEvent(dom, 'click', emptywrapper); - } else { - attachEvent(dom, 'input', onTextInputChange); - } - } - - function applyValueInput(nextPropsOrEmpty, dom) { - var type = nextPropsOrEmpty.type; - var value = nextPropsOrEmpty.value; - var checked = nextPropsOrEmpty.checked; - var multiple = nextPropsOrEmpty.multiple; - var defaultValue = nextPropsOrEmpty.defaultValue; - var hasValue = !isNullOrUndef$3(value); - - if (type && type !== dom.type) { - dom.setAttribute('type', type); - } - - if (!isNullOrUndef$3(multiple) && multiple !== dom.multiple) { - dom.multiple = multiple; - } - - if (!isNullOrUndef$3(defaultValue) && !hasValue) { - dom.defaultValue = defaultValue + ''; - } - - if (isCheckedType(type)) { - if (hasValue) { - dom.value = value; - } - - if (!isNullOrUndef$3(checked)) { - dom.checked = checked; - } - } else { - if (hasValue && dom.value !== value) { - dom.defaultValue = value; - dom.value = value; - } else if (!isNullOrUndef$3(checked)) { - dom.checked = checked; - } - } - } - - function updateChildOptions(vNode, value) { - if (vNode.type === 'option') { - updateChildOption(vNode, value); - } else { - var children = vNode.children; - var flags = vNode.flags; - - if (flags & 4 - /* ComponentClass */ - ) { - updateChildOptions(children.$LI, value); - } else if (flags & 8 - /* ComponentFunction */ - ) { - updateChildOptions(children, value); - } else if (vNode.childFlags === 2 - /* HasVNodeChildren */ - ) { - updateChildOptions(children, value); - } else if (vNode.childFlags & 12 - /* MultipleChildren */ - ) { - for (var i = 0, len = children.length; i < len; ++i) { - updateChildOptions(children[i], value); - } - } - } - } - - function updateChildOption(vNode, value) { - var props = vNode.props || EMPTY_OBJ; - var dom = vNode.dom; // we do this as multiple may have changed - - dom.value = props.value; - - if (props.value === value || isArray$1(value) && value.indexOf(props.value) !== -1) { - dom.selected = true; - } else if (!isNullOrUndef$3(value) || !isNullOrUndef$3(props.selected)) { - dom.selected = props.selected || false; - } - } - - var onSelectChange = createWrappedFunction('onChange', applyValueSelect); - - function selectEvents(dom) { - attachEvent(dom, 'change', onSelectChange); - } - - function applyValueSelect(nextPropsOrEmpty, dom, mounting, vNode) { - var multiplePropInBoolean = Boolean(nextPropsOrEmpty.multiple); - - if (!isNullOrUndef$3(nextPropsOrEmpty.multiple) && multiplePropInBoolean !== dom.multiple) { - dom.multiple = multiplePropInBoolean; - } - - var index = nextPropsOrEmpty.selectedIndex; - - if (index === -1) { - dom.selectedIndex = -1; - } - - var childFlags = vNode.childFlags; - - if (childFlags !== 1 - /* HasInvalidChildren */ - ) { - var value = nextPropsOrEmpty.value; - - if (isNumber$1(index) && index > -1 && dom.options[index]) { - value = dom.options[index].value; - } - - if (mounting && isNullOrUndef$3(value)) { - value = nextPropsOrEmpty.defaultValue; - } - - updateChildOptions(vNode, value); - } - } - - var onTextareaInputChange = createWrappedFunction('onInput', applyValueTextArea); - var wrappedOnChange = createWrappedFunction('onChange'); - - function textAreaEvents(dom, nextPropsOrEmpty) { - attachEvent(dom, 'input', onTextareaInputChange); - - if (nextPropsOrEmpty.onChange) { - attachEvent(dom, 'change', wrappedOnChange); - } - } - - function applyValueTextArea(nextPropsOrEmpty, dom, mounting) { - var value = nextPropsOrEmpty.value; - var domValue = dom.value; - - if (isNullOrUndef$3(value)) { - if (mounting) { - var defaultValue = nextPropsOrEmpty.defaultValue; - - if (!isNullOrUndef$3(defaultValue) && defaultValue !== domValue) { - dom.defaultValue = defaultValue; - dom.value = defaultValue; - } - } - } else if (domValue !== value) { - /* There is value so keep it controlled */ - dom.defaultValue = value; - dom.value = value; - } - } - - function processElement(flags, vNode, dom, nextPropsOrEmpty, mounting, isControlled) { - if (flags & 64 - /* InputElement */ - ) { - applyValueInput(nextPropsOrEmpty, dom); - } else if (flags & 256 - /* SelectElement */ - ) { - applyValueSelect(nextPropsOrEmpty, dom, mounting, vNode); - } else if (flags & 128 - /* TextareaElement */ - ) { - applyValueTextArea(nextPropsOrEmpty, dom, mounting); - } - - if (isControlled) { - dom.$V = vNode; - } - } - - function addFormElementEventHandlers(flags, dom, nextPropsOrEmpty) { - if (flags & 64 - /* InputElement */ - ) { - inputEvents(dom, nextPropsOrEmpty); - } else if (flags & 256 - /* SelectElement */ - ) { - selectEvents(dom); - } else if (flags & 128 - /* TextareaElement */ - ) { - textAreaEvents(dom, nextPropsOrEmpty); - } - } - - function isControlledFormElement(nextPropsOrEmpty) { - return nextPropsOrEmpty.type && isCheckedType(nextPropsOrEmpty.type) ? !isNullOrUndef$3(nextPropsOrEmpty.checked) : !isNullOrUndef$3(nextPropsOrEmpty.value); - } - - function createRef() { - return { - current: null - }; - } - - function forwardRef(render) { - // @ts-ignore - return { - render: render - }; - } - - function unmountRef(ref) { - if (ref) { - if (!safeCall1(ref, null) && ref.current) { - ref.current = null; - } - } - } - - function mountRef(ref, value, lifecycle) { - if (ref && (isFunction$3(ref) || ref.current !== void 0)) { - lifecycle.push(function () { - if (!safeCall1(ref, value) && ref.current !== void 0) { - ref.current = value; - } - }); - } - } - - function remove(vNode, parentDOM, animations) { - unmount(vNode, animations); - removeVNodeDOM(vNode, parentDOM, animations); - } - - function unmount(vNode, animations) { - var flags = vNode.flags; - var children = vNode.children; - var ref; - - if (flags & 481 - /* Element */ - ) { - ref = vNode.ref; - var props = vNode.props; - unmountRef(ref); - var childFlags = vNode.childFlags; - - if (!isNull$2(props)) { - var keys = Object.keys(props); - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i]; - - if (syntheticEvents[key]) { - unmountSyntheticEvent(key, vNode.dom); - } - } - } - - if (childFlags & 12 - /* MultipleChildren */ - ) { - unmountAllChildren(children, animations); - } else if (childFlags === 2 - /* HasVNodeChildren */ - ) { - unmount(children, animations); - } - } else if (children) { - if (flags & 4 - /* ComponentClass */ - ) { - if (isFunction$3(children.componentWillUnmount)) { - // TODO: Possible entrypoint - children.componentWillUnmount(); - } // If we have a componentWillDisappear on this component, block children - - - var childAnimations = animations; - - if (isFunction$3(children.componentWillDisappear)) { - childAnimations = new AnimationQueues(); - addDisappearAnimationHook(animations, children, children.$LI.dom, flags, undefined); - } - - unmountRef(vNode.ref); - children.$UN = true; - unmount(children.$LI, childAnimations); - } else if (flags & 8 - /* ComponentFunction */ - ) { - // If we have a onComponentWillDisappear on this component, block children - var childAnimations$1 = animations; - ref = vNode.ref; - - if (!isNullOrUndef$3(ref)) { - var domEl = findDOMfromVNode(vNode, true); - - if (isFunction$3(ref.onComponentWillUnmount)) { - ref.onComponentWillUnmount(domEl, vNode.props || EMPTY_OBJ); - } - - if (isFunction$3(ref.onComponentWillDisappear)) { - childAnimations$1 = new AnimationQueues(); - addDisappearAnimationHook(animations, ref, domEl, flags, vNode.props); - } - } - - unmount(children, childAnimations$1); - } else if (flags & 1024 - /* Portal */ - ) { - remove(children, vNode.ref, animations); - } else if (flags & 8192 - /* Fragment */ - ) { - if (vNode.childFlags & 12 - /* MultipleChildren */ - ) { - unmountAllChildren(children, animations); - } - } - } - } - - function unmountAllChildren(children, animations) { - for (var i = 0, len = children.length; i < len; ++i) { - unmount(children[i], animations); - } - } - - function createClearAllCallback(children, parentDOM) { - return function () { - // We need to remove children one by one because elements can be added during animation - if (parentDOM) { - for (var i = 0; i < children.length; i++) { - var vNode = children[i]; - clearVNodeDOM(vNode, parentDOM, false); - } - } - }; - } - - function clearDOM(parentDOM, children, animations) { - if (animations.componentWillDisappear.length > 0) { - // Wait until animations are finished before removing actual dom nodes - // Be aware that the element could be removed by a later operation - callAllAnimationHooks(animations.componentWillDisappear, createClearAllCallback(children, parentDOM)); - } else { - // Optimization for clearing dom - parentDOM.textContent = ''; - } - } - - function removeAllChildren(dom, vNode, children, animations) { - unmountAllChildren(children, animations); - - if (vNode.flags & 8192 - /* Fragment */ - ) { - removeVNodeDOM(vNode, dom, animations); - } else { - clearDOM(dom, children, animations); - } - } // Only add animations to queue in browser - - - function addDisappearAnimationHook(animations, instanceOrRef, dom, flags, props) { - animations.componentWillDisappear.push(function (callback) { - if (flags & 4 - /* ComponentClass */ - ) { - instanceOrRef.componentWillDisappear(dom, callback); - } else if (flags & 8 - /* ComponentFunction */ - ) { - instanceOrRef.onComponentWillDisappear(dom, props, callback); - } - }); - } - - function wrapLinkEvent(nextValue) { - // This variable makes sure there is no "this" context in callback - var ev = nextValue.event; - return function (e) { - ev(nextValue.data, e); - }; - } - - function patchEvent(name, lastValue, nextValue, dom) { - if (isLinkEventObject(nextValue)) { - if (isLastValueSameLinkEvent(lastValue, nextValue)) { - return; - } - - nextValue = wrapLinkEvent(nextValue); - } - - attachEvent(dom, normalizeEventName(name), nextValue); - } // We are assuming here that we come from patchProp routine - // -nextAttrValue cannot be null or undefined - - - function patchStyle(lastAttrValue, nextAttrValue, dom) { - if (isNullOrUndef$3(nextAttrValue)) { - dom.removeAttribute('style'); - return; - } - - var domStyle = dom.style; - var style; - var value; - - if (isString$2(nextAttrValue)) { - domStyle.cssText = nextAttrValue; - return; - } - - if (!isNullOrUndef$3(lastAttrValue) && !isString$2(lastAttrValue)) { - for (style in nextAttrValue) { - // do not add a hasOwnProperty check here, it affects performance - value = nextAttrValue[style]; - - if (value !== lastAttrValue[style]) { - domStyle.setProperty(style, value); - } - } - - for (style in lastAttrValue) { - if (isNullOrUndef$3(nextAttrValue[style])) { - domStyle.removeProperty(style); - } - } - } else { - for (style in nextAttrValue) { - value = nextAttrValue[style]; - domStyle.setProperty(style, value); - } - } - } - - function patchDangerInnerHTML(lastValue, nextValue, lastVNode, dom, animations) { - var lastHtml = lastValue && lastValue.__html || ''; - var nextHtml = nextValue && nextValue.__html || ''; - - if (lastHtml !== nextHtml) { - if (!isNullOrUndef$3(nextHtml) && !isSameInnerHTML$1(dom, nextHtml)) { - if (!isNull$2(lastVNode)) { - if (lastVNode.childFlags & 12 - /* MultipleChildren */ - ) { - unmountAllChildren(lastVNode.children, animations); - } else if (lastVNode.childFlags === 2 - /* HasVNodeChildren */ - ) { - unmount(lastVNode.children, animations); - } - - lastVNode.children = null; - lastVNode.childFlags = 1 - /* HasInvalidChildren */ - ; - } - - dom.innerHTML = nextHtml; - } - } - } - - function patchProp(prop, lastValue, nextValue, dom, isSVG, hasControlledValue, lastVNode, animations) { - switch (prop) { - case 'children': - case 'childrenType': - case 'className': - case 'defaultValue': - case 'key': - case 'multiple': - case 'ref': - case 'selectedIndex': - break; - - case 'autoFocus': - dom.autofocus = !!nextValue; - break; - - case 'allowfullscreen': - case 'autoplay': - case 'capture': - case 'checked': - case 'controls': - case 'default': - case 'disabled': - case 'hidden': - case 'indeterminate': - case 'loop': - case 'muted': - case 'novalidate': - case 'open': - case 'readOnly': - case 'required': - case 'reversed': - case 'scoped': - case 'seamless': - case 'selected': - dom[prop] = !!nextValue; - break; - - case 'defaultChecked': - case 'value': - case 'volume': - if (hasControlledValue && prop === 'value') { - break; - } - - var value = isNullOrUndef$3(nextValue) ? '' : nextValue; - - if (dom[prop] !== value) { - dom[prop] = value; - } - - break; - - case 'style': - patchStyle(lastValue, nextValue, dom); - break; - - case 'dangerouslySetInnerHTML': - patchDangerInnerHTML(lastValue, nextValue, lastVNode, dom, animations); - break; - - default: - if (syntheticEvents[prop]) { - handleSyntheticEvent(prop, lastValue, nextValue, dom); - } else if (prop.charCodeAt(0) === 111 && prop.charCodeAt(1) === 110) { - patchEvent(prop, lastValue, nextValue, dom); - } else if (isNullOrUndef$3(nextValue)) { - dom.removeAttribute(prop); - } else if (isSVG && namespaces[prop]) { - // We optimize for isSVG being false - // If we end up in this path we can read property again - dom.setAttributeNS(namespaces[prop], prop, nextValue); - } else { - dom.setAttribute(prop, nextValue); - } - - break; - } - } - - function mountProps(vNode, flags, props, dom, isSVG, animations) { - var hasControlledValue = false; - var isFormElement = (flags & 448 - /* FormElement */ - ) > 0; - - if (isFormElement) { - hasControlledValue = isControlledFormElement(props); - - if (hasControlledValue) { - addFormElementEventHandlers(flags, dom, props); - } - } - - for (var prop in props) { - // do not add a hasOwnProperty check here, it affects performance - patchProp(prop, null, props[prop], dom, isSVG, hasControlledValue, null, animations); - } - - if (isFormElement) { - processElement(flags, vNode, dom, props, true, hasControlledValue); - } - } - - function renderNewInput(instance, props, context) { - var nextInput = normalizeRoot(instance.render(props, instance.state, context)); - var childContext = context; - - if (isFunction$3(instance.getChildContext)) { - childContext = combineFrom$1(context, instance.getChildContext()); - } - - instance.$CX = childContext; - return nextInput; - } - - function createClassComponentInstance(vNode, Component, props, context, isSVG, lifecycle) { - var instance = new Component(props, context); - var usesNewAPI = instance.$N = Boolean(Component.getDerivedStateFromProps || instance.getSnapshotBeforeUpdate); - instance.$SVG = isSVG; - instance.$L = lifecycle; - vNode.children = instance; - instance.$BS = false; - instance.context = context; - - if (instance.props === EMPTY_OBJ) { - instance.props = props; - } - - if (!usesNewAPI) { - if (isFunction$3(instance.componentWillMount)) { - instance.$BR = true; - instance.componentWillMount(); - var pending = instance.$PS; - - if (!isNull$2(pending)) { - var state = instance.state; - - if (isNull$2(state)) { - instance.state = pending; - } else { - for (var key in pending) { - state[key] = pending[key]; - } - } - - instance.$PS = null; - } - - instance.$BR = false; - } - } else { - instance.state = createDerivedState(instance, props, instance.state); - } - - instance.$LI = renderNewInput(instance, props, context); - return instance; - } - - function renderFunctionalComponent(vNode, context) { - var props = vNode.props || EMPTY_OBJ; - return vNode.flags & 32768 - /* ForwardRef */ - ? vNode.type.render(props, vNode.ref, context) : vNode.type(props, context); - } - - function mount(vNode, parentDOM, context, isSVG, nextNode, lifecycle, animations) { - var flags = vNode.flags |= 16384 - /* InUse */ - ; - - if (flags & 481 - /* Element */ - ) { - mountElement(vNode, parentDOM, context, isSVG, nextNode, lifecycle, animations); - } else if (flags & 4 - /* ComponentClass */ - ) { - mountClassComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle, animations); - } else if (flags & 8 - /* ComponentFunction */ - ) { - mountFunctionalComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle, animations); - } else if (flags & 512 - /* Void */ - || flags & 16 - /* Text */ - ) { - mountText(vNode, parentDOM, nextNode); - } else if (flags & 8192 - /* Fragment */ - ) { - mountFragment(vNode, context, parentDOM, isSVG, nextNode, lifecycle, animations); - } else if (flags & 1024 - /* Portal */ - ) { - mountPortal(vNode, context, parentDOM, nextNode, lifecycle, animations); - } else ; - } - - function mountPortal(vNode, context, parentDOM, nextNode, lifecycle, animations) { - mount(vNode.children, vNode.ref, context, false, null, lifecycle, animations); - var placeHolderVNode = createVoidVNode(); - mountText(placeHolderVNode, parentDOM, nextNode); - vNode.dom = placeHolderVNode.dom; - } - - function mountFragment(vNode, context, parentDOM, isSVG, nextNode, lifecycle, animations) { - var children = vNode.children; - var childFlags = vNode.childFlags; // When fragment is optimized for multiple children, check if there is no children and change flag to invalid - // This is the only normalization always done, to keep optimization flags API same for fragments and regular elements - - if (childFlags & 12 - /* MultipleChildren */ - && children.length === 0) { - childFlags = vNode.childFlags = 2 - /* HasVNodeChildren */ - ; - children = vNode.children = createVoidVNode(); - } - - if (childFlags === 2 - /* HasVNodeChildren */ - ) { - mount(children, parentDOM, nextNode, isSVG, nextNode, lifecycle, animations); - } else { - mountArrayChildren(children, parentDOM, context, isSVG, nextNode, lifecycle, animations); - } - } - - function mountText(vNode, parentDOM, nextNode) { - var dom = vNode.dom = document.createTextNode(vNode.children); - - if (!isNull$2(parentDOM)) { - insertOrAppend(parentDOM, dom, nextNode); - } - } - - function mountElement(vNode, parentDOM, context, isSVG, nextNode, lifecycle, animations) { - var flags = vNode.flags; - var props = vNode.props; - var className = vNode.className; - var childFlags = vNode.childFlags; - var dom = vNode.dom = documentCreateElement(vNode.type, isSVG = isSVG || (flags & 32 - /* SvgElement */ - ) > 0); - var children = vNode.children; - - if (!isNullOrUndef$3(className) && className !== '') { - if (isSVG) { - dom.setAttribute('class', className); - } else { - dom.className = className; - } - } - - if (childFlags === 16 - /* HasTextChildren */ - ) { - setTextContent(dom, children); - } else if (childFlags !== 1 - /* HasInvalidChildren */ - ) { - var childrenIsSVG = isSVG && vNode.type !== 'foreignObject'; - - if (childFlags === 2 - /* HasVNodeChildren */ - ) { - if (children.flags & 16384 - /* InUse */ - ) { - vNode.children = children = directClone(children); - } - - mount(children, dom, context, childrenIsSVG, null, lifecycle, animations); - } else if (childFlags === 8 - /* HasKeyedChildren */ - || childFlags === 4 - /* HasNonKeyedChildren */ - ) { - mountArrayChildren(children, dom, context, childrenIsSVG, null, lifecycle, animations); - } - } - - if (!isNull$2(parentDOM)) { - insertOrAppend(parentDOM, dom, nextNode); - } - - if (!isNull$2(props)) { - mountProps(vNode, flags, props, dom, isSVG, animations); - } - - mountRef(vNode.ref, dom, lifecycle); - } - - function mountArrayChildren(children, dom, context, isSVG, nextNode, lifecycle, animations) { - for (var i = 0; i < children.length; ++i) { - var child = children[i]; - - if (child.flags & 16384 - /* InUse */ - ) { - children[i] = child = directClone(child); - } - - mount(child, dom, context, isSVG, nextNode, lifecycle, animations); - } - } - - function mountClassComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle, animations) { - var instance = createClassComponentInstance(vNode, vNode.type, vNode.props || EMPTY_OBJ, context, isSVG, lifecycle); // If we have a componentDidAppear on this component, we shouldn't allow children to animate so we're passing an dummy animations queue - - var childAnimations = animations; - - if (isFunction$3(instance.componentDidAppear)) { - childAnimations = new AnimationQueues(); - } - - mount(instance.$LI, parentDOM, instance.$CX, isSVG, nextNode, lifecycle, childAnimations); - mountClassComponentCallbacks(vNode.ref, instance, lifecycle, animations); - } - - function mountFunctionalComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle, animations) { - var ref = vNode.ref; // If we have a componentDidAppear on this component, we shouldn't allow children to animate so we're passing an dummy animations queue - - var childAnimations = animations; - - if (!isNullOrUndef$3(ref) && isFunction$3(ref.onComponentDidAppear)) { - childAnimations = new AnimationQueues(); - } - - mount(vNode.children = normalizeRoot(renderFunctionalComponent(vNode, context)), parentDOM, context, isSVG, nextNode, lifecycle, childAnimations); - mountFunctionalComponentCallbacks(vNode, lifecycle, animations); - } - - function createClassMountCallback(instance) { - return function () { - instance.componentDidMount(); - }; - } - - function addAppearAnimationHook(animations, instanceOrRef, dom, flags, props) { - animations.componentDidAppear.push(function () { - if (flags & 4 - /* ComponentClass */ - ) { - instanceOrRef.componentDidAppear(dom); - } else if (flags & 8 - /* ComponentFunction */ - ) { - instanceOrRef.onComponentDidAppear(dom, props); - } - }); - } - - function mountClassComponentCallbacks(ref, instance, lifecycle, animations) { - mountRef(ref, instance, lifecycle); - - if (isFunction$3(instance.componentDidMount)) { - lifecycle.push(createClassMountCallback(instance)); - } - - if (isFunction$3(instance.componentDidAppear)) { - addAppearAnimationHook(animations, instance, instance.$LI.dom, 4 - /* ComponentClass */ - , undefined); - } - } - - function createOnMountCallback(ref, vNode) { - return function () { - ref.onComponentDidMount(findDOMfromVNode(vNode, true), vNode.props || EMPTY_OBJ); - }; - } - - function mountFunctionalComponentCallbacks(vNode, lifecycle, animations) { - var ref = vNode.ref; - - if (!isNullOrUndef$3(ref)) { - safeCall1(ref.onComponentWillMount, vNode.props || EMPTY_OBJ); - - if (isFunction$3(ref.onComponentDidMount)) { - lifecycle.push(createOnMountCallback(ref, vNode)); - } - - if (isFunction$3(ref.onComponentDidAppear)) { - addAppearAnimationHook(animations, ref, findDOMfromVNode(vNode, true), 8 - /* ComponentFunction */ - , vNode.props); - } - } - } - - function replaceWithNewNode(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle, animations) { - unmount(lastVNode, animations); - - if ((nextVNode.flags & lastVNode.flags & 2033 - /* DOMRef */ - ) !== 0) { - mount(nextVNode, null, context, isSVG, null, lifecycle, animations); // Single DOM operation, when we have dom references available - - replaceChild(parentDOM, nextVNode.dom, lastVNode.dom); - } else { - mount(nextVNode, parentDOM, context, isSVG, findDOMfromVNode(lastVNode, true), lifecycle, animations); - removeVNodeDOM(lastVNode, parentDOM, animations); - } - } - - function patch(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle, animations) { - var nextFlags = nextVNode.flags |= 16384 - /* InUse */ - ; - - if (lastVNode.flags !== nextFlags || lastVNode.type !== nextVNode.type || lastVNode.key !== nextVNode.key || nextFlags & 2048 - /* ReCreate */ - ) { - if (lastVNode.flags & 16384 - /* InUse */ - ) { - replaceWithNewNode(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle, animations); - } else { - // Last vNode is not in use, it has crashed at application level. Just mount nextVNode and ignore last one - // TODO: What does this mean? Should we not not call animations here? - mount(nextVNode, parentDOM, context, isSVG, nextNode, lifecycle, animations); - } - } else if (nextFlags & 481 - /* Element */ - ) { - patchElement(lastVNode, nextVNode, context, isSVG, nextFlags, lifecycle, animations); - } else if (nextFlags & 4 - /* ComponentClass */ - ) { - patchClassComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle, animations); - } else if (nextFlags & 8 - /* ComponentFunction */ - ) { - patchFunctionalComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle, animations); - } else if (nextFlags & 16 - /* Text */ - ) { - patchText(lastVNode, nextVNode); - } else if (nextFlags & 512 - /* Void */ - ) { - nextVNode.dom = lastVNode.dom; - } else if (nextFlags & 8192 - /* Fragment */ - ) { - patchFragment(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle, animations); - } else { - patchPortal(lastVNode, nextVNode, context, lifecycle, animations); - } // Invoke move animations when all moves have been calculated - - - if (animations.componentWillMove.length > 0) { - callAllMoveAnimationHooks(animations.componentWillMove); - } - } - - function patchSingleTextChild(lastChildren, nextChildren, parentDOM) { - if (lastChildren !== nextChildren) { - if (lastChildren !== '') { - parentDOM.firstChild.nodeValue = nextChildren; - } else { - setTextContent(parentDOM, nextChildren); - } - } - } - - function patchContentEditableChildren(dom, nextChildren) { - if (dom.textContent !== nextChildren) { - dom.textContent = nextChildren; - } - } - - function patchFragment(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle, animations) { - var lastChildren = lastVNode.children; - var nextChildren = nextVNode.children; - var lastChildFlags = lastVNode.childFlags; - var nextChildFlags = nextVNode.childFlags; - var nextNode = null; // When fragment is optimized for multiple children, check if there is no children and change flag to invalid - // This is the only normalization always done, to keep optimization flags API same for fragments and regular elements - - if (nextChildFlags & 12 - /* MultipleChildren */ - && nextChildren.length === 0) { - nextChildFlags = nextVNode.childFlags = 2 - /* HasVNodeChildren */ - ; - nextChildren = nextVNode.children = createVoidVNode(); - } - - var nextIsSingle = (nextChildFlags & 2 - /* HasVNodeChildren */ - ) !== 0; - - if (lastChildFlags & 12 - /* MultipleChildren */ - ) { - var lastLen = lastChildren.length; // We need to know Fragment's edge node when - - if ( // It uses keyed algorithm - lastChildFlags & 8 - /* HasKeyedChildren */ - && nextChildFlags & 8 - /* HasKeyedChildren */ - || // It transforms from many to single - nextIsSingle || // It will append more nodes - !nextIsSingle && nextChildren.length > lastLen) { - // When fragment has multiple children there is always at least one vNode - nextNode = findDOMfromVNode(lastChildren[lastLen - 1], false).nextSibling; - } - } - - patchChildren(lastChildFlags, nextChildFlags, lastChildren, nextChildren, parentDOM, context, isSVG, nextNode, lastVNode, lifecycle, animations); - } - - function patchPortal(lastVNode, nextVNode, context, lifecycle, animations) { - var lastContainer = lastVNode.ref; - var nextContainer = nextVNode.ref; - var nextChildren = nextVNode.children; - patchChildren(lastVNode.childFlags, nextVNode.childFlags, lastVNode.children, nextChildren, lastContainer, context, false, null, lastVNode, lifecycle, animations); - nextVNode.dom = lastVNode.dom; - - if (lastContainer !== nextContainer && !isInvalid$2(nextChildren)) { - var node = nextChildren.dom; - removeChild(lastContainer, node); - appendChild(nextContainer, node); - } - } - - function patchElement(lastVNode, nextVNode, context, isSVG, nextFlags, lifecycle, animations) { - var dom = nextVNode.dom = lastVNode.dom; - var lastProps = lastVNode.props; - var nextProps = nextVNode.props; - var isFormElement = false; - var hasControlledValue = false; - var nextPropsOrEmpty; - isSVG = isSVG || (nextFlags & 32 - /* SvgElement */ - ) > 0; // inlined patchProps -- starts -- - - if (lastProps !== nextProps) { - var lastPropsOrEmpty = lastProps || EMPTY_OBJ; - nextPropsOrEmpty = nextProps || EMPTY_OBJ; - - if (nextPropsOrEmpty !== EMPTY_OBJ) { - isFormElement = (nextFlags & 448 - /* FormElement */ - ) > 0; - - if (isFormElement) { - hasControlledValue = isControlledFormElement(nextPropsOrEmpty); - } - - for (var prop in nextPropsOrEmpty) { - var lastValue = lastPropsOrEmpty[prop]; - var nextValue = nextPropsOrEmpty[prop]; - - if (lastValue !== nextValue) { - patchProp(prop, lastValue, nextValue, dom, isSVG, hasControlledValue, lastVNode, animations); - } - } - } - - if (lastPropsOrEmpty !== EMPTY_OBJ) { - for (var prop$1 in lastPropsOrEmpty) { - if (isNullOrUndef$3(nextPropsOrEmpty[prop$1]) && !isNullOrUndef$3(lastPropsOrEmpty[prop$1])) { - patchProp(prop$1, lastPropsOrEmpty[prop$1], null, dom, isSVG, hasControlledValue, lastVNode, animations); - } - } - } - } - - var nextChildren = nextVNode.children; - var nextClassName = nextVNode.className; // inlined patchProps -- ends -- - - if (lastVNode.className !== nextClassName) { - if (isNullOrUndef$3(nextClassName)) { - dom.removeAttribute('class'); - } else if (isSVG) { - dom.setAttribute('class', nextClassName); - } else { - dom.className = nextClassName; - } - } - - if (nextFlags & 4096 - /* ContentEditable */ - ) { - patchContentEditableChildren(dom, nextChildren); - } else { - patchChildren(lastVNode.childFlags, nextVNode.childFlags, lastVNode.children, nextChildren, dom, context, isSVG && nextVNode.type !== 'foreignObject', null, lastVNode, lifecycle, animations); - } - - if (isFormElement) { - processElement(nextFlags, nextVNode, dom, nextPropsOrEmpty, false, hasControlledValue); - } - - var nextRef = nextVNode.ref; - var lastRef = lastVNode.ref; - - if (lastRef !== nextRef) { - unmountRef(lastRef); - mountRef(nextRef, dom, lifecycle); - } - } - - function replaceOneVNodeWithMultipleVNodes(lastChildren, nextChildren, parentDOM, context, isSVG, lifecycle, animations) { - unmount(lastChildren, animations); - mountArrayChildren(nextChildren, parentDOM, context, isSVG, findDOMfromVNode(lastChildren, true), lifecycle, animations); - removeVNodeDOM(lastChildren, parentDOM, animations); - } - - function patchChildren(lastChildFlags, nextChildFlags, lastChildren, nextChildren, parentDOM, context, isSVG, nextNode, parentVNode, lifecycle, animations) { - switch (lastChildFlags) { - case 2 - /* HasVNodeChildren */ - : - switch (nextChildFlags) { - case 2 - /* HasVNodeChildren */ - : - patch(lastChildren, nextChildren, parentDOM, context, isSVG, nextNode, lifecycle, animations); - break; - - case 1 - /* HasInvalidChildren */ - : - remove(lastChildren, parentDOM, animations); - break; - - case 16 - /* HasTextChildren */ - : - unmount(lastChildren, animations); - setTextContent(parentDOM, nextChildren); - break; - - default: - replaceOneVNodeWithMultipleVNodes(lastChildren, nextChildren, parentDOM, context, isSVG, lifecycle, animations); - break; - } - - break; - - case 1 - /* HasInvalidChildren */ - : - switch (nextChildFlags) { - case 2 - /* HasVNodeChildren */ - : - mount(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle, animations); - break; - - case 1 - /* HasInvalidChildren */ - : - break; - - case 16 - /* HasTextChildren */ - : - setTextContent(parentDOM, nextChildren); - break; - - default: - mountArrayChildren(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle, animations); - break; - } - - break; - - case 16 - /* HasTextChildren */ - : - switch (nextChildFlags) { - case 16 - /* HasTextChildren */ - : - patchSingleTextChild(lastChildren, nextChildren, parentDOM); - break; - - case 2 - /* HasVNodeChildren */ - : - clearDOM(parentDOM, lastChildren, animations); - mount(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle, animations); - break; - - case 1 - /* HasInvalidChildren */ - : - clearDOM(parentDOM, lastChildren, animations); - break; - - default: - clearDOM(parentDOM, lastChildren, animations); - mountArrayChildren(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle, animations); - break; - } - - break; - - default: - switch (nextChildFlags) { - case 16 - /* HasTextChildren */ - : - unmountAllChildren(lastChildren, animations); - setTextContent(parentDOM, nextChildren); - break; - - case 2 - /* HasVNodeChildren */ - : - removeAllChildren(parentDOM, parentVNode, lastChildren, animations); - mount(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle, animations); - break; - - case 1 - /* HasInvalidChildren */ - : - removeAllChildren(parentDOM, parentVNode, lastChildren, animations); - break; - - default: - var lastLength = lastChildren.length | 0; - var nextLength = nextChildren.length | 0; // Fast path's for both algorithms - - if (lastLength === 0) { - if (nextLength > 0) { - mountArrayChildren(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle, animations); - } - } else if (nextLength === 0) { - removeAllChildren(parentDOM, parentVNode, lastChildren, animations); - } else if (nextChildFlags === 8 - /* HasKeyedChildren */ - && lastChildFlags === 8 - /* HasKeyedChildren */ - ) { - patchKeyedChildren(lastChildren, nextChildren, parentDOM, context, isSVG, lastLength, nextLength, nextNode, parentVNode, lifecycle, animations); - } else { - patchNonKeyedChildren(lastChildren, nextChildren, parentDOM, context, isSVG, lastLength, nextLength, nextNode, lifecycle, animations); - } - - break; - } - - break; - } - } - - function createDidUpdate(instance, lastProps, lastState, snapshot, lifecycle) { - lifecycle.push(function () { - instance.componentDidUpdate(lastProps, lastState, snapshot); - }); - } - - function updateClassComponent(instance, nextState, nextProps, parentDOM, context, isSVG, force, nextNode, lifecycle, animations) { - var lastState = instance.state; - var lastProps = instance.props; - var usesNewAPI = Boolean(instance.$N); - var hasSCU = isFunction$3(instance.shouldComponentUpdate); - - if (usesNewAPI) { - nextState = createDerivedState(instance, nextProps, nextState !== lastState ? combineFrom$1(lastState, nextState) : nextState); - } - - if (force || !hasSCU || hasSCU && instance.shouldComponentUpdate(nextProps, nextState, context)) { - if (!usesNewAPI && isFunction$3(instance.componentWillUpdate)) { - instance.componentWillUpdate(nextProps, nextState, context); - } - - instance.props = nextProps; - instance.state = nextState; - instance.context = context; - var snapshot = null; - var nextInput = renderNewInput(instance, nextProps, context); - - if (usesNewAPI && isFunction$3(instance.getSnapshotBeforeUpdate)) { - snapshot = instance.getSnapshotBeforeUpdate(lastProps, lastState); - } - - patch(instance.$LI, nextInput, parentDOM, instance.$CX, isSVG, nextNode, lifecycle, animations); // Dont update Last input, until patch has been succesfully executed - - instance.$LI = nextInput; - - if (isFunction$3(instance.componentDidUpdate)) { - createDidUpdate(instance, lastProps, lastState, snapshot, lifecycle); - } - } else { - instance.props = nextProps; - instance.state = nextState; - instance.context = context; - } - } - - function patchClassComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle, animations) { - var instance = nextVNode.children = lastVNode.children; // If Component has crashed, ignore it to stay functional - - if (isNull$2(instance)) { - return; - } - - instance.$L = lifecycle; - var nextProps = nextVNode.props || EMPTY_OBJ; - var nextRef = nextVNode.ref; - var lastRef = lastVNode.ref; - var nextState = instance.state; - - if (!instance.$N) { - if (isFunction$3(instance.componentWillReceiveProps)) { - instance.$BR = true; - instance.componentWillReceiveProps(nextProps, context); // If instance component was removed during its own update do nothing. - - if (instance.$UN) { - return; - } - - instance.$BR = false; - } - - if (!isNull$2(instance.$PS)) { - nextState = combineFrom$1(nextState, instance.$PS); - instance.$PS = null; - } - } - - updateClassComponent(instance, nextState, nextProps, parentDOM, context, isSVG, false, nextNode, lifecycle, animations); - - if (lastRef !== nextRef) { - unmountRef(lastRef); - mountRef(nextRef, instance, lifecycle); - } - } - - function patchFunctionalComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle, animations) { - var shouldUpdate = true; - var nextProps = nextVNode.props || EMPTY_OBJ; - var nextRef = nextVNode.ref; - var lastProps = lastVNode.props; - var nextHooksDefined = !isNullOrUndef$3(nextRef); - var lastInput = lastVNode.children; - - if (nextHooksDefined && isFunction$3(nextRef.onComponentShouldUpdate)) { - shouldUpdate = nextRef.onComponentShouldUpdate(lastProps, nextProps); - } - - if (shouldUpdate !== false) { - if (nextHooksDefined && isFunction$3(nextRef.onComponentWillUpdate)) { - nextRef.onComponentWillUpdate(lastProps, nextProps); - } - - var nextInput = normalizeRoot(renderFunctionalComponent(nextVNode, context)); - patch(lastInput, nextInput, parentDOM, context, isSVG, nextNode, lifecycle, animations); - nextVNode.children = nextInput; - - if (nextHooksDefined && isFunction$3(nextRef.onComponentDidUpdate)) { - nextRef.onComponentDidUpdate(lastProps, nextProps); - } - } else { - nextVNode.children = lastInput; - } - } - - function patchText(lastVNode, nextVNode) { - var nextText = nextVNode.children; - var dom = nextVNode.dom = lastVNode.dom; - - if (nextText !== lastVNode.children) { - dom.nodeValue = nextText; - } - } - - function patchNonKeyedChildren(lastChildren, nextChildren, dom, context, isSVG, lastChildrenLength, nextChildrenLength, nextNode, lifecycle, animations) { - var commonLength = lastChildrenLength > nextChildrenLength ? nextChildrenLength : lastChildrenLength; - var i = 0; - var nextChild; - var lastChild; - - for (; i < commonLength; ++i) { - nextChild = nextChildren[i]; - lastChild = lastChildren[i]; - - if (nextChild.flags & 16384 - /* InUse */ - ) { - nextChild = nextChildren[i] = directClone(nextChild); - } - - patch(lastChild, nextChild, dom, context, isSVG, nextNode, lifecycle, animations); - lastChildren[i] = nextChild; - } - - if (lastChildrenLength < nextChildrenLength) { - for (i = commonLength; i < nextChildrenLength; ++i) { - nextChild = nextChildren[i]; - - if (nextChild.flags & 16384 - /* InUse */ - ) { - nextChild = nextChildren[i] = directClone(nextChild); - } - - mount(nextChild, dom, context, isSVG, nextNode, lifecycle, animations); - } - } else if (lastChildrenLength > nextChildrenLength) { - for (i = commonLength; i < lastChildrenLength; ++i) { - remove(lastChildren[i], dom, animations); - } - } - } - - function patchKeyedChildren(a, b, dom, context, isSVG, aLength, bLength, outerEdge, parentVNode, lifecycle, animations) { - var aEnd = aLength - 1; - var bEnd = bLength - 1; - var j = 0; - var aNode = a[j]; - var bNode = b[j]; - var nextPos; - var nextNode; // Step 1 - // tslint:disable-next-line - - outer: { - // Sync nodes with the same key at the beginning. - while (aNode.key === bNode.key) { - if (bNode.flags & 16384 - /* InUse */ - ) { - b[j] = bNode = directClone(bNode); - } - - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle, animations); - a[j] = bNode; - ++j; - - if (j > aEnd || j > bEnd) { - break outer; - } - - aNode = a[j]; - bNode = b[j]; - } - - aNode = a[aEnd]; - bNode = b[bEnd]; // Sync nodes with the same key at the end. - - while (aNode.key === bNode.key) { - if (bNode.flags & 16384 - /* InUse */ - ) { - b[bEnd] = bNode = directClone(bNode); - } - - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle, animations); - a[aEnd] = bNode; - aEnd--; - bEnd--; - - if (j > aEnd || j > bEnd) { - break outer; - } - - aNode = a[aEnd]; - bNode = b[bEnd]; - } - } - - if (j > aEnd) { - if (j <= bEnd) { - nextPos = bEnd + 1; - nextNode = nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge; - - while (j <= bEnd) { - bNode = b[j]; - - if (bNode.flags & 16384 - /* InUse */ - ) { - b[j] = bNode = directClone(bNode); - } - - ++j; - mount(bNode, dom, context, isSVG, nextNode, lifecycle, animations); - } - } - } else if (j > bEnd) { - while (j <= aEnd) { - remove(a[j++], dom, animations); - } - } else { - patchKeyedChildrenComplex(a, b, context, aLength, bLength, aEnd, bEnd, j, dom, isSVG, outerEdge, parentVNode, lifecycle, animations); - } - } - - function patchKeyedChildrenComplex(a, b, context, aLength, bLength, aEnd, bEnd, j, dom, isSVG, outerEdge, parentVNode, lifecycle, animations) { - var aNode; - var bNode; - var nextPos = 0; - var i = 0; - var aStart = j; - var bStart = j; - var aLeft = aEnd - j + 1; - var bLeft = bEnd - j + 1; - var sources = new Int32Array(bLeft + 1); // Keep track if its possible to remove whole DOM using textContent = ''; - - var canRemoveWholeContent = aLeft === aLength; - var moved = false; - var pos = 0; - var patched = 0; // When sizes are small, just loop them through - - if (bLength < 4 || (aLeft | bLeft) < 32) { - for (i = aStart; i <= aEnd; ++i) { - aNode = a[i]; - - if (patched < bLeft) { - for (j = bStart; j <= bEnd; j++) { - bNode = b[j]; - - if (aNode.key === bNode.key) { - sources[j - bStart] = i + 1; - - if (canRemoveWholeContent) { - canRemoveWholeContent = false; - - while (aStart < i) { - remove(a[aStart++], dom, animations); - } - } - - if (pos > j) { - moved = true; - } else { - pos = j; - } - - if (bNode.flags & 16384 - /* InUse */ - ) { - b[j] = bNode = directClone(bNode); - } - - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle, animations); - ++patched; - break; - } - } - - if (!canRemoveWholeContent && j > bEnd) { - remove(aNode, dom, animations); - } - } else if (!canRemoveWholeContent) { - remove(aNode, dom, animations); - } - } - } else { - var keyIndex = {}; // Map keys by their index - - for (i = bStart; i <= bEnd; ++i) { - keyIndex[b[i].key] = i; - } // Try to patch same keys - - - for (i = aStart; i <= aEnd; ++i) { - aNode = a[i]; - - if (patched < bLeft) { - j = keyIndex[aNode.key]; - - if (j !== void 0) { - if (canRemoveWholeContent) { - canRemoveWholeContent = false; - - while (i > aStart) { - remove(a[aStart++], dom, animations); - } - } - - sources[j - bStart] = i + 1; - - if (pos > j) { - moved = true; - } else { - pos = j; - } - - bNode = b[j]; - - if (bNode.flags & 16384 - /* InUse */ - ) { - b[j] = bNode = directClone(bNode); - } - - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle, animations); - ++patched; - } else if (!canRemoveWholeContent) { - remove(aNode, dom, animations); - } - } else if (!canRemoveWholeContent) { - remove(aNode, dom, animations); - } - } - } // fast-path: if nothing patched remove all old and add all new - - - if (canRemoveWholeContent) { - removeAllChildren(dom, parentVNode, a, animations); - mountArrayChildren(b, dom, context, isSVG, outerEdge, lifecycle, animations); - } else if (moved) { - var seq = lis_algorithm(sources); - j = seq.length - 1; - - for (i = bLeft - 1; i >= 0; i--) { - if (sources[i] === 0) { - pos = i + bStart; - bNode = b[pos]; - - if (bNode.flags & 16384 - /* InUse */ - ) { - b[pos] = bNode = directClone(bNode); - } - - nextPos = pos + 1; - mount(bNode, dom, context, isSVG, nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge, lifecycle, animations); - } else if (j < 0 || i !== seq[j]) { - pos = i + bStart; - bNode = b[pos]; - nextPos = pos + 1; // --- the DOM-node is moved by a call to insertAppend - - moveVNodeDOM(parentVNode, bNode, dom, nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge, animations); - } else { - j--; - } - } - } else if (patched !== bLeft) { - // when patched count doesn't match b length we need to insert those new ones - // loop backwards so we can use insertBefore - for (i = bLeft - 1; i >= 0; i--) { - if (sources[i] === 0) { - pos = i + bStart; - bNode = b[pos]; - - if (bNode.flags & 16384 - /* InUse */ - ) { - b[pos] = bNode = directClone(bNode); - } - - nextPos = pos + 1; - mount(bNode, dom, context, isSVG, nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge, lifecycle, animations); - } - } - } - } - - var result; - var p; - var maxLen = 0; // https://en.wikipedia.org/wiki/Longest_increasing_subsequence - - function lis_algorithm(arr) { - var arrI = 0; - var i = 0; - var j = 0; - var k = 0; - var u = 0; - var v = 0; - var c = 0; - var len = arr.length; - - if (len > maxLen) { - maxLen = len; - result = new Int32Array(len); - p = new Int32Array(len); - } - - for (; i < len; ++i) { - arrI = arr[i]; - - if (arrI !== 0) { - j = result[k]; - - if (arr[j] < arrI) { - p[i] = j; - result[++k] = i; - continue; - } - - u = 0; - v = k; - - while (u < v) { - c = u + v >> 1; - - if (arr[result[c]] < arrI) { - u = c + 1; - } else { - v = c; - } - } - - if (arrI < arr[result[u]]) { - if (u > 0) { - p[i] = result[u - 1]; - } - - result[u] = i; - } - } - } - - u = k + 1; - var seq = new Int32Array(u); - v = result[u - 1]; - - while (u-- > 0) { - seq[u] = v; - v = p[v]; - result[u] = 0; - } - - return seq; - } - - var hasDocumentAvailable = typeof document !== 'undefined'; - - if (hasDocumentAvailable) { - /* - * Defining $EV and $V properties on Node.prototype - * fixes v8 "wrong map" de-optimization - */ - if (window.Node) { - Node.prototype.$EV = null; - Node.prototype.$V = null; - } - } - - function __render(input, parentDOM, callback, context) { - var lifecycle = []; - var animations = new AnimationQueues(); - var rootInput = parentDOM.$V; - renderCheck.v = true; - - if (isNullOrUndef$3(rootInput)) { - if (!isNullOrUndef$3(input)) { - if (input.flags & 16384 - /* InUse */ - ) { - input = directClone(input); - } - - mount(input, parentDOM, context, false, null, lifecycle, animations); - parentDOM.$V = input; - rootInput = input; - } - } else { - if (isNullOrUndef$3(input)) { - remove(rootInput, parentDOM, animations); - parentDOM.$V = null; - } else { - if (input.flags & 16384 - /* InUse */ - ) { - input = directClone(input); - } - - patch(rootInput, input, parentDOM, context, false, null, lifecycle, animations); - rootInput = parentDOM.$V = input; - } - } - - callAll(lifecycle); - callAllAnimationHooks(animations.componentDidAppear); - renderCheck.v = false; - - if (isFunction$3(callback)) { - callback(); - } - - if (isFunction$3(options.renderComplete)) { - options.renderComplete(rootInput, parentDOM); - } - } - - function render$1(input, parentDOM, callback, context) { - if (callback === void 0) callback = null; - if (context === void 0) context = EMPTY_OBJ; - - __render(input, parentDOM, callback, context); - } - - function createRenderer(parentDOM) { - return function renderer(lastInput, nextInput, callback, context) { - if (!parentDOM) { - parentDOM = lastInput; - } - - render$1(nextInput, parentDOM, callback, context); - }; - } - - var QUEUE = []; - var nextTick = typeof Promise !== 'undefined' ? Promise.resolve().then.bind(Promise.resolve()) : function (a) { - window.setTimeout(a, 0); - }; - var microTaskPending = false; - - function queueStateChanges(component, newState, callback, force) { - var pending = component.$PS; - - if (isFunction$3(newState)) { - newState = newState(pending ? combineFrom$1(component.state, pending) : component.state, component.props, component.context); - } - - if (isNullOrUndef$3(pending)) { - component.$PS = newState; - } else { - for (var stateKey in newState) { - pending[stateKey] = newState[stateKey]; - } - } - - if (!component.$BR) { - if (!renderCheck.v) { - if (QUEUE.length === 0) { - applyState(component, force); - - if (isFunction$3(callback)) { - callback.call(component); - } - - return; - } - } - - if (QUEUE.indexOf(component) === -1) { - QUEUE.push(component); - } - - if (force) { - component.$F = true; - } - - if (!microTaskPending) { - microTaskPending = true; - nextTick(rerender); - } - - if (isFunction$3(callback)) { - var QU = component.$QU; - - if (!QU) { - QU = component.$QU = []; - } - - QU.push(callback); - } - } else if (isFunction$3(callback)) { - component.$L.push(callback.bind(component)); - } - } - - function callSetStateCallbacks(component) { - var queue = component.$QU; - - for (var i = 0; i < queue.length; ++i) { - queue[i].call(component); - } - - component.$QU = null; - } - - function rerender() { - var component; - microTaskPending = false; - - while (component = QUEUE.shift()) { - if (!component.$UN) { - var force = component.$F; - component.$F = false; - applyState(component, force); - - if (component.$QU) { - callSetStateCallbacks(component); - } - } - } - } - - function applyState(component, force) { - if (force || !component.$BR) { - var pendingState = component.$PS; - component.$PS = null; - var lifecycle = []; - var animations = new AnimationQueues(); - renderCheck.v = true; - updateClassComponent(component, combineFrom$1(component.state, pendingState), component.props, findDOMfromVNode(component.$LI, true).parentNode, component.context, component.$SVG, force, null, lifecycle, animations); - callAll(lifecycle); - callAllAnimationHooks(animations.componentDidAppear); - renderCheck.v = false; - } else { - component.state = component.$PS; - component.$PS = null; - } - } - - var Component = function Component(props, context) { - // Public - this.state = null; // Internal properties - - this.$BR = false; // BLOCK RENDER - - this.$BS = true; // BLOCK STATE - - this.$PS = null; // PENDING STATE (PARTIAL or FULL) - - this.$LI = null; // LAST INPUT - - this.$UN = false; // UNMOUNTED - - this.$CX = null; // CHILDCONTEXT - - this.$QU = null; // QUEUE - - this.$N = false; // Uses new lifecycle API Flag - - this.$L = null; // Current lifecycle of this component - - this.$SVG = false; // Flag to keep track if component is inside SVG tree - - this.$F = false; // Force update flag - - this.$MV = false; // Coordinating a move animation (set on parent node) - - this.props = props || EMPTY_OBJ; - this.context = context || EMPTY_OBJ; // context should not be mutable - }; - - Component.prototype.forceUpdate = function forceUpdate(callback) { - if (this.$UN) { - return; - } // Do not allow double render during force update - - - queueStateChanges(this, {}, callback, true); - }; - - Component.prototype.setState = function setState(newState, callback) { - if (this.$UN) { - return; - } - - if (!this.$BS) { - queueStateChanges(this, newState, callback, false); - } - }; - - Component.prototype.render = function render(_nextProps, _nextState, _nextContext) { - return null; - }; - - var ERROR_MSG$1 = 'a runtime error occured! Use Inferno in development environment to find the error.'; - - function isNullOrUndef$2(o) { - return o === void 0 || o === null; - } - - function isInvalid$1(o) { - return o === null || o === false || o === true || o === void 0; - } - - function isFunction$2(o) { - return typeof o === 'function'; - } - - function isNull$1(o) { - return o === null; - } - - function throwError$1(message) { - if (!message) { - message = ERROR_MSG$1; - } - - throw new Error("Inferno Error: " + message); - } - - function isSameInnerHTML(dom, innerHTML) { - var tempdom = document.createElement('i'); - tempdom.innerHTML = innerHTML; - return tempdom.innerHTML === dom.innerHTML; - } - - function findLastDOMFromVNode(vNode) { - var flags; - var children; - - while (vNode) { - flags = vNode.flags; - - if (flags & 2033 - /* DOMRef */ - ) { - return vNode.dom; - } - - children = vNode.children; - - if (flags & 8192 - /* Fragment */ - ) { - vNode = vNode.childFlags === 2 - /* HasVNodeChildren */ - ? children : children[children.length - 1]; - } else if (flags & 4 - /* ComponentClass */ - ) { - vNode = children.$LI; - } else { - vNode = children; - } - } - - return null; - } - - function isSamePropsInnerHTML(dom, props) { - return Boolean(props && props.dangerouslySetInnerHTML && props.dangerouslySetInnerHTML.__html && isSameInnerHTML(dom, props.dangerouslySetInnerHTML.__html)); - } - - function hydrateComponent(vNode, parentDOM, dom, context, isSVG, isClass, lifecycle, animations) { - var type = vNode.type; - var ref = vNode.ref; - var props = vNode.props || EMPTY_OBJ; - var currentNode; - - if (isClass) { - var instance = createClassComponentInstance(vNode, type, props, context, isSVG, lifecycle); - - var input = instance.$LI; - currentNode = hydrateVNode(input, parentDOM, dom, instance.$CX, isSVG, lifecycle, animations); - - mountClassComponentCallbacks(ref, instance, lifecycle, animations); - } else { - var input$1 = normalizeRoot(renderFunctionalComponent(vNode, context)); - - currentNode = hydrateVNode(input$1, parentDOM, dom, context, isSVG, lifecycle, animations); - vNode.children = input$1; - - mountFunctionalComponentCallbacks(vNode, lifecycle, animations); - } - - return currentNode; - } - - function hydrateChildren(parentVNode, parentNode, currentNode, context, isSVG, lifecycle, animations) { - var childFlags = parentVNode.childFlags; - var children = parentVNode.children; - var props = parentVNode.props; - var flags = parentVNode.flags; - - if (childFlags !== 1 - /* HasInvalidChildren */ - ) { - if (childFlags === 2 - /* HasVNodeChildren */ - ) { - if (isNull$1(currentNode)) { - mount(children, parentNode, context, isSVG, null, lifecycle, animations); - } else { - currentNode = hydrateVNode(children, parentNode, currentNode, context, isSVG, lifecycle, animations); - currentNode = currentNode ? currentNode.nextSibling : null; - } - } else if (childFlags === 16 - /* HasTextChildren */ - ) { - if (isNull$1(currentNode)) { - parentNode.appendChild(document.createTextNode(children)); - } else if (parentNode.childNodes.length !== 1 || currentNode.nodeType !== 3) { - parentNode.textContent = children; - } else { - if (currentNode.nodeValue !== children) { - currentNode.nodeValue = children; - } - } - - currentNode = null; - } else if (childFlags & 12 - /* MultipleChildren */ - ) { - var prevVNodeIsTextNode = false; - - for (var i = 0, len = children.length; i < len; ++i) { - var child = children[i]; - - if (isNull$1(currentNode) || prevVNodeIsTextNode && (child.flags & 16 - /* Text */ - ) > 0) { - mount(child, parentNode, context, isSVG, currentNode, lifecycle, animations); - } else { - currentNode = hydrateVNode(child, parentNode, currentNode, context, isSVG, lifecycle, animations); - currentNode = currentNode ? currentNode.nextSibling : null; - } - - prevVNodeIsTextNode = (child.flags & 16 - /* Text */ - ) > 0; - } - } // clear any other DOM nodes, there should be only a single entry for the root - - - if ((flags & 8192 - /* Fragment */ - ) === 0) { - var nextSibling = null; - - while (currentNode) { - nextSibling = currentNode.nextSibling; - parentNode.removeChild(currentNode); - currentNode = nextSibling; - } - } - } else if (!isNull$1(parentNode.firstChild) && !isSamePropsInnerHTML(parentNode, props)) { - parentNode.textContent = ''; // dom has content, but VNode has no children remove everything from DOM - - if (flags & 448 - /* FormElement */ - ) { - // If element is form element, we need to clear defaultValue also - parentNode.defaultValue = ''; - } - } - } - - function hydrateElement(vNode, parentDOM, dom, context, isSVG, lifecycle, animations) { - var props = vNode.props; - var className = vNode.className; - var flags = vNode.flags; - var ref = vNode.ref; - isSVG = isSVG || (flags & 32 - /* SvgElement */ - ) > 0; - - if (dom.nodeType !== 1 || dom.tagName.toLowerCase() !== vNode.type) { - mountElement(vNode, null, context, isSVG, null, lifecycle, animations); - - parentDOM.replaceChild(vNode.dom, dom); - } else { - vNode.dom = dom; - hydrateChildren(vNode, dom, dom.firstChild, context, isSVG, lifecycle, animations); - - if (!isNull$1(props)) { - mountProps(vNode, flags, props, dom, isSVG, animations); - } - - if (isNullOrUndef$2(className)) { - if (dom.className !== '') { - dom.removeAttribute('class'); - } - } else if (isSVG) { - dom.setAttribute('class', className); - } else { - dom.className = className; - } - - mountRef(ref, dom, lifecycle); - } - - return vNode.dom; - } - - function hydrateText(vNode, parentDOM, dom) { - if (dom.nodeType !== 3) { - parentDOM.replaceChild(vNode.dom = document.createTextNode(vNode.children), dom); - } else { - var text = vNode.children; - - if (dom.nodeValue !== text) { - dom.nodeValue = text; - } - - vNode.dom = dom; - } - - return vNode.dom; - } - - function hydrateFragment(vNode, parentDOM, dom, context, isSVG, lifecycle, animations) { - var children = vNode.children; - - if (vNode.childFlags === 2 - /* HasVNodeChildren */ - ) { - hydrateText(children, parentDOM, dom); - return children.dom; - } - - hydrateChildren(vNode, parentDOM, dom, context, isSVG, lifecycle, animations); - return findLastDOMFromVNode(children[children.length - 1]); - } - - function hydrateVNode(vNode, parentDOM, currentDom, context, isSVG, lifecycle, animations) { - var flags = vNode.flags |= 16384 - /* InUse */ - ; - - if (flags & 14 - /* Component */ - ) { - return hydrateComponent(vNode, parentDOM, currentDom, context, isSVG, (flags & 4 - /* ComponentClass */ - ) > 0, lifecycle, animations); - } - - if (flags & 481 - /* Element */ - ) { - return hydrateElement(vNode, parentDOM, currentDom, context, isSVG, lifecycle, animations); - } - - if (flags & 16 - /* Text */ - ) { - return hydrateText(vNode, parentDOM, currentDom); - } - - if (flags & 512 - /* Void */ - ) { - return vNode.dom = currentDom; - } - - if (flags & 8192 - /* Fragment */ - ) { - return hydrateFragment(vNode, parentDOM, currentDom, context, isSVG, lifecycle, animations); - } - - throwError$1(); - return null; - } - - function hydrate(input, parentDOM, callback) { - var dom = parentDOM.firstChild; - - if (isNull$1(dom)) { - render$1(input, parentDOM, callback); - } else { - var lifecycle = []; - var animations = new AnimationQueues(); - - if (!isInvalid$1(input)) { - dom = hydrateVNode(input, parentDOM, dom, {}, false, lifecycle, animations); - } // clear any other DOM nodes, there should be only a single entry for the root - - - while (dom && (dom = dom.nextSibling)) { - parentDOM.removeChild(dom); - } - - if (lifecycle.length > 0) { - var listener; - - while ((listener = lifecycle.shift()) !== undefined) { - listener(); - } - } - } - - parentDOM.$V = input; - - if (isFunction$2(callback)) { - callback(); - } - } - - function combineFrom(first, second) { - var out = {}; - - if (first) { - for (var key in first) { - out[key] = first[key]; - } - } - - if (second) { - for (var key$1 in second) { - out[key$1] = second[key$1]; - } - } - - return out; - } - /* - directClone is preferred over cloneVNode and used internally also. - This function makes Inferno backwards compatible. - And can be tree-shaked by modern bundlers - - Would be nice to combine this with directClone but could not do it without breaking change - */ - - /** - * Clones given virtual node by creating new instance of it - * @param {VNode} vNodeToClone virtual node to be cloned - * @param {Props=} props additional props for new virtual node - * @param {...*} _children new children for new virtual node - * @returns {VNode} new virtual node - */ - - - function cloneVNode(vNodeToClone, props, _children) { - var arguments$1 = arguments; - var flags = vNodeToClone.flags; - var children = flags & 14 - /* Component */ - ? vNodeToClone.props && vNodeToClone.props.children : vNodeToClone.children; - var childLen = arguments.length - 2; - var className = vNodeToClone.className; - var key = vNodeToClone.key; - var ref = vNodeToClone.ref; - - if (props) { - if (props.className !== void 0) { - className = props.className; - } - - if (props.ref !== void 0) { - ref = props.ref; - } - - if (props.key !== void 0) { - key = props.key; - } - - if (props.children !== void 0) { - children = props.children; - } - } else { - props = {}; - } - - if (childLen === 1) { - children = _children; - } else if (childLen > 1) { - children = []; - - while (childLen-- > 0) { - children[childLen] = arguments$1[childLen + 2]; - } - } - - props.children = children; - - if (flags & 14 - /* Component */ - ) { - return createComponentVNode(flags, vNodeToClone.type, !vNodeToClone.props && !props ? EMPTY_OBJ : combineFrom(vNodeToClone.props, props), key, ref); - } - - if (flags & 16 - /* Text */ - ) { - return createTextVNode(children); - } - - if (flags & 8192 - /* Fragment */ - ) { - return createFragment(childLen === 1 ? [children] : children, 0 - /* UnknownChildren */ - , key); - } - - return normalizeProps(createVNode(flags, vNodeToClone.type, className, null, 1 - /* HasInvalidChildren */ - , combineFrom(vNodeToClone.props, props), key, ref)); - } - - var ERROR_MSG = 'a runtime error occured! Use Inferno in development environment to find the error.'; - - function isFunction$1(o) { - return typeof o === 'function'; - } - - function throwError(message) { - if (!message) { - message = ERROR_MSG; - } - - throw new Error("Inferno Error: " + message); - } // don't autobind these methods since they already have guaranteed context. - - - var AUTOBIND_BLACKLIST = { - componentDidMount: 1, - componentDidUnmount: 1, - componentDidUpdate: 1, - componentWillMount: 1, - componentWillUnmount: 1, - componentWillUpdate: 1, - constructor: 1, - render: 1, - shouldComponentUpdate: 1 - }; - - function extend(base, props) { - for (var key in props) { - base[key] = props[key]; - } - - return base; - } - - function bindAll(ctx) { - for (var i in ctx) { - var v = ctx[i]; - - if (typeof v === 'function' && !v.__bound && !AUTOBIND_BLACKLIST[i]) { - (ctx[i] = v.bind(ctx)).__bound = true; - } - } - } - - function collateMixins(mixins, keyed) { - if (keyed === void 0) keyed = {}; - - for (var i = 0, len = mixins.length; i < len; ++i) { - var mixin = mixins[i]; // Surprise: Mixins can have mixins - - if (mixin.mixins) { - // Recursively collate sub-mixins - collateMixins(mixin.mixins, keyed); - } - - for (var key in mixin) { - if (mixin.hasOwnProperty(key) && typeof mixin[key] === 'function') { - (keyed[key] || (keyed[key] = [])).push(mixin[key]); - } - } - } - - return keyed; - } - - function multihook(hooks, mergeFn) { - return function () { - var arguments$1 = arguments; - var ret; - - for (var i = 0, len = hooks.length; i < len; ++i) { - var hook = hooks[i]; - var r = hook.apply(this, arguments$1); - - if (mergeFn) { - ret = mergeFn(ret, r); - } else if (r) { - ret = r; - } - } - - return ret; - }; - } - - function mergeNoDupes(previous, current) { - if (current) { - if (typeof current !== 'object') { - throwError('Expected Mixin to return value to be an object or null.'); - } - - if (!previous) { - previous = {}; - } - - for (var key in current) { - if (current.hasOwnProperty(key)) { - if (previous.hasOwnProperty(key)) { - throwError("Mixins return duplicate key " + key + " in their return values"); - } - - previous[key] = current[key]; - } - } - } - - return previous; - } - - function applyMixin(key, inst, mixin) { - var hooks = inst[key] !== void 0 ? mixin.concat(inst[key]) : mixin; - - if (key === 'getDefaultProps' || key === 'getInitialState' || key === 'getChildContext') { - inst[key] = multihook(hooks, mergeNoDupes); - } else { - inst[key] = multihook(hooks); - } - } - - function applyMixins(Cl, mixins) { - for (var key in mixins) { - if (mixins.hasOwnProperty(key)) { - var mixin = mixins[key]; - var inst = void 0; - - if (key === 'getDefaultProps') { - inst = Cl; - } else { - inst = Cl.prototype; - } - - if (isFunction$1(mixin[0])) { - applyMixin(key, inst, mixin); - } else { - inst[key] = mixin; - } - } - } - } - - function createClass(obj) { - var Cl = /*@__PURE__*/function (Component) { - function Cl(props, context) { - Component.call(this, props, context); - bindAll(this); - - if (this.getInitialState) { - this.state = this.getInitialState(); - } - } - - if (Component) Cl.__proto__ = Component; - Cl.prototype = Object.create(Component && Component.prototype); - Cl.prototype.constructor = Cl; - - Cl.prototype.replaceState = function replaceState(nextState, callback) { - this.setState(nextState, callback); - }; - - Cl.prototype.isMounted = function isMounted() { - return this.$LI !== null && !this.$UN; - }; - - return Cl; - }(Component); - - Cl.displayName = obj.name || obj.displayName || 'Component'; - Cl.propTypes = obj.propTypes; - Cl.mixins = obj.mixins && collateMixins(obj.mixins); - Cl.getDefaultProps = obj.getDefaultProps; - extend(Cl.prototype, obj); - - if (obj.statics) { - extend(Cl, obj.statics); - } - - if (obj.mixins) { - applyMixins(Cl, collateMixins(obj.mixins)); - } - - if (Cl.getDefaultProps) { - Cl.defaultProps = Cl.getDefaultProps(); - } - - return Cl; - } - - function isNullOrUndef$1(o) { - return o === void 0 || o === null; - } - - function isString$1(o) { - return typeof o === 'string'; - } - - function isUndefined(o) { - return o === void 0; - } - - var componentHooks = { - onComponentDidAppear: 1, - onComponentDidMount: 1, - onComponentDidUpdate: 1, - onComponentShouldUpdate: 1, - onComponentWillDisappear: 1, - onComponentWillMount: 1, - onComponentWillUnmount: 1, - onComponentWillUpdate: 1 - }; - - function createElement(type, props, _children) { - var arguments$1 = arguments; - var children; - var ref = null; - var key = null; - var className = null; - var flags = 0; - var newProps; - var childLen = arguments.length - 2; - - if (childLen === 1) { - children = _children; - } else if (childLen > 1) { - children = []; - - while (childLen-- > 0) { - children[childLen] = arguments$1[childLen + 2]; - } - } - - if (isString$1(type)) { - flags = getFlagsForElementVnode(type); - - if (!isNullOrUndef$1(props)) { - newProps = {}; - - for (var prop in props) { - if (prop === 'className' || prop === 'class') { - className = props[prop]; - } else if (prop === 'key') { - key = props.key; - } else if (prop === 'children' && isUndefined(children)) { - children = props.children; // always favour children args over props - } else if (prop === 'ref') { - ref = props.ref; - } else { - if (prop === 'contenteditable') { - flags |= 4096 - /* ContentEditable */ - ; - } - - newProps[prop] = props[prop]; - } - } - } - } else { - flags = 2 - /* ComponentUnknown */ - ; - - if (!isUndefined(children)) { - if (!props) { - props = {}; - } - - props.children = children; - } - - if (!isNullOrUndef$1(props)) { - newProps = {}; - - for (var prop$1 in props) { - if (prop$1 === 'key') { - key = props.key; - } else if (prop$1 === 'ref') { - ref = props.ref; - } else if (componentHooks[prop$1] === 1) { - if (!ref) { - ref = {}; - } - - ref[prop$1] = props[prop$1]; - } else { - newProps[prop$1] = props[prop$1]; - } - } - } - - return createComponentVNode(flags, type, newProps, key, ref); - } - - if (flags & 8192 - /* Fragment */ - ) { - return createFragment(childLen === 1 ? [children] : children, 0 - /* UnknownChildren */ - , key); - } - - return createVNode(flags, type, className, children, 0 - /* UnknownChildren */ - , newProps, key, ref); - } - - function findDOMNode(ref) { - if (ref && ref.nodeType) { - return ref; - } - - if (!ref || ref.$UN) { - return null; - } - - if (ref.$LI) { - return findDOMfromVNode(ref.$LI, true); - } - - if (ref.flags) { - return findDOMfromVNode(ref, true); - } - - return null; - } - - var isArray = Array.isArray; - - function isNullOrUndef(o) { - return o === void 0 || o === null; - } - - function isInvalid(o) { - return o === null || o === false || o === true || o === void 0; - } - - function isFunction(o) { - return typeof o === 'function'; - } - - function isString(o) { - return typeof o === 'string'; - } - - function isNumber(o) { - return typeof o === 'number'; - } - - function isNull(o) { - return o === null; - } - - function isValidElement(obj) { - var isValidObject = typeof obj === 'object' && !isNull(obj); - - if (!isValidObject) { - return false; - } - - return (obj.flags & (14 - /* Component */ - | 481 - /* Element */ - )) > 0; - } - /** - * @module Inferno-Compat - */ - - /** - * Inlined PropTypes, there is propType checking ATM. - */ - // tslint:disable-next-line:no-empty - - - function proptype() {} - - proptype.isRequired = proptype; - - var getProptype = function getProptype() { - return proptype; - }; - - var PropTypes = { - any: getProptype, - array: proptype, - arrayOf: getProptype, - bool: proptype, - checkPropTypes: function checkPropTypes() { - return null; - }, - element: getProptype, - func: proptype, - instanceOf: getProptype, - node: getProptype, - number: proptype, - object: proptype, - objectOf: getProptype, - oneOf: getProptype, - oneOfType: getProptype, - shape: getProptype, - string: proptype, - symbol: proptype - }; - /** - * This is a list of all SVG attributes that need special casing, - * namespacing, or boolean value assignment. - * - * When adding attributes to this list, be sure to also add them to - * the `possibleStandardNames` module to ensure casing and incorrect - * name warnings. - * - * SVG Attributes List: - * https://www.w3.org/TR/SVG/attindex.html - * SMIL Spec: - * https://www.w3.org/TR/smil - */ - - var ATTRS = ['accent-height', 'alignment-baseline', 'arabic-form', 'baseline-shift', 'cap-height', 'clip-path', 'clip-rule', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'dominant-baseline', 'enable-background', 'fill-opacity', 'fill-rule', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-constiant', 'font-weight', 'glyph-name', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'horiz-adv-x', 'horiz-origin-x', 'image-rendering', 'letter-spacing', 'lighting-color', 'marker-end', 'marker-mid', 'marker-start', 'overline-position', 'overline-thickness', 'paint-order', 'panose-1', 'pointer-events', 'rendering-intent', 'shape-rendering', 'stop-color', 'stop-opacity', 'strikethrough-position', 'strikethrough-thickness', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-decoration', 'text-rendering', 'underline-position', 'underline-thickness', 'unicode-bidi', 'unicode-range', 'units-per-em', 'v-alphabetic', 'v-hanging', 'v-ideographic', 'v-mathematical', 'vector-effect', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'word-spacing', 'writing-mode', 'x-height', 'xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xmlns:xlink', 'xml:lang', 'xml:space']; - var InfernoCompatPropertyMap = { - htmlFor: 'for', - onDoubleClick: 'onDblClick' - }; - var CAMELIZE = /[\-:]([a-z])/g; - - var capitalize = function capitalize(token) { - return token[1].toUpperCase(); - }; - - ATTRS.forEach(function (original) { - var reactName = original.replace(CAMELIZE, capitalize); - InfernoCompatPropertyMap[reactName] = original; - }); - - function getNumberStyleValue(style, value) { - switch (style) { - case 'animation-iteration-count': - case 'border-image-outset': - case 'border-image-slice': - case 'border-image-width': - case 'box-flex': - case 'box-flex-group': - case 'box-ordinal-group': - case 'column-count': - case 'fill-opacity': - case 'flex': - case 'flex-grow': - case 'flex-negative': - case 'flex-order': - case 'flex-positive': - case 'flex-shrink': - case 'flood-opacity': - case 'font-weight': - case 'grid-column': - case 'grid-row': - case 'line-clamp': - case 'line-height': - case 'opacity': - case 'order': - case 'orphans': - case 'stop-opacity': - case 'stroke-dasharray': - case 'stroke-dashoffset': - case 'stroke-miterlimit': - case 'stroke-opacity': - case 'stroke-width': - case 'tab-size': - case 'widows': - case 'z-index': - case 'zoom': - return value; - - default: - return value + 'px'; - } - } - - var uppercasePattern = /[A-Z]/g; - - function hyphenCase(str) { - return str.replace(uppercasePattern, '-$&').toLowerCase(); - } - - options.reactStyles = true; - - function unmountComponentAtNode(container) { - __render(null, container, null, null); - - return true; - } - - function flatten(arr, result) { - for (var i = 0, len = arr.length; i < len; ++i) { - var value = arr[i]; - - if (isArray(value)) { - flatten(value, result); - } else { - result.push(value); - } - } - - return result; - } - - var ARR = []; - var Children = { - map: function map(children, fn, ctx) { - if (isNullOrUndef(children)) { - return children; - } - - children = Children.toArray(children); - - if (ctx) { - fn = fn.bind(ctx); - } - - return children.map(fn); - }, - forEach: function forEach(children, fn, ctx) { - if (isNullOrUndef(children)) { - return; - } - - children = Children.toArray(children); - - if (ctx) { - fn = fn.bind(ctx); - } - - for (var i = 0, len = children.length; i < len; ++i) { - var child = isInvalid(children[i]) ? null : children[i]; - fn(child, i, children); - } - }, - count: function count(children) { - children = Children.toArray(children); - return children.length; - }, - only: function only(children) { - children = Children.toArray(children); - - if (children.length !== 1) { - throw new Error('Children.only() expects only one child.'); - } - - return children[0]; - }, - toArray: function toArray(children) { - if (isNullOrUndef(children)) { - return []; - } // We need to flatten arrays here, - // because React does it also and application level code might depend on that behavior - - - if (isArray(children)) { - var result = []; - flatten(children, result); - return result; - } - - return ARR.concat(children); - } - }; - Component.prototype.isReactComponent = {}; - var version = '15.4.2'; - var validLineInputs = { - date: true, - 'datetime-local': true, - email: true, - month: true, - number: true, - password: true, - search: true, - tel: true, - text: true, - time: true, - url: true, - week: true - }; - - function normalizeGenericProps(props) { - for (var prop in props) { - var mappedProp = InfernoCompatPropertyMap[prop]; - - if (mappedProp && props[prop] && mappedProp !== prop) { - props[mappedProp] = props[prop]; - props[prop] = void 0; - } - - if (options.reactStyles && prop === 'style') { - var styles = props.style; - - if (styles && !isString(styles)) { - var newStyles = {}; - - for (var s in styles) { - var value = styles[s]; - var hyphenStr = hyphenCase(s); - newStyles[hyphenStr] = isNumber(value) ? getNumberStyleValue(hyphenStr, value) : value; - } - - props.style = newStyles; - } - } - } - } - - function normalizeFormProps(name, props) { - if ((name === 'input' || name === 'textarea') && props.type !== 'radio' && props.onChange) { - var type = props.type && props.type.toLowerCase(); - var eventName; - - if (!type || validLineInputs[type]) { - eventName = 'oninput'; - } - - if (eventName && !props[eventName]) { - props[eventName] = props.onChange; - props.onChange = void 0; - } - } - } // we need to add persist() to Event (as React has it for synthetic events) - // this is a hack and we really shouldn't be modifying a global object this way, - // but there isn't a performant way of doing this apart from trying to proxy - // every prop event that starts with "on", i.e. onClick or onKeyPress - // but in reality devs use onSomething for many things, not only for - // input events - - - if (typeof Event !== 'undefined') { - var eventProtoType = Event.prototype; - - if (!eventProtoType.persist) { - // tslint:disable-next-line:no-empty - eventProtoType.persist = function () {}; - } - } - - function iterableToArray(iterable) { - var iterStep; - var tmpArr = []; - - do { - iterStep = iterable.next(); - tmpArr.push(iterStep.value); - } while (!iterStep.done); - - return tmpArr; - } - - var g = typeof window === 'undefined' ? global : window; - var hasSymbolSupport = typeof g.Symbol !== 'undefined'; - var symbolIterator = hasSymbolSupport ? g.Symbol.iterator : ''; - var oldCreateVNode = options.createVNode; - - options.createVNode = function (vNode) { - var children = vNode.children; - var props = vNode.props; - - if (isNullOrUndef(props)) { - props = vNode.props = {}; - } // React supports iterable children, in addition to Array-like - - - if (hasSymbolSupport && !isNull(children) && typeof children === 'object' && !isArray(children) && isFunction(children[symbolIterator])) { - vNode.children = iterableToArray(children[symbolIterator]()); - } - - if (!isNullOrUndef(children) && isNullOrUndef(props.children)) { - props.children = children; - } - - if (vNode.flags & 14 - /* Component */ - ) { - if (isString(vNode.type)) { - vNode.flags = getFlagsForElementVnode(vNode.type); - - if (props) { - normalizeProps(vNode); - } - } - } - - var flags = vNode.flags; - - if (flags & 448 - /* FormElement */ - ) { - normalizeFormProps(vNode.type, props); - } - - if (flags & 481 - /* Element */ - ) { - if (vNode.className) { - props.className = vNode.className; - } - - normalizeGenericProps(props); - } - - if (oldCreateVNode) { - oldCreateVNode(vNode); - } - }; // Credit: preact-compat - https://github.com/developit/preact-compat :) - - - function shallowDiffers(a, b) { - var i; - - for (i in a) { - if (!(i in b)) { - return true; - } - } - - for (i in b) { - if (a[i] !== b[i]) { - return true; - } - } - - return false; - } - - var PureComponent = /*@__PURE__*/function (Component) { - function PureComponent() { - Component.apply(this, arguments); - } - - if (Component) PureComponent.__proto__ = Component; - PureComponent.prototype = Object.create(Component && Component.prototype); - PureComponent.prototype.constructor = PureComponent; - - PureComponent.prototype.shouldComponentUpdate = function shouldComponentUpdate(props, state) { - return shallowDiffers(this.props, props) || shallowDiffers(this.state, state); - }; - - return PureComponent; - }(Component); - - var WrapperComponent = /*@__PURE__*/function (Component) { - function WrapperComponent() { - Component.apply(this, arguments); - } - - if (Component) WrapperComponent.__proto__ = Component; - WrapperComponent.prototype = Object.create(Component && Component.prototype); - WrapperComponent.prototype.constructor = WrapperComponent; - - WrapperComponent.prototype.getChildContext = function getChildContext() { - // tslint:disable-next-line - return this.props.context; - }; - - WrapperComponent.prototype.render = function render(props) { - return props.children; - }; - - return WrapperComponent; - }(Component); - - function unstable_renderSubtreeIntoContainer(parentComponent, vNode, container, callback) { - var wrapperVNode = createComponentVNode(4 - /* ComponentClass */ - , WrapperComponent, { - children: vNode, - context: parentComponent.context - }); - render(wrapperVNode, container, null); - var component = vNode.children; - - if (callback) { - // callback gets the component as context, no other argument. - callback.call(component); - } - - return component; - } - - function createFactory(type) { - return createElement.bind(null, type); - } - - function render(rootInput, container, cb, context) { - if (cb === void 0) cb = null; - if (context === void 0) context = EMPTY_OBJ; - - __render(rootInput, container, cb, context); - - var input = container.$V; - - if (input && input.flags & 14 - /* Component */ - ) { - return input.children; - } - } // Mask React global in browser enviornments when React is not used. - - - if (typeof window !== 'undefined' && typeof window.React === 'undefined') { - var exports$1 = { - Children: Children, - Component: Component, - EMPTY_OBJ: EMPTY_OBJ, - Fragment: Fragment, - PropTypes: PropTypes, - PureComponent: PureComponent, - // Internal methods - _CI: createClassComponentInstance, - _HI: normalizeRoot, - _M: mount, - _MCCC: mountClassComponentCallbacks, - _ME: mountElement, - _MFCC: mountFunctionalComponentCallbacks, - _MP: mountProps, - _MR: mountRef, - __render: __render, - // Public methods - cloneElement: cloneVNode, - cloneVNode: cloneVNode, - createClass: createClass, - createComponentVNode: createComponentVNode, - createElement: createElement, - createFactory: createFactory, - createFragment: createFragment, - createPortal: createPortal, - createRef: createRef, - createRenderer: createRenderer, - createTextVNode: createTextVNode, - createVNode: createVNode, - directClone: directClone, - findDOMNode: findDOMNode, - findDOMfromVNode: findDOMfromVNode, - forwardRef: forwardRef, - getFlagsForElementVnode: getFlagsForElementVnode, - hydrate: hydrate, - isValidElement: isValidElement, - linkEvent: linkEvent, - normalizeProps: normalizeProps, - options: options, - render: render, - rerender: rerender, - unmountComponentAtNode: unmountComponentAtNode, - unstable_renderSubtreeIntoContainer: unstable_renderSubtreeIntoContainer, - version: version - }; - window.React = exports$1; - window.ReactDOM = exports$1; - } - - /* - * Inferno + inferno-compat without any Inferno specific optimizations - * Optimization flags could be used, but the purpose is to track performance of slow code paths - */ - - uibench.init('Inferno compat (simple)', version); - - function TreeLeaf(_ref) { - var children = _ref.children; - return createVNode$1(1, "li", "TreeLeaf", createTextVNode(children), 0, null, null, null); - } - - function shouldDataUpdate(lastProps, nextProps) { - return lastProps !== nextProps; - } - - function TreeNode(_ref2) { - var data = _ref2.data; - var length = data.children.length; - var children = new Array(length); - - for (var i = 0; i < length; i++) { - var n = data.children[i]; - var id = n.id; - - if (n.container) { - children[i] = createComponentVNode$1(2, TreeNode, { - "data": n - }, id, { - "onComponentShouldUpdate": shouldDataUpdate - }); - } else { - children[i] = createComponentVNode$1(2, TreeLeaf, { - children: id - }, id, { - "onComponentShouldUpdate": shouldDataUpdate - }); - } - } - - return createVNode$1(1, "ul", "TreeNode", children, 0, null, null, null); - } - - function tree(data) { - return createVNode$1(1, "div", "Tree", createComponentVNode$1(2, TreeNode, { - "data": data.root - }, null, { - "onComponentShouldUpdate": shouldDataUpdate - }), 2, null, null, null); - } - - function AnimBox(_ref3) { - var data = _ref3.data; - var time = data.time % 10; - var style = 'border-radius:' + time + 'px;' + 'background:rgba(0,0,0,' + (0.5 + time / 10) + ')'; - return createVNode$1(1, "div", "AnimBox", null, 1, { - "data-id": data.id, - "style": style - }, null, null); - } - - function anim(data) { - var items = data.items; - var length = items.length; - var children = new Array(length); - - for (var i = 0; i < length; i++) { - var item = items[i]; // Here we are using onComponentShouldUpdate functional Component hook, to short circuit rendering process of AnimBox Component - // When the data does not change - - children[i] = createComponentVNode$1(2, AnimBox, { - "data": item - }, item.id, { - "onComponentShouldUpdate": shouldDataUpdate - }); - } - - return createVNode$1(1, "div", "Anim", children, 0, null, null, null); - } - - function onClick(text, e) { - console.log('Clicked', text); - e.stopPropagation(); - } - - function TableCell(_ref4) { - var children = _ref4.children; - return createVNode$1(1, "td", "TableCell", createTextVNode(children), 0, { - "onClick": linkEvent(children, onClick) - }, null, null); - } - - function TableRow(_ref5) { - var data = _ref5.data; - var classes = 'TableRow'; - - if (data.active) { - classes = 'TableRow active'; - } - - var cells = data.props; - var length = cells.length + 1; - var children = new Array(length); - children[0] = createComponentVNode$1(2, TableCell, { - children: '#' + data.id - }, null, { - "onComponentShouldUpdate": shouldDataUpdate - }); - - for (var i = 1; i < length; i++) { - children[i] = createComponentVNode$1(2, TableCell, { - children: cells[i - 1] - }, null, { - "onComponentShouldUpdate": shouldDataUpdate - }); - } - - return createVNode$1(1, "tr", classes, children, 0, { - "data-id": data.id - }, null, null); - } - - function table(data) { - var items = data.items; - var length = items.length; - var children = new Array(length); - - for (var i = 0; i < length; i++) { - var item = items[i]; - children[i] = createComponentVNode$1(2, TableRow, { - "data": item, - children: item - }, item.id, { - "onComponentShouldUpdate": shouldDataUpdate - }); - } - - return createVNode$1(1, "table", "Table", children, 0, null, null, null); - } - - function main(data) { - var location = data.location; - var section; - - if (location === 'table') { - section = table(data.table); - } else if (location === 'anim') { - section = anim(data.anim); - } else if (location === 'tree') { - section = tree(data.tree); - } - - return createVNode$1(1, "div", "Main", section, 0, null, null, null); - } - - document.addEventListener('DOMContentLoaded', function (e) { - var container = document.querySelector('#App'); - uibench.run(function (state) { - render(main(state), container); - }, function (samples) { - render(createVNode$1(1, "pre", null, JSON.stringify(samples, null, ' '), 0, null, null, null), container); - }); - }); - -}()); +!function(){"use strict";var e=Array.isArray;function n(e){var n=typeof e;return"string"===n||"number"===n}function t(e){return void 0===e||null===e}function r(e){return null===e||!1===e||!0===e||void 0===e}function o(e){return"string"===typeof e}function i(e){return null===e}function l(e,n){var t={};if(e)for(var r in e)t[r]=e[r];if(n)for(var o in n)t[o]=n[o];return t}var a={};function u(e,n){for(var t in n)void 0===e[t]&&(e[t]=n[t]);return e}var c="$";function f(e,n,t,r,o,i,l,a){this.childFlags=e,this.children=n,this.className=t,this.dom=null,this.flags=r,this.key=void 0===o?null:o,this.props=void 0===i?null:i,this.ref=void 0===l?null:l,this.type=a}function s(e,n,t,r,o,i,l,a){var u=void 0===o?1:o,c=new f(u,r,t,e,l,i,a,n);return 0===u&&C(c,c.children),c}function d(e,n,r){if(4&e)return r;var o=(32768&e?n.render:n).defaultHooks;if(t(o))return r;if(t(r))return o;return u(r,o)}function p(e,n,r){var o=(32768&e?n.render:n).defaultProps;if(t(o))return r;if(t(r))return l(o,null);return u(r,o)}function v(e,n){if(12&e)return e;if(n.prototype&&n.prototype.render)return 4;if(n.render)return 32776;return 8}function h(e,n,t,r,o){return new f(1,null,null,e=v(e,n),r,p(e,n,t),d(e,n,o),n)}function m(e,n){return new f(1,t(e)||!0===e||!1===e?"":e,null,16,n,null,null,null)}function g(e,n,t){var r=s(8192,8192,null,e,n,null,t,null);switch(r.childFlags){case 1:r.children=m("",null),r.childFlags=2;break;case 16:r.children=[m(e)],r.childFlags=4}return r}function y(e){var n=e.children,t=e.childFlags;return g(2===t?b(n):n.map(b),t,e.key)}function b(e){var n=-16385&e.flags,t=e.props;if(14&n&&!i(t)){var r=t;for(var o in t={},r)t[o]=r[o]}if(0===(8192&n))return new f(e.childFlags,e.children,e.className,n,e.key,t,e.ref,e.type);return y(e)}function k(t,l,a,u){for(var f=t.length;a0,h=i(p),g=o(p)&&p[0]===c;v||h||g?(a=a||l.slice(0,s),(v||g)&&(d=b(d)),(h||g)&&(d.key=c+s),a.push(d)):a&&a.push(d),d.flags|=65536}}u=0===(a=a||l).length?1:8}else(a=l).flags|=65536,81920&l.flags&&(a=b(l)),u=2;return t.children=a,t.childFlags=u,t}function w(e,n,t){if(e[n]){var r=e[n];r.event?r.event(r.data,t):r(t)}else{var o=n.toLowerCase();e[o]&&e[o](t)}}function x(e,n){var t=function(t){var r=this.$V;if(!r)return;var i=r.props||a,l=r.dom;if(o(e))w(i,e,t);else for(var u=0;u-1&&n.options[l]&&(a=n.options[l].value),r&&t(a)&&(a=e.defaultValue),P(o,a)}})),x("onInput",(function(e,n,r){var o=e.value,i=n.value;if(t(o)){if(r){var l=e.defaultValue;t(l)||l===i||(n.defaultValue=l,n.value=l)}}else i!==o&&(n.defaultValue=o,n.value=o)})),x("onChange"),"undefined"!==typeof document&&window.Node&&(Node.prototype.$EV=null,Node.prototype.$V=null),"undefined"!==typeof Promise&&Promise.resolve().then.bind(Promise.resolve());var F=Array.isArray;function V(e){var n=typeof e;return"string"===n||"number"===n}function U(e){return void 0===e||null===e}function D(e){return null===e||!1===e||!0===e||void 0===e}function M(e){return"function"===typeof e}function I(e){return"string"===typeof e}function A(e){return null===e}function L(e,n){var t={};if(e)for(var r in e)t[r]=e[r];if(n)for(var o in n)t[o]=n[o];return t}function T(e,n){if(M(n))return{data:e,event:n};return null}function W(e){return!A(e)&&"object"===typeof e}var _={},E=function(){this.componentDidAppear=[],this.componentWillDisappear=[],this.componentWillMove=[]};function O(e){return e.substr(2).toLowerCase()}function B(e,n){e.appendChild(n)}function R(e,n,t){A(t)?B(e,n):e.insertBefore(n,t)}function j(e,n){if(n)return document.createElementNS("http://www.w3.org/2000/svg",e);return document.createElement(e)}function H(e,n,t){e.replaceChild(n,t)}function z(e,n){e.removeChild(n)}function Q(e){for(var n=0;n0?G(t.componentWillDisappear,Y(e,n)):J(e,n,!1)}function ee(e,n,t,r,o,i,l,a){e.componentWillMove.push({dom:r,fn:function(){4&l?t.componentWillMove(n,o,r,a):8&l&&t.onComponentWillMove(n,o,r,a)},next:i,parent:o})}function ne(e,n,t,r,o){var i,l,a=n.flags;do{var u=n.flags;if(2033&u)return void(U(i)||!M(i.componentWillMove)&&!M(i.onComponentWillMove)?R(t,n.dom,r):ee(o,e,i,n.dom,t,r,a,l));var c=n.children;if(4&u&&(i=n.children,l=n.props,n=c.$LI),8&u&&(i=n.ref,l=n.props,n=c),8192&u){if(2!==n.childFlags){for(var f=0,s=c.length;f0,c=A(a),f=I(a)&&a[0]===ce;u||c||f?(t=t||n.slice(0,i),(u||f)&&(l=ke(l)),(c||f)&&(l.key=ce+i),t.push(l)):t&&t.push(l),l.flags|=65536}}r=0===(t=t||n).length?1:8}else(t=n).flags|=65536,81920&n.flags&&(t=ke(n)),r=2;return e.children=t,e.childFlags=r,e}function Ne(e){if(D(e)||V(e))return me(e,null);if(F(e))return ge(e,0,null);return 16384&e.flags?ke(e):e}var Pe="http://www.w3.org/1999/xlink",Se="http://www.w3.org/XML/1998/namespace",Fe={"xlink:actuate":Pe,"xlink:arcrole":Pe,"xlink:href":Pe,"xlink:role":Pe,"xlink:show":Pe,"xlink:title":Pe,"xlink:type":Pe,"xml:base":Se,"xml:lang":Se,"xml:space":Se};function Ve(e){return{onClick:e,onDblClick:e,onFocusIn:e,onFocusOut:e,onKeyDown:e,onKeyPress:e,onKeyUp:e,onMouseDown:e,onMouseMove:e,onMouseUp:e,onTouchEnd:e,onTouchMove:e,onTouchStart:e}}var Ue=Ve(0),De=Ve(null),Me=Ve(!0);function Ie(e,n){var t=n.$EV;return t||(t=n.$EV=Ve(null)),t[e]||1===++Ue[e]&&(De[e]=He(e)),t}function Ae(e,n){var t=n.$EV;t&&t[e]&&(0===--Ue[e]&&(document.removeEventListener(O(e),De[e]),De[e]=null),t[e]=null)}function Le(e,n,t,r){if(M(t))Ie(e,r)[e]=t;else if(W(t)){if(le(n,t))return;Ie(e,r)[e]=t}else Ae(e,r)}function Te(e){return M(e.composedPath)?e.composedPath()[0]:e.target}function We(e,n,t,r){var o=Te(e);do{if(n&&o.disabled)return;var i=o.$EV;if(i){var l=i[t];if(l&&(r.dom=o,l.event?l.event(l.data,e):l(e),e.cancelBubble))return}o=o.parentNode}while(!A(o))}function _e(){this.cancelBubble=!0,this.immediatePropagationStopped||this.stopImmediatePropagation()}function Ee(){return this.defaultPrevented}function Oe(){return this.cancelBubble}function Be(e){var n={dom:document};return e.isDefaultPrevented=Ee,e.isPropagationStopped=Oe,e.stopPropagation=_e,Object.defineProperty(e,"currentTarget",{configurable:!0,get:function(){return n.dom}}),n}function Re(e){return function(n){if(0!==n.button)return void n.stopPropagation();We(n,!0,e,Be(n))}}function je(e){return function(n){We(n,!1,e,Be(n))}}function He(e){var n="onClick"===e||"onDblClick"===e?Re(e):je(e);return document.addEventListener(O(e),n),n}function ze(e,n){var t=document.createElement("i");return t.innerHTML=n,t.innerHTML===e.innerHTML}function Qe(e,n,t){if(e[n]){var r=e[n];r.event?r.event(r.data,t):r(t)}else{var o=n.toLowerCase();e[o]&&e[o](t)}}function Xe(e,n){var t=function(t){var r=this.$V;if(!r)return;var o=r.props||_,i=r.dom;if(I(e))Qe(o,e,t);else for(var l=0;l-1&&n.options[i]&&(l=n.options[i].value),t&&U(l)&&(l=e.defaultValue),nn(r,l)}}var an,un,cn=Xe("onInput",dn),fn=Xe("onChange");function sn(e,n){qe(e,"input",cn),n.onChange&&qe(e,"change",fn)}function dn(e,n,t){var r=e.value,o=n.value;if(U(r)){if(t){var i=e.defaultValue;U(i)||i===o||(n.defaultValue=i,n.value=i)}}else o!==r&&(n.defaultValue=r,n.value=r)}function pn(e,n,t,r,o,i){64&e?en(r,t):256&e?ln(r,t,o,n):128&e&&dn(r,t,o),i&&(t.$V=n)}function vn(e,n,t){64&e?Ze(n,t):256&e?on(n):128&e&&sn(n,t)}function hn(e){return e.type&&Ge(e.type)?!U(e.checked):!U(e.value)}function mn(e){e&&!ue(e,null)&&e.current&&(e.current=null)}function gn(e,n,t){e&&(M(e)||void 0!==e.current)&&t.push((function(){ue(e,n)||void 0===e.current||(e.current=n)}))}function yn(e,n,t){bn(e,t),Z(e,n,t)}function bn(e,n){var t,r=e.flags,o=e.children;if(481&r){t=e.ref;var i=e.props;mn(t);var l=e.childFlags;if(!A(i))for(var a=Object.keys(i),u=0,c=a.length;u0?G(t.componentWillDisappear,Cn(n,e)):e.textContent=""}function xn(e,n,t,r){kn(t,r),8192&n.flags?Z(n,e,r):wn(e,t,r)}function $n(e,n,t,r,o){e.componentWillDisappear.push((function(e){4&r?n.componentWillDisappear(t,e):8&r&&n.onComponentWillDisappear(t,o,e)}))}function Nn(e){var n=e.event;return function(t){n(e.data,t)}}function Pn(e,n,t,r){if(W(t)){if(le(n,t))return;t=Nn(t)}qe(r,O(e),t)}function Sn(e,n,t){if(U(n))return void t.removeAttribute("style");var r,o,i=t.style;if(I(n))return void(i.cssText=n);if(U(e)||I(e))for(r in n)o=n[r],i.setProperty(r,o);else{for(r in n)(o=n[r])!==e[r]&&i.setProperty(r,o);for(r in e)U(n[r])&&i.removeProperty(r)}}function Fn(e,n,t,r,o){var i=e&&e.__html||"",l=n&&n.__html||"";i!==l&&(U(l)||ze(r,l)||(A(t)||(12&t.childFlags?kn(t.children,o):2===t.childFlags&&bn(t.children,o),t.children=null,t.childFlags=1),r.innerHTML=l))}function Vn(e,n,t,r,o,i,l,a){switch(e){case"children":case"childrenType":case"className":case"defaultValue":case"key":case"multiple":case"ref":case"selectedIndex":break;case"autoFocus":r.autofocus=!!t;break;case"allowfullscreen":case"autoplay":case"capture":case"checked":case"controls":case"default":case"disabled":case"hidden":case"indeterminate":case"loop":case"muted":case"novalidate":case"open":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"selected":r[e]=!!t;break;case"defaultChecked":case"value":case"volume":if(i&&"value"===e)break;var u=U(t)?"":t;r[e]!==u&&(r[e]=u);break;case"style":Sn(n,t,r);break;case"dangerouslySetInnerHTML":Fn(n,t,l,r,a);break;default:Me[e]?Le(e,n,t,r):111===e.charCodeAt(0)&&110===e.charCodeAt(1)?Pn(e,n,t,r):U(t)?r.removeAttribute(e):o&&Fe[e]?r.setAttributeNS(Fe[e],e,t):r.setAttribute(e,t)}}function Un(e,n,t,r,o,i){var l=!1,a=(448&n)>0;for(var u in a&&(l=hn(t))&&vn(n,r,t),t)Vn(u,null,t[u],r,o,l,null,i);a&&pn(n,e,r,t,!0,l)}function Dn(e,n,t){var r=Ne(e.render(n,e.state,t)),o=t;return M(e.getChildContext)&&(o=L(t,e.getChildContext())),e.$CX=o,r}function Mn(e,n,t,r,o,i){var l=new n(t,r),a=l.$N=Boolean(n.getDerivedStateFromProps||l.getSnapshotBeforeUpdate);if(l.$SVG=o,l.$L=i,e.children=l,l.$BS=!1,l.context=r,l.props===_&&(l.props=t),a)l.state=te(l,t,l.state);else if(M(l.componentWillMount)){l.$BR=!0,l.componentWillMount();var u=l.$PS;if(!A(u)){var c=l.state;if(A(c))l.state=u;else for(var f in u)c[f]=u[f];l.$PS=null}l.$BR=!1}return l.$LI=Dn(l,t,r),l}function In(e,n){var t=e.props||_;return 32768&e.flags?e.type.render(t,e.ref,n):e.type(t,n)}function An(e,n,t,r,o,i,l){var a=e.flags|=16384;481&a?_n(e,n,t,r,o,i,l):4&a?On(e,n,t,r,o,i,l):8&a?Bn(e,n,t,r,o,i,l):512&a||16&a?Wn(e,n,o):8192&a?Tn(e,t,n,r,o,i,l):1024&a&&Ln(e,t,n,o,i,l)}function Ln(e,n,t,r,o,i){An(e.children,e.ref,n,!1,null,o,i);var l=Ce();Wn(l,t,r),e.dom=l.dom}function Tn(e,n,t,r,o,i,l){var a=e.children,u=e.childFlags;12&u&&0===a.length&&(u=e.childFlags=2,a=e.children=Ce()),2===u?An(a,t,o,r,o,i,l):En(a,t,n,r,o,i,l)}function Wn(e,n,t){var r=e.dom=document.createTextNode(e.children);A(n)||R(n,r,t)}function _n(e,n,t,r,o,i,l){var a=e.flags,u=e.props,c=e.className,f=e.childFlags,s=e.dom=j(e.type,r=r||(32&a)>0),d=e.children;if(U(c)||""===c||(r?s.setAttribute("class",c):s.className=c),16===f)ie(s,d);else if(1!==f){var p=r&&"foreignObject"!==e.type;2===f?(16384&d.flags&&(e.children=d=ke(d)),An(d,s,t,p,null,i,l)):8!==f&&4!==f||En(d,s,t,p,null,i,l)}A(n)||R(n,s,o),A(u)||Un(e,a,u,s,r,l),gn(e.ref,s,i)}function En(e,n,t,r,o,i,l){for(var a=0;a0&&K(a.componentWillMove)}function Gn(e,n,t){e!==n&&(""!==e?t.firstChild.nodeValue=n:ie(t,n))}function Kn(e,n){e.textContent!==n&&(e.textContent=n)}function Jn(e,n,t,r,o,i,l){var a=e.children,u=n.children,c=e.childFlags,f=n.childFlags,s=null;12&f&&0===u.length&&(f=n.childFlags=2,u=n.children=Ce());var d=0!==(2&f);if(12&c){var p=a.length;(8&c&&8&f||d||!d&&u.length>p)&&(s=q(a[p-1],!1).nextSibling)}nt(c,f,a,u,t,r,o,s,e,i,l)}function Yn(e,n,t,r,o){var i=e.ref,l=n.ref,a=n.children;if(nt(e.childFlags,n.childFlags,e.children,a,i,t,!1,null,e,r,o),n.dom=e.dom,i!==l&&!D(a)){var u=a.dom;z(i,u),B(l,u)}}function Zn(e,n,t,r,o,i,l){var a,u=n.dom=e.dom,c=e.props,f=n.props,s=!1,d=!1;if(r=r||(32&o)>0,c!==f){var p=c||_;if((a=f||_)!==_)for(var v in(s=(448&o)>0)&&(d=hn(a)),a){var h=p[v],m=a[v];h!==m&&Vn(v,h,m,u,r,d,e,l)}if(p!==_)for(var g in p)U(a[g])&&!U(p[g])&&Vn(g,p[g],null,u,r,d,e,l)}var y=n.children,b=n.className;e.className!==b&&(U(b)?u.removeAttribute("class"):r?u.setAttribute("class",b):u.className=b),4096&o?Kn(u,y):nt(e.childFlags,n.childFlags,e.children,y,u,t,r&&"foreignObject"!==n.type,null,e,i,l),s&&pn(o,n,u,a,!1,d);var k=n.ref,C=e.ref;C!==k&&(mn(C),gn(k,u,i))}function et(e,n,t,r,o,i,l){bn(e,l),En(n,t,r,o,q(e,!0),i,l),Z(e,t,l)}function nt(e,n,t,r,o,i,l,a,u,c,f){switch(e){case 2:switch(n){case 2:qn(t,r,o,i,l,a,c,f);break;case 1:yn(t,o,f);break;case 16:bn(t,f),ie(o,r);break;default:et(t,r,o,i,l,c,f)}break;case 1:switch(n){case 2:An(r,o,i,l,a,c,f);break;case 1:break;case 16:ie(o,r);break;default:En(r,o,i,l,a,c,f)}break;case 16:switch(n){case 16:Gn(t,r,o);break;case 2:wn(o,t,f),An(r,o,i,l,a,c,f);break;case 1:wn(o,t,f);break;default:wn(o,t,f),En(r,o,i,l,a,c,f)}break;default:switch(n){case 16:kn(t,f),ie(o,r);break;case 2:xn(o,u,t,f),An(r,o,i,l,a,c,f);break;case 1:xn(o,u,t,f);break;default:var s=0|t.length,d=0|r.length;0===s?d>0&&En(r,o,i,l,a,c,f):0===d?xn(o,u,t,f):8===n&&8===e?ut(t,r,o,i,l,s,d,a,u,c,f):at(t,r,o,i,l,s,d,a,c,f)}}}function tt(e,n,t,r,o){o.push((function(){e.componentDidUpdate(n,t,r)}))}function rt(e,n,t,r,o,i,l,a,u,c){var f=e.state,s=e.props,d=Boolean(e.$N),p=M(e.shouldComponentUpdate);if(d&&(n=te(e,t,n!==f?L(f,n):n)),l||!p||p&&e.shouldComponentUpdate(t,n,o)){!d&&M(e.componentWillUpdate)&&e.componentWillUpdate(t,n,o),e.props=t,e.state=n,e.context=o;var v=null,h=Dn(e,t,o);d&&M(e.getSnapshotBeforeUpdate)&&(v=e.getSnapshotBeforeUpdate(s,f)),qn(e.$LI,h,r,e.$CX,i,a,u,c),e.$LI=h,M(e.componentDidUpdate)&&tt(e,s,f,v,u)}else e.props=t,e.state=n,e.context=o}function ot(e,n,t,r,o,i,l,a){var u=n.children=e.children;if(A(u))return;u.$L=l;var c=n.props||_,f=n.ref,s=e.ref,d=u.state;if(!u.$N){if(M(u.componentWillReceiveProps)){if(u.$BR=!0,u.componentWillReceiveProps(c,r),u.$UN)return;u.$BR=!1}A(u.$PS)||(d=L(d,u.$PS),u.$PS=null)}rt(u,d,c,t,r,o,!1,i,l,a),s!==f&&(mn(s),gn(f,u,l))}function it(e,n,t,r,o,i,l,a){var u=!0,c=n.props||_,f=n.ref,s=e.props,d=!U(f),p=e.children;if(d&&M(f.onComponentShouldUpdate)&&(u=f.onComponentShouldUpdate(s,c)),!1!==u){d&&M(f.onComponentWillUpdate)&&f.onComponentWillUpdate(s,c);var v=Ne(In(n,r));qn(p,v,t,r,o,i,l,a),n.children=v,d&&M(f.onComponentDidUpdate)&&f.onComponentDidUpdate(s,c)}else n.children=p}function lt(e,n){var t=n.children,r=n.dom=e.dom;t!==e.children&&(r.nodeValue=t)}function at(e,n,t,r,o,i,l,a,u,c){for(var f,s,d=i>l?l:i,p=0;pl)for(p=d;pp||h>v)break e;m=e[h],g=n[h]}for(m=e[p],g=n[v];m.key===g.key;){if(16384&g.flags&&(n[v]=g=ke(g)),qn(m,g,t,r,o,a,c,f),e[p]=g,v--,h>--p||h>v)break e;m=e[p],g=n[v]}}if(h>p){if(h<=v)for(d=(s=v+1)v)for(;h<=p;)yn(e[h++],t,f);else ct(e,n,r,i,l,p,v,h,t,o,a,u,c,f)}function ct(e,n,t,r,o,i,l,a,u,c,f,s,d,p){var v,h,m=0,g=0,y=a,b=a,k=i-a+1,C=l-a+1,w=new Int32Array(C+1),x=k===r,$=!1,N=0,P=0;if(o<4||(k|C)<32)for(g=y;g<=i;++g)if(v=e[g],Pa?$=!0:N=a,16384&h.flags&&(n[a]=h=ke(h)),qn(v,h,u,t,c,f,d,p),++P;break}!x&&a>l&&yn(v,u,p)}else x||yn(v,u,p);else{var S={};for(g=b;g<=l;++g)S[n[g].key]=g;for(g=y;g<=i;++g)if(v=e[g],Py;)yn(e[y++],u,p);w[a-b]=g+1,N>a?$=!0:N=a,16384&(h=n[a]).flags&&(n[a]=h=ke(h)),qn(v,h,u,t,c,f,d,p),++P}else x||yn(v,u,p);else x||yn(v,u,p)}if(x)xn(u,s,e,p),En(n,u,t,c,f,d,p);else if($){var F=st(w);for(a=F.length-1,g=C-1;g>=0;g--)0===w[g]?(16384&(h=n[N=g+b]).flags&&(n[N]=h=ke(h)),An(h,u,t,c,(m=N+1)=0;g--)0===w[g]&&(16384&(h=n[N=g+b]).flags&&(n[N]=h=ke(h)),An(h,u,t,c,(m=N+1)ft&&(ft=u,an=new Int32Array(u),un=new Int32Array(u));t>1]]0&&(un[t]=an[i-1]),an[i]=t)}i=o+1;var c=new Int32Array(i);for(l=an[i-1];i-- >0;)c[i]=l,l=un[l],an[i]=0;return c}function dt(e,n,t,r){var o=[],i=new E,l=n.$V;re.v=!0,U(l)?U(e)||(16384&e.flags&&(e=ke(e)),An(e,n,r,!1,null,o,i),n.$V=e,l=e):U(e)?(yn(l,n,i),n.$V=null):(16384&e.flags&&(e=ke(e)),qn(l,e,n,r,!1,null,o,i),l=n.$V=e),Q(o),G(i.componentDidAppear),re.v=!1,M(t)&&t(),M(oe.renderComplete)&&oe.renderComplete(l,n)}function pt(e,n,t,r){void 0===t&&(t=null),void 0===r&&(r=_),dt(e,n,t,r)}"undefined"!==typeof document&&window.Node&&(Node.prototype.$EV=null,Node.prototype.$V=null);var vt=[],ht="undefined"!==typeof Promise?Promise.resolve().then.bind(Promise.resolve()):function(e){window.setTimeout(e,0)},mt=!1;function gt(e,n,t,r){var o=e.$PS;if(M(n)&&(n=n(o?L(e.state,o):e.state,e.props,e.context)),U(o))e.$PS=n;else for(var i in n)o[i]=n[i];if(e.$BR)M(t)&&e.$L.push(t.bind(e));else{if(!re.v&&0===vt.length)return kt(e,r),void(M(t)&&t.call(e));if(-1===vt.indexOf(e)&&vt.push(e),r&&(e.$F=!0),mt||(mt=!0,ht(bt)),M(t)){var l=e.$QU;l||(l=e.$QU=[]),l.push(t)}}}function yt(e){for(var n=e.$QU,t=0;t0?An(v,n,r,o,t,i,l):t=(t=It(v,n,t,r,o,i,l))?t.nextSibling:null,s=(16&v.flags)>0}if(0===(8192&f))for(var h=null;t;)h=t.nextSibling,n.removeChild(t),t=h}else xt(n.firstChild)||St(n,c)||(n.textContent="",448&f&&(n.defaultValue=""))}function Ut(e,n,t,r,o,i,l){var a,u=e.props,c=e.className,f=e.flags,s=e.ref;return o=o||(32&f)>0,1!==t.nodeType||t.tagName.toLowerCase()!==e.type?(_n(e,null,r,o,null,i,l),n.replaceChild(e.dom,t)):(e.dom=t,Vt(e,t,t.firstChild,r,o,i,l),xt(u)||Un(e,f,u,t,o,l),void 0===(a=c)||null===a?""!==t.className&&t.removeAttribute("class"):o?t.setAttribute("class",c):t.className=c,gn(s,t,i)),e.dom}function Dt(e,n,t){if(3!==t.nodeType)n.replaceChild(e.dom=document.createTextNode(e.children),t);else{var r=e.children;t.nodeValue!==r&&(t.nodeValue=r),e.dom=t}return e.dom}function Mt(e,n,t,r,o,i,l){var a=e.children;if(2===e.childFlags)return Dt(a,n,t),a.dom;return Vt(e,n,t,r,o,i,l),Pt(a[a.length-1])}function It(e,n,t,r,o,i,l){var a=e.flags|=16384;if(14&a)return Ft(e,n,t,r,o,(4&a)>0,i,l);if(481&a)return Ut(e,n,t,r,o,i,l);if(16&a)return Dt(e,n,t);if(512&a)return e.dom=t;if(8192&a)return Mt(e,n,t,r,o,i,l);return $t(),null}function At(e,n){var t={};if(e)for(var r in e)t[r]=e[r];if(n)for(var o in n)t[o]=n[o];return t}function Lt(e,n,t){var r=arguments,o=e.flags,i=14&o?e.props&&e.props.children:e.children,l=arguments.length-2,a=e.className,u=e.key,c=e.ref;if(n?(void 0!==n.className&&(a=n.className),void 0!==n.ref&&(c=n.ref),void 0!==n.key&&(u=n.key),void 0!==n.children&&(i=n.children)):n={},1===l)i=t;else if(l>1)for(i=[];l-- >0;)i[l]=r[l+2];if(n.children=i,14&o)return he(o,e.type,e.props||n?At(e.props,n):_,u,c);if(16&o)return me(i);if(8192&o)return ge(1===l?[i]:i,0,u);return ye(se(o,e.type,a,null,1,At(e.props,n),u,c))}function Tt(e){throw e||(e="a runtime error occured! Use Inferno in development environment to find the error."),new Error("Inferno Error: "+e)}Ct.prototype.forceUpdate=function(e){if(this.$UN)return;gt(this,{},e,!0)},Ct.prototype.setState=function(e,n){if(this.$UN)return;this.$BS||gt(this,e,n,!1)},Ct.prototype.render=function(e,n,t){return null};var Wt={componentDidMount:1,componentDidUnmount:1,componentDidUpdate:1,componentWillMount:1,componentWillUnmount:1,componentWillUpdate:1,constructor:1,render:1,shouldComponentUpdate:1};function _t(e,n){for(var t in n)e[t]=n[t];return e}function Et(e){for(var n in e){var t=e[n];"function"!==typeof t||t.__bound||Wt[n]||((e[n]=t.bind(e)).__bound=!0)}}function Ot(e,n){void 0===n&&(n={});for(var t=0,r=e.length;t1)for(r=[];f-- >0;)r[f]=i[f+2];if(!Qt(e)){if(c=2,Xt(r)||(n||(n={}),n.children=r),!zt(n))for(var s in o={},n)"key"===s?a=n.key:"ref"===s?l=n.ref:1===qt[s]?(l||(l={}),l[s]=n[s]):o[s]=n[s];return he(c,e,o,a,l)}if(c=xe(e),!zt(n))for(var d in o={},n)"className"===d||"class"===d?u=n[d]:"key"===d?a=n.key:"children"===d&&Xt(r)?r=n.children:"ref"===d?l=n.ref:("contenteditable"===d&&(c|=4096),o[d]=n[d]);if(8192&c)return ge(1===f?[r]:r,0,a);return se(c,e,u,r,0,o,a,l)}var Kt=Array.isArray;function Jt(e){return void 0===e||null===e}function Yt(e){return"string"===typeof e}function Zt(e){return null===e}function er(){}er.isRequired=er;var nr=function(){return er},tr={any:nr,array:er,arrayOf:nr,bool:er,checkPropTypes:function(){return null},element:nr,func:er,instanceOf:nr,node:nr,number:er,object:er,objectOf:nr,oneOf:nr,oneOfType:nr,shape:nr,string:er,symbol:er},rr={htmlFor:"for",onDoubleClick:"onDblClick"},or=/[\-:]([a-z])/g,ir=function(e){return e[1].toUpperCase()};function lr(e,n){switch(e){case"animation-iteration-count":case"border-image-outset":case"border-image-slice":case"border-image-width":case"box-flex":case"box-flex-group":case"box-ordinal-group":case"column-count":case"fill-opacity":case"flex":case"flex-grow":case"flex-negative":case"flex-order":case"flex-positive":case"flex-shrink":case"flood-opacity":case"font-weight":case"grid-column":case"grid-row":case"line-clamp":case"line-height":case"opacity":case"order":case"orphans":case"stop-opacity":case"stroke-dasharray":case"stroke-dashoffset":case"stroke-miterlimit":case"stroke-opacity":case"stroke-width":case"tab-size":case"widows":case"z-index":case"zoom":return n;default:return n+"px"}}["accent-height","alignment-baseline","arabic-form","baseline-shift","cap-height","clip-path","clip-rule","color-interpolation","color-interpolation-filters","color-profile","color-rendering","dominant-baseline","enable-background","fill-opacity","fill-rule","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-constiant","font-weight","glyph-name","glyph-orientation-horizontal","glyph-orientation-vertical","horiz-adv-x","horiz-origin-x","image-rendering","letter-spacing","lighting-color","marker-end","marker-mid","marker-start","overline-position","overline-thickness","paint-order","panose-1","pointer-events","rendering-intent","shape-rendering","stop-color","stop-opacity","strikethrough-position","strikethrough-thickness","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-rendering","underline-position","underline-thickness","unicode-bidi","unicode-range","units-per-em","v-alphabetic","v-hanging","v-ideographic","v-mathematical","vector-effect","vert-adv-y","vert-origin-x","vert-origin-y","word-spacing","writing-mode","x-height","xlink:actuate","xlink:arcrole","xlink:href","xlink:role","xlink:show","xlink:title","xlink:type","xml:base","xmlns:xlink","xml:lang","xml:space"].forEach((function(e){var n=e.replace(or,ir);rr[n]=e}));var ar=/[A-Z]/g;function ur(e,n){for(var t=0,r=e.length;t0)for(var a;void 0!==(a=i.shift());)a()}n.$V=e,wt(t)&&t()},isValidElement:function(e){if("object"!==typeof e||Zt(e))return!1;return(495&e.flags)>0},linkEvent:T,normalizeProps:ye,options:oe,render:$r,rerender:bt,unmountComponentAtNode:function(e){return dt(null,e,null,null),!0},unstable_renderSubtreeIntoContainer:function(e,n,t,r){$r(he(4,xr,{children:n,context:e.context}),t,null);var o=n.children;return r&&r.call(o),o},version:sr};window.React=Nr,window.ReactDOM=Nr}function Pr(e){return s(1,"li","TreeLeaf",me(e.children),0,null,null,null)}function Sr(e,n){return e!==n}function Fr(e){for(var n=e.data,t=n.children.length,r=new Array(t),o=0;o 0; - var isNullKey = isNull(key); - var isPrefixed = isString(key) && key[0] === keyPrefix; - if (needsCloning || isNullKey || isPrefixed) { - newChildren = newChildren || children.slice(0, i); - if (needsCloning || isPrefixed) { - n = directClone(n); - } - if (isNullKey || isPrefixed) { - n.key = keyPrefix + i; - } - newChildren.push(n); - } - else if (newChildren) { - newChildren.push(n); - } - n.flags |= 65536 /* Normalized */; - } - } - newChildren = newChildren || children; - if (newChildren.length === 0) { - newChildFlags = 1 /* HasInvalidChildren */; - } - else { - newChildFlags = 8 /* HasKeyedChildren */; - } - } - else { - newChildren = children; - newChildren.flags |= 65536 /* Normalized */; - if (children.flags & 81920 /* InUseOrNormalized */) { - newChildren = directClone(children); - } - newChildFlags = 2 /* HasVNodeChildren */; - } - vNode.children = newChildren; - vNode.childFlags = newChildFlags; - return vNode; - } - function normalizeRoot(input) { - if (isInvalid(input) || isStringOrNumber(input)) { - return createTextVNode(input, null); - } - if (isArray(input)) { - return createFragment(input, 0 /* UnknownChildren */, null); - } - return input.flags & 16384 /* InUse */ ? directClone(input) : input; - } - - var xlinkNS = 'http://www.w3.org/1999/xlink'; - var xmlNS = 'http://www.w3.org/XML/1998/namespace'; - var namespaces = { - 'xlink:actuate': xlinkNS, - 'xlink:arcrole': xlinkNS, - 'xlink:href': xlinkNS, - 'xlink:role': xlinkNS, - 'xlink:show': xlinkNS, - 'xlink:title': xlinkNS, - 'xlink:type': xlinkNS, - 'xml:base': xmlNS, - 'xml:lang': xmlNS, - 'xml:space': xmlNS - }; - - function getDelegatedEventObject(v) { - return { - onClick: v, - onDblClick: v, - onFocusIn: v, - onFocusOut: v, - onKeyDown: v, - onKeyPress: v, - onKeyUp: v, - onMouseDown: v, - onMouseMove: v, - onMouseUp: v, - onTouchEnd: v, - onTouchMove: v, - onTouchStart: v - }; - } - var attachedEventCounts = getDelegatedEventObject(0); - var attachedEvents = getDelegatedEventObject(null); - var syntheticEvents = getDelegatedEventObject(true); - function updateOrAddSyntheticEvent(name, dom) { - var eventsObject = dom.$EV; - if (!eventsObject) { - eventsObject = dom.$EV = getDelegatedEventObject(null); - } - if (!eventsObject[name]) { - if (++attachedEventCounts[name] === 1) { - attachedEvents[name] = attachEventToDocument(name); - } - } - return eventsObject; - } - function unmountSyntheticEvent(name, dom) { - var eventsObject = dom.$EV; - if (eventsObject && eventsObject[name]) { - if (--attachedEventCounts[name] === 0) { - document.removeEventListener(normalizeEventName(name), attachedEvents[name]); - attachedEvents[name] = null; - } - eventsObject[name] = null; - } - } - function handleSyntheticEvent(name, lastEvent, nextEvent, dom) { - if (isFunction(nextEvent)) { - updateOrAddSyntheticEvent(name, dom)[name] = nextEvent; - } - else if (isLinkEventObject(nextEvent)) { - if (isLastValueSameLinkEvent(lastEvent, nextEvent)) { - return; - } - updateOrAddSyntheticEvent(name, dom)[name] = nextEvent; - } - else { - unmountSyntheticEvent(name, dom); - } - } - // When browsers fully support event.composedPath we could loop it through instead of using parentNode property - function getTargetNode(event) { - return isFunction(event.composedPath) ? event.composedPath()[0] : event.target; - } - function dispatchEvents(event, isClick, name, eventData) { - var dom = getTargetNode(event); - do { - // Html Nodes can be nested fe: span inside button in that scenario browser does not handle disabled attribute on parent, - // because the event listener is on document.body - // Don't process clicks on disabled elements - if (isClick && dom.disabled) { - return; - } - var eventsObject = dom.$EV; - if (eventsObject) { - var currentEvent = eventsObject[name]; - if (currentEvent) { - // linkEvent object - eventData.dom = dom; - currentEvent.event ? currentEvent.event(currentEvent.data, event) : currentEvent(event); - if (event.cancelBubble) { - return; - } - } - } - dom = dom.parentNode; - } while (!isNull(dom)); - } - function stopPropagation() { - this.cancelBubble = true; - if (!this.immediatePropagationStopped) { - this.stopImmediatePropagation(); - } - } - function isDefaultPrevented() { - return this.defaultPrevented; - } - function isPropagationStopped() { - return this.cancelBubble; - } - function extendEventProperties(event) { - // Event data needs to be object to save reference to currentTarget getter - var eventData = { - dom: document - }; - event.isDefaultPrevented = isDefaultPrevented; - event.isPropagationStopped = isPropagationStopped; - event.stopPropagation = stopPropagation; - Object.defineProperty(event, 'currentTarget', { - configurable: true, - get: function get() { - return eventData.dom; - } - }); - return eventData; - } - function rootClickEvent(name) { - return function (event) { - if (event.button !== 0) { - // Firefox incorrectly triggers click event for mid/right mouse buttons. - // This bug has been active for 17 years. - // https://bugzilla.mozilla.org/show_bug.cgi?id=184051 - event.stopPropagation(); - return; - } - dispatchEvents(event, true, name, extendEventProperties(event)); - }; - } - function rootEvent(name) { - return function (event) { - dispatchEvents(event, false, name, extendEventProperties(event)); - }; - } - function attachEventToDocument(name) { - var attachedEvent = name === 'onClick' || name === 'onDblClick' ? rootClickEvent(name) : rootEvent(name); - document.addEventListener(normalizeEventName(name), attachedEvent); - return attachedEvent; - } - - function isSameInnerHTML(dom, innerHTML) { - var tempdom = document.createElement('i'); - tempdom.innerHTML = innerHTML; - return tempdom.innerHTML === dom.innerHTML; - } - - function triggerEventListener(props, methodName, e) { - if (props[methodName]) { - var listener = props[methodName]; - if (listener.event) { - listener.event(listener.data, e); - } - else { - listener(e); - } - } - else { - var nativeListenerName = methodName.toLowerCase(); - if (props[nativeListenerName]) { - props[nativeListenerName](e); - } - } - } - function createWrappedFunction(methodName, applyValue) { - var fnMethod = function (e) { - var vNode = this.$V; - // If vNode is gone by the time event fires, no-op - if (!vNode) { - return; - } - var props = vNode.props || EMPTY_OBJ; - var dom = vNode.dom; - if (isString(methodName)) { - triggerEventListener(props, methodName, e); - } - else { - for (var i = 0; i < methodName.length; ++i) { - triggerEventListener(props, methodName[i], e); - } - } - if (isFunction(applyValue)) { - var newVNode = this.$V; - var newProps = newVNode.props || EMPTY_OBJ; - applyValue(newProps, dom, false, newVNode); - } - }; - Object.defineProperty(fnMethod, 'wrapped', { - configurable: false, - enumerable: false, - value: true, - writable: false - }); - return fnMethod; - } - - function attachEvent(dom, eventName, handler) { - var previousKey = "$" + eventName; - var previousArgs = dom[previousKey]; - if (previousArgs) { - if (previousArgs[1].wrapped) { - return; - } - dom.removeEventListener(previousArgs[0], previousArgs[1]); - dom[previousKey] = null; - } - if (isFunction(handler)) { - dom.addEventListener(eventName, handler); - dom[previousKey] = [eventName, handler]; - } - } - - function isCheckedType(type) { - return type === 'checkbox' || type === 'radio'; - } - var onTextInputChange = createWrappedFunction('onInput', applyValueInput); - var wrappedOnChange = createWrappedFunction(['onClick', 'onChange'], applyValueInput); - /* tslint:disable-next-line:no-empty */ - function emptywrapper(event) { - event.stopPropagation(); - } - emptywrapper.wrapped = true; - function inputEvents(dom, nextPropsOrEmpty) { - if (isCheckedType(nextPropsOrEmpty.type)) { - attachEvent(dom, 'change', wrappedOnChange); - attachEvent(dom, 'click', emptywrapper); - } - else { - attachEvent(dom, 'input', onTextInputChange); - } - } - function applyValueInput(nextPropsOrEmpty, dom) { - var type = nextPropsOrEmpty.type; - var value = nextPropsOrEmpty.value; - var checked = nextPropsOrEmpty.checked; - var multiple = nextPropsOrEmpty.multiple; - var defaultValue = nextPropsOrEmpty.defaultValue; - var hasValue = !isNullOrUndef(value); - if (type && type !== dom.type) { - dom.setAttribute('type', type); - } - if (!isNullOrUndef(multiple) && multiple !== dom.multiple) { - dom.multiple = multiple; - } - if (!isNullOrUndef(defaultValue) && !hasValue) { - dom.defaultValue = defaultValue + ''; - } - if (isCheckedType(type)) { - if (hasValue) { - dom.value = value; - } - if (!isNullOrUndef(checked)) { - dom.checked = checked; - } - } - else { - if (hasValue && dom.value !== value) { - dom.defaultValue = value; - dom.value = value; - } - else if (!isNullOrUndef(checked)) { - dom.checked = checked; - } - } - } - - function updateChildOptions(vNode, value) { - if (vNode.type === 'option') { - updateChildOption(vNode, value); - } - else { - var children = vNode.children; - var flags = vNode.flags; - if (flags & 4 /* ComponentClass */) { - updateChildOptions(children.$LI, value); - } - else if (flags & 8 /* ComponentFunction */) { - updateChildOptions(children, value); - } - else if (vNode.childFlags === 2 /* HasVNodeChildren */) { - updateChildOptions(children, value); - } - else if (vNode.childFlags & 12 /* MultipleChildren */) { - for (var i = 0, len = children.length; i < len; ++i) { - updateChildOptions(children[i], value); - } - } - } - } - function updateChildOption(vNode, value) { - var props = vNode.props || EMPTY_OBJ; - var dom = vNode.dom; - // we do this as multiple may have changed - dom.value = props.value; - if (props.value === value || (isArray(value) && value.indexOf(props.value) !== -1)) { - dom.selected = true; - } - else if (!isNullOrUndef(value) || !isNullOrUndef(props.selected)) { - dom.selected = props.selected || false; - } - } - var onSelectChange = createWrappedFunction('onChange', applyValueSelect); - function selectEvents(dom) { - attachEvent(dom, 'change', onSelectChange); - } - function applyValueSelect(nextPropsOrEmpty, dom, mounting, vNode) { - var multiplePropInBoolean = Boolean(nextPropsOrEmpty.multiple); - if (!isNullOrUndef(nextPropsOrEmpty.multiple) && multiplePropInBoolean !== dom.multiple) { - dom.multiple = multiplePropInBoolean; - } - var index = nextPropsOrEmpty.selectedIndex; - if (index === -1) { - dom.selectedIndex = -1; - } - var childFlags = vNode.childFlags; - if (childFlags !== 1 /* HasInvalidChildren */) { - var value = nextPropsOrEmpty.value; - if (isNumber(index) && index > -1 && dom.options[index]) { - value = dom.options[index].value; - } - if (mounting && isNullOrUndef(value)) { - value = nextPropsOrEmpty.defaultValue; - } - updateChildOptions(vNode, value); - } - } - - var onTextareaInputChange = createWrappedFunction('onInput', applyValueTextArea); - var wrappedOnChange$1 = createWrappedFunction('onChange'); - function textAreaEvents(dom, nextPropsOrEmpty) { - attachEvent(dom, 'input', onTextareaInputChange); - if (nextPropsOrEmpty.onChange) { - attachEvent(dom, 'change', wrappedOnChange$1); - } - } - function applyValueTextArea(nextPropsOrEmpty, dom, mounting) { - var value = nextPropsOrEmpty.value; - var domValue = dom.value; - if (isNullOrUndef(value)) { - if (mounting) { - var defaultValue = nextPropsOrEmpty.defaultValue; - if (!isNullOrUndef(defaultValue) && defaultValue !== domValue) { - dom.defaultValue = defaultValue; - dom.value = defaultValue; - } - } - } - else if (domValue !== value) { - /* There is value so keep it controlled */ - dom.defaultValue = value; - dom.value = value; - } - } - - function processElement(flags, vNode, dom, nextPropsOrEmpty, mounting, isControlled) { - if (flags & 64 /* InputElement */) { - applyValueInput(nextPropsOrEmpty, dom); - } - else if (flags & 256 /* SelectElement */) { - applyValueSelect(nextPropsOrEmpty, dom, mounting, vNode); - } - else if (flags & 128 /* TextareaElement */) { - applyValueTextArea(nextPropsOrEmpty, dom, mounting); - } - if (isControlled) { - dom.$V = vNode; - } - } - function addFormElementEventHandlers(flags, dom, nextPropsOrEmpty) { - if (flags & 64 /* InputElement */) { - inputEvents(dom, nextPropsOrEmpty); - } - else if (flags & 256 /* SelectElement */) { - selectEvents(dom); - } - else if (flags & 128 /* TextareaElement */) { - textAreaEvents(dom, nextPropsOrEmpty); - } - } - function isControlledFormElement(nextPropsOrEmpty) { - return nextPropsOrEmpty.type && isCheckedType(nextPropsOrEmpty.type) ? !isNullOrUndef(nextPropsOrEmpty.checked) : !isNullOrUndef(nextPropsOrEmpty.value); - } - function unmountRef(ref) { - if (ref) { - if (!safeCall1(ref, null) && ref.current) { - ref.current = null; - } - } - } - function mountRef(ref, value, lifecycle) { - if (ref && (isFunction(ref) || ref.current !== void 0)) { - lifecycle.push(function () { - if (!safeCall1(ref, value) && ref.current !== void 0) { - ref.current = value; - } - }); - } - } - - function remove(vNode, parentDOM) { - unmount(vNode); - removeVNodeDOM(vNode, parentDOM); - } - function unmount(vNode) { - var flags = vNode.flags; - var children = vNode.children; - var ref; - if (flags & 481 /* Element */) { - ref = vNode.ref; - var props = vNode.props; - unmountRef(ref); - var childFlags = vNode.childFlags; - if (!isNull(props)) { - var keys = Object.keys(props); - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i]; - if (syntheticEvents[key]) { - unmountSyntheticEvent(key, vNode.dom); - } - } - } - if (childFlags & 12 /* MultipleChildren */) { - unmountAllChildren(children); - } - else if (childFlags === 2 /* HasVNodeChildren */) { - unmount(children); - } - } - else if (children) { - if (flags & 4 /* ComponentClass */) { - if (isFunction(children.componentWillUnmount)) { - children.componentWillUnmount(); - } - unmountRef(vNode.ref); - children.$UN = true; - unmount(children.$LI); - } - else if (flags & 8 /* ComponentFunction */) { - ref = vNode.ref; - if (!isNullOrUndef(ref) && isFunction(ref.onComponentWillUnmount)) { - ref.onComponentWillUnmount(findDOMfromVNode(vNode, true), vNode.props || EMPTY_OBJ); - } - unmount(children); - } - else if (flags & 1024 /* Portal */) { - remove(children, vNode.ref); - } - else if (flags & 8192 /* Fragment */) { - if (vNode.childFlags & 12 /* MultipleChildren */) { - unmountAllChildren(children); - } - } - } - } - function unmountAllChildren(children) { - for (var i = 0, len = children.length; i < len; ++i) { - unmount(children[i]); - } - } - function clearDOM(dom) { - // Optimization for clearing dom - dom.textContent = ''; - } - function removeAllChildren(dom, vNode, children) { - unmountAllChildren(children); - if (vNode.flags & 8192 /* Fragment */) { - removeVNodeDOM(vNode, dom); - } - else { - clearDOM(dom); - } - } - - function wrapLinkEvent(nextValue) { - // This variable makes sure there is no "this" context in callback - var ev = nextValue.event; - return function (e) { - ev(nextValue.data, e); - }; - } - function patchEvent(name, lastValue, nextValue, dom) { - if (isLinkEventObject(nextValue)) { - if (isLastValueSameLinkEvent(lastValue, nextValue)) { - return; - } - nextValue = wrapLinkEvent(nextValue); - } - attachEvent(dom, normalizeEventName(name), nextValue); - } - // We are assuming here that we come from patchProp routine - // -nextAttrValue cannot be null or undefined - function patchStyle(lastAttrValue, nextAttrValue, dom) { - if (isNullOrUndef(nextAttrValue)) { - dom.removeAttribute('style'); - return; - } - var domStyle = dom.style; - var style; - var value; - if (isString(nextAttrValue)) { - domStyle.cssText = nextAttrValue; - return; - } - if (!isNullOrUndef(lastAttrValue) && !isString(lastAttrValue)) { - for (style in nextAttrValue) { - // do not add a hasOwnProperty check here, it affects performance - value = nextAttrValue[style]; - if (value !== lastAttrValue[style]) { - domStyle.setProperty(style, value); - } - } - for (style in lastAttrValue) { - if (isNullOrUndef(nextAttrValue[style])) { - domStyle.removeProperty(style); - } - } - } - else { - for (style in nextAttrValue) { - value = nextAttrValue[style]; - domStyle.setProperty(style, value); - } - } - } - function patchDangerInnerHTML(lastValue, nextValue, lastVNode, dom) { - var lastHtml = (lastValue && lastValue.__html) || ''; - var nextHtml = (nextValue && nextValue.__html) || ''; - if (lastHtml !== nextHtml) { - if (!isNullOrUndef(nextHtml) && !isSameInnerHTML(dom, nextHtml)) { - if (!isNull(lastVNode)) { - if (lastVNode.childFlags & 12 /* MultipleChildren */) { - unmountAllChildren(lastVNode.children); - } - else if (lastVNode.childFlags === 2 /* HasVNodeChildren */) { - unmount(lastVNode.children); - } - lastVNode.children = null; - lastVNode.childFlags = 1 /* HasInvalidChildren */; - } - dom.innerHTML = nextHtml; - } - } - } - function patchProp(prop, lastValue, nextValue, dom, isSVG, hasControlledValue, lastVNode) { - switch (prop) { - case 'children': - case 'childrenType': - case 'className': - case 'defaultValue': - case 'key': - case 'multiple': - case 'ref': - case 'selectedIndex': - break; - case 'autoFocus': - dom.autofocus = !!nextValue; - break; - case 'allowfullscreen': - case 'autoplay': - case 'capture': - case 'checked': - case 'controls': - case 'default': - case 'disabled': - case 'hidden': - case 'indeterminate': - case 'loop': - case 'muted': - case 'novalidate': - case 'open': - case 'readOnly': - case 'required': - case 'reversed': - case 'scoped': - case 'seamless': - case 'selected': - dom[prop] = !!nextValue; - break; - case 'defaultChecked': - case 'value': - case 'volume': - if (hasControlledValue && prop === 'value') { - break; - } - var value = isNullOrUndef(nextValue) ? '' : nextValue; - if (dom[prop] !== value) { - dom[prop] = value; - } - break; - case 'style': - patchStyle(lastValue, nextValue, dom); - break; - case 'dangerouslySetInnerHTML': - patchDangerInnerHTML(lastValue, nextValue, lastVNode, dom); - break; - default: - if (syntheticEvents[prop]) { - handleSyntheticEvent(prop, lastValue, nextValue, dom); - } - else if (prop.charCodeAt(0) === 111 && prop.charCodeAt(1) === 110) { - patchEvent(prop, lastValue, nextValue, dom); - } - else if (isNullOrUndef(nextValue)) { - dom.removeAttribute(prop); - } - else if (isSVG && namespaces[prop]) { - // We optimize for isSVG being false - // If we end up in this path we can read property again - dom.setAttributeNS(namespaces[prop], prop, nextValue); - } - else { - dom.setAttribute(prop, nextValue); - } - break; - } - } - function mountProps(vNode, flags, props, dom, isSVG) { - var hasControlledValue = false; - var isFormElement = (flags & 448 /* FormElement */) > 0; - if (isFormElement) { - hasControlledValue = isControlledFormElement(props); - if (hasControlledValue) { - addFormElementEventHandlers(flags, dom, props); - } - } - for (var prop in props) { - // do not add a hasOwnProperty check here, it affects performance - patchProp(prop, null, props[prop], dom, isSVG, hasControlledValue, null); - } - if (isFormElement) { - processElement(flags, vNode, dom, props, true, hasControlledValue); - } - } - - function renderNewInput(instance, props, context) { - var nextInput = normalizeRoot(instance.render(props, instance.state, context)); - var childContext = context; - if (isFunction(instance.getChildContext)) { - childContext = combineFrom(context, instance.getChildContext()); - } - instance.$CX = childContext; - return nextInput; - } - function createClassComponentInstance(vNode, Component, props, context, isSVG, lifecycle) { - var instance = new Component(props, context); - var usesNewAPI = (instance.$N = Boolean(Component.getDerivedStateFromProps || instance.getSnapshotBeforeUpdate)); - instance.$SVG = isSVG; - instance.$L = lifecycle; - vNode.children = instance; - instance.$BS = false; - instance.context = context; - if (instance.props === EMPTY_OBJ) { - instance.props = props; - } - if (!usesNewAPI) { - if (isFunction(instance.componentWillMount)) { - instance.$BR = true; - instance.componentWillMount(); - var pending = instance.$PS; - if (!isNull(pending)) { - var state = instance.state; - if (isNull(state)) { - instance.state = pending; - } - else { - for (var key in pending) { - state[key] = pending[key]; - } - } - instance.$PS = null; - } - instance.$BR = false; - } - } - else { - instance.state = createDerivedState(instance, props, instance.state); - } - instance.$LI = renderNewInput(instance, props, context); - return instance; - } - function renderFunctionalComponent(vNode, context) { - var props = vNode.props || EMPTY_OBJ; - return vNode.flags & 32768 /* ForwardRef */ ? vNode.type.render(props, vNode.ref, context) : vNode.type(props, context); - } - - function mount(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var flags = (vNode.flags |= 16384 /* InUse */); - if (flags & 481 /* Element */) { - mountElement(vNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (flags & 4 /* ComponentClass */) { - mountClassComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (flags & 8 /* ComponentFunction */) { - mountFunctionalComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle); - mountFunctionalComponentCallbacks(vNode, lifecycle); - } - else if (flags & 512 /* Void */ || flags & 16 /* Text */) { - mountText(vNode, parentDOM, nextNode); - } - else if (flags & 8192 /* Fragment */) { - mountFragment(vNode, context, parentDOM, isSVG, nextNode, lifecycle); - } - else if (flags & 1024 /* Portal */) { - mountPortal(vNode, context, parentDOM, nextNode, lifecycle); - } - else ; - } - function mountPortal(vNode, context, parentDOM, nextNode, lifecycle) { - mount(vNode.children, vNode.ref, context, false, null, lifecycle); - var placeHolderVNode = createVoidVNode(); - mountText(placeHolderVNode, parentDOM, nextNode); - vNode.dom = placeHolderVNode.dom; - } - function mountFragment(vNode, context, parentDOM, isSVG, nextNode, lifecycle) { - var children = vNode.children; - var childFlags = vNode.childFlags; - // When fragment is optimized for multiple children, check if there is no children and change flag to invalid - // This is the only normalization always done, to keep optimization flags API same for fragments and regular elements - if (childFlags & 12 /* MultipleChildren */ && children.length === 0) { - childFlags = vNode.childFlags = 2 /* HasVNodeChildren */; - children = vNode.children = createVoidVNode(); - } - if (childFlags === 2 /* HasVNodeChildren */) { - mount(children, parentDOM, nextNode, isSVG, nextNode, lifecycle); - } - else { - mountArrayChildren(children, parentDOM, context, isSVG, nextNode, lifecycle); - } - } - function mountText(vNode, parentDOM, nextNode) { - var dom = (vNode.dom = document.createTextNode(vNode.children)); - if (!isNull(parentDOM)) { - insertOrAppend(parentDOM, dom, nextNode); - } - } - function mountElement(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var flags = vNode.flags; - var props = vNode.props; - var className = vNode.className; - var childFlags = vNode.childFlags; - var dom = (vNode.dom = documentCreateElement(vNode.type, (isSVG = isSVG || (flags & 32 /* SvgElement */) > 0))); - var children = vNode.children; - if (!isNullOrUndef(className) && className !== '') { - if (isSVG) { - dom.setAttribute('class', className); - } - else { - dom.className = className; - } - } - if (childFlags === 16 /* HasTextChildren */) { - setTextContent(dom, children); - } - else if (childFlags !== 1 /* HasInvalidChildren */) { - var childrenIsSVG = isSVG && vNode.type !== 'foreignObject'; - if (childFlags === 2 /* HasVNodeChildren */) { - if (children.flags & 16384 /* InUse */) { - vNode.children = children = directClone(children); - } - mount(children, dom, context, childrenIsSVG, null, lifecycle); - } - else if (childFlags === 8 /* HasKeyedChildren */ || childFlags === 4 /* HasNonKeyedChildren */) { - mountArrayChildren(children, dom, context, childrenIsSVG, null, lifecycle); - } - } - if (!isNull(parentDOM)) { - insertOrAppend(parentDOM, dom, nextNode); - } - if (!isNull(props)) { - mountProps(vNode, flags, props, dom, isSVG); - } - mountRef(vNode.ref, dom, lifecycle); - } - function mountArrayChildren(children, dom, context, isSVG, nextNode, lifecycle) { - for (var i = 0; i < children.length; ++i) { - var child = children[i]; - if (child.flags & 16384 /* InUse */) { - children[i] = child = directClone(child); - } - mount(child, dom, context, isSVG, nextNode, lifecycle); - } - } - function mountClassComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var instance = createClassComponentInstance(vNode, vNode.type, vNode.props || EMPTY_OBJ, context, isSVG, lifecycle); - mount(instance.$LI, parentDOM, instance.$CX, isSVG, nextNode, lifecycle); - mountClassComponentCallbacks(vNode.ref, instance, lifecycle); - } - function mountFunctionalComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - mount((vNode.children = normalizeRoot(renderFunctionalComponent(vNode, context))), parentDOM, context, isSVG, nextNode, lifecycle); - } - function createClassMountCallback(instance) { - return function () { - instance.componentDidMount(); - }; - } - function mountClassComponentCallbacks(ref, instance, lifecycle) { - mountRef(ref, instance, lifecycle); - if (isFunction(instance.componentDidMount)) { - lifecycle.push(createClassMountCallback(instance)); - } - } - function createOnMountCallback(ref, vNode) { - return function () { - ref.onComponentDidMount(findDOMfromVNode(vNode, true), vNode.props || EMPTY_OBJ); - }; - } - function mountFunctionalComponentCallbacks(vNode, lifecycle) { - var ref = vNode.ref; - if (!isNullOrUndef(ref)) { - safeCall1(ref.onComponentWillMount, vNode.props || EMPTY_OBJ); - if (isFunction(ref.onComponentDidMount)) { - lifecycle.push(createOnMountCallback(ref, vNode)); - } - } - } - - function replaceWithNewNode(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle) { - unmount(lastVNode); - if ((nextVNode.flags & lastVNode.flags & 2033 /* DOMRef */) !== 0) { - mount(nextVNode, null, context, isSVG, null, lifecycle); - // Single DOM operation, when we have dom references available - replaceChild(parentDOM, nextVNode.dom, lastVNode.dom); - } - else { - mount(nextVNode, parentDOM, context, isSVG, findDOMfromVNode(lastVNode, true), lifecycle); - removeVNodeDOM(lastVNode, parentDOM); - } - } - function patch(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var nextFlags = (nextVNode.flags |= 16384 /* InUse */); - if (lastVNode.flags !== nextFlags || lastVNode.type !== nextVNode.type || lastVNode.key !== nextVNode.key || nextFlags & 2048 /* ReCreate */) { - if (lastVNode.flags & 16384 /* InUse */) { - replaceWithNewNode(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle); - } - else { - // Last vNode is not in use, it has crashed at application level. Just mount nextVNode and ignore last one - mount(nextVNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - } - else if (nextFlags & 481 /* Element */) { - patchElement(lastVNode, nextVNode, context, isSVG, nextFlags, lifecycle); - } - else if (nextFlags & 4 /* ComponentClass */) { - patchClassComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (nextFlags & 8 /* ComponentFunction */) { - patchFunctionalComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (nextFlags & 16 /* Text */) { - patchText(lastVNode, nextVNode); - } - else if (nextFlags & 512 /* Void */) { - nextVNode.dom = lastVNode.dom; - } - else if (nextFlags & 8192 /* Fragment */) { - patchFragment(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle); - } - else { - patchPortal(lastVNode, nextVNode, context, lifecycle); - } - } - function patchSingleTextChild(lastChildren, nextChildren, parentDOM) { - if (lastChildren !== nextChildren) { - if (lastChildren !== '') { - parentDOM.firstChild.nodeValue = nextChildren; - } - else { - setTextContent(parentDOM, nextChildren); - } - } - } - function patchContentEditableChildren(dom, nextChildren) { - if (dom.textContent !== nextChildren) { - dom.textContent = nextChildren; - } - } - function patchFragment(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle) { - var lastChildren = lastVNode.children; - var nextChildren = nextVNode.children; - var lastChildFlags = lastVNode.childFlags; - var nextChildFlags = nextVNode.childFlags; - var nextNode = null; - // When fragment is optimized for multiple children, check if there is no children and change flag to invalid - // This is the only normalization always done, to keep optimization flags API same for fragments and regular elements - if (nextChildFlags & 12 /* MultipleChildren */ && nextChildren.length === 0) { - nextChildFlags = nextVNode.childFlags = 2 /* HasVNodeChildren */; - nextChildren = nextVNode.children = createVoidVNode(); - } - var nextIsSingle = (nextChildFlags & 2 /* HasVNodeChildren */) !== 0; - if (lastChildFlags & 12 /* MultipleChildren */) { - var lastLen = lastChildren.length; - // We need to know Fragment's edge node when - if ( - // It uses keyed algorithm - (lastChildFlags & 8 /* HasKeyedChildren */ && nextChildFlags & 8 /* HasKeyedChildren */) || - // It transforms from many to single - nextIsSingle || - // It will append more nodes - (!nextIsSingle && nextChildren.length > lastLen)) { - // When fragment has multiple children there is always at least one vNode - nextNode = findDOMfromVNode(lastChildren[lastLen - 1], false).nextSibling; - } - } - patchChildren(lastChildFlags, nextChildFlags, lastChildren, nextChildren, parentDOM, context, isSVG, nextNode, lastVNode, lifecycle); - } - function patchPortal(lastVNode, nextVNode, context, lifecycle) { - var lastContainer = lastVNode.ref; - var nextContainer = nextVNode.ref; - var nextChildren = nextVNode.children; - patchChildren(lastVNode.childFlags, nextVNode.childFlags, lastVNode.children, nextChildren, lastContainer, context, false, null, lastVNode, lifecycle); - nextVNode.dom = lastVNode.dom; - if (lastContainer !== nextContainer && !isInvalid(nextChildren)) { - var node = nextChildren.dom; - removeChild(lastContainer, node); - appendChild(nextContainer, node); - } - } - function patchElement(lastVNode, nextVNode, context, isSVG, nextFlags, lifecycle) { - var dom = (nextVNode.dom = lastVNode.dom); - var lastProps = lastVNode.props; - var nextProps = nextVNode.props; - var isFormElement = false; - var hasControlledValue = false; - var nextPropsOrEmpty; - isSVG = isSVG || (nextFlags & 32 /* SvgElement */) > 0; - // inlined patchProps -- starts -- - if (lastProps !== nextProps) { - var lastPropsOrEmpty = lastProps || EMPTY_OBJ; - nextPropsOrEmpty = nextProps || EMPTY_OBJ; - if (nextPropsOrEmpty !== EMPTY_OBJ) { - isFormElement = (nextFlags & 448 /* FormElement */) > 0; - if (isFormElement) { - hasControlledValue = isControlledFormElement(nextPropsOrEmpty); - } - for (var prop in nextPropsOrEmpty) { - var lastValue = lastPropsOrEmpty[prop]; - var nextValue = nextPropsOrEmpty[prop]; - if (lastValue !== nextValue) { - patchProp(prop, lastValue, nextValue, dom, isSVG, hasControlledValue, lastVNode); - } - } - } - if (lastPropsOrEmpty !== EMPTY_OBJ) { - for (var prop$1 in lastPropsOrEmpty) { - if (isNullOrUndef(nextPropsOrEmpty[prop$1]) && !isNullOrUndef(lastPropsOrEmpty[prop$1])) { - patchProp(prop$1, lastPropsOrEmpty[prop$1], null, dom, isSVG, hasControlledValue, lastVNode); - } - } - } - } - var nextChildren = nextVNode.children; - var nextClassName = nextVNode.className; - // inlined patchProps -- ends -- - if (lastVNode.className !== nextClassName) { - if (isNullOrUndef(nextClassName)) { - dom.removeAttribute('class'); - } - else if (isSVG) { - dom.setAttribute('class', nextClassName); - } - else { - dom.className = nextClassName; - } - } - if (nextFlags & 4096 /* ContentEditable */) { - patchContentEditableChildren(dom, nextChildren); - } - else { - patchChildren(lastVNode.childFlags, nextVNode.childFlags, lastVNode.children, nextChildren, dom, context, isSVG && nextVNode.type !== 'foreignObject', null, lastVNode, lifecycle); - } - if (isFormElement) { - processElement(nextFlags, nextVNode, dom, nextPropsOrEmpty, false, hasControlledValue); - } - var nextRef = nextVNode.ref; - var lastRef = lastVNode.ref; - if (lastRef !== nextRef) { - unmountRef(lastRef); - mountRef(nextRef, dom, lifecycle); - } - } - function replaceOneVNodeWithMultipleVNodes(lastChildren, nextChildren, parentDOM, context, isSVG, lifecycle) { - unmount(lastChildren); - mountArrayChildren(nextChildren, parentDOM, context, isSVG, findDOMfromVNode(lastChildren, true), lifecycle); - removeVNodeDOM(lastChildren, parentDOM); - } - function patchChildren(lastChildFlags, nextChildFlags, lastChildren, nextChildren, parentDOM, context, isSVG, nextNode, parentVNode, lifecycle) { - switch (lastChildFlags) { - case 2 /* HasVNodeChildren */: - switch (nextChildFlags) { - case 2 /* HasVNodeChildren */: - patch(lastChildren, nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - remove(lastChildren, parentDOM); - break; - case 16 /* HasTextChildren */: - unmount(lastChildren); - setTextContent(parentDOM, nextChildren); - break; - default: - replaceOneVNodeWithMultipleVNodes(lastChildren, nextChildren, parentDOM, context, isSVG, lifecycle); - break; - } - break; - case 1 /* HasInvalidChildren */: - switch (nextChildFlags) { - case 2 /* HasVNodeChildren */: - mount(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - break; - case 16 /* HasTextChildren */: - setTextContent(parentDOM, nextChildren); - break; - default: - mountArrayChildren(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - } - break; - case 16 /* HasTextChildren */: - switch (nextChildFlags) { - case 16 /* HasTextChildren */: - patchSingleTextChild(lastChildren, nextChildren, parentDOM); - break; - case 2 /* HasVNodeChildren */: - clearDOM(parentDOM); - mount(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - clearDOM(parentDOM); - break; - default: - clearDOM(parentDOM); - mountArrayChildren(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - } - break; - default: - switch (nextChildFlags) { - case 16 /* HasTextChildren */: - unmountAllChildren(lastChildren); - setTextContent(parentDOM, nextChildren); - break; - case 2 /* HasVNodeChildren */: - removeAllChildren(parentDOM, parentVNode, lastChildren); - mount(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - removeAllChildren(parentDOM, parentVNode, lastChildren); - break; - default: - var lastLength = lastChildren.length | 0; - var nextLength = nextChildren.length | 0; - // Fast path's for both algorithms - if (lastLength === 0) { - if (nextLength > 0) { - mountArrayChildren(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - } - } - else if (nextLength === 0) { - removeAllChildren(parentDOM, parentVNode, lastChildren); - } - else if (nextChildFlags === 8 /* HasKeyedChildren */ && lastChildFlags === 8 /* HasKeyedChildren */) { - patchKeyedChildren(lastChildren, nextChildren, parentDOM, context, isSVG, lastLength, nextLength, nextNode, parentVNode, lifecycle); - } - else { - patchNonKeyedChildren(lastChildren, nextChildren, parentDOM, context, isSVG, lastLength, nextLength, nextNode, lifecycle); - } - break; - } - break; - } - } - function createDidUpdate(instance, lastProps, lastState, snapshot, lifecycle) { - lifecycle.push(function () { - instance.componentDidUpdate(lastProps, lastState, snapshot); - }); - } - function updateClassComponent(instance, nextState, nextProps, parentDOM, context, isSVG, force, nextNode, lifecycle) { - var lastState = instance.state; - var lastProps = instance.props; - var usesNewAPI = Boolean(instance.$N); - var hasSCU = isFunction(instance.shouldComponentUpdate); - if (usesNewAPI) { - nextState = createDerivedState(instance, nextProps, nextState !== lastState ? combineFrom(lastState, nextState) : nextState); - } - if (force || !hasSCU || (hasSCU && instance.shouldComponentUpdate(nextProps, nextState, context))) { - if (!usesNewAPI && isFunction(instance.componentWillUpdate)) { - instance.componentWillUpdate(nextProps, nextState, context); - } - instance.props = nextProps; - instance.state = nextState; - instance.context = context; - var snapshot = null; - var nextInput = renderNewInput(instance, nextProps, context); - if (usesNewAPI && isFunction(instance.getSnapshotBeforeUpdate)) { - snapshot = instance.getSnapshotBeforeUpdate(lastProps, lastState); - } - patch(instance.$LI, nextInput, parentDOM, instance.$CX, isSVG, nextNode, lifecycle); - // Dont update Last input, until patch has been succesfully executed - instance.$LI = nextInput; - if (isFunction(instance.componentDidUpdate)) { - createDidUpdate(instance, lastProps, lastState, snapshot, lifecycle); - } - } - else { - instance.props = nextProps; - instance.state = nextState; - instance.context = context; - } - } - function patchClassComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var instance = (nextVNode.children = lastVNode.children); - // If Component has crashed, ignore it to stay functional - if (isNull(instance)) { - return; - } - instance.$L = lifecycle; - var nextProps = nextVNode.props || EMPTY_OBJ; - var nextRef = nextVNode.ref; - var lastRef = lastVNode.ref; - var nextState = instance.state; - if (!instance.$N) { - if (isFunction(instance.componentWillReceiveProps)) { - instance.$BR = true; - instance.componentWillReceiveProps(nextProps, context); - // If instance component was removed during its own update do nothing. - if (instance.$UN) { - return; - } - instance.$BR = false; - } - if (!isNull(instance.$PS)) { - nextState = combineFrom(nextState, instance.$PS); - instance.$PS = null; - } - } - updateClassComponent(instance, nextState, nextProps, parentDOM, context, isSVG, false, nextNode, lifecycle); - if (lastRef !== nextRef) { - unmountRef(lastRef); - mountRef(nextRef, instance, lifecycle); - } - } - function patchFunctionalComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var shouldUpdate = true; - var nextProps = nextVNode.props || EMPTY_OBJ; - var nextRef = nextVNode.ref; - var lastProps = lastVNode.props; - var nextHooksDefined = !isNullOrUndef(nextRef); - var lastInput = lastVNode.children; - if (nextHooksDefined && isFunction(nextRef.onComponentShouldUpdate)) { - shouldUpdate = nextRef.onComponentShouldUpdate(lastProps, nextProps); - } - if (shouldUpdate !== false) { - if (nextHooksDefined && isFunction(nextRef.onComponentWillUpdate)) { - nextRef.onComponentWillUpdate(lastProps, nextProps); - } - var nextInput = normalizeRoot(renderFunctionalComponent(nextVNode, context)); - patch(lastInput, nextInput, parentDOM, context, isSVG, nextNode, lifecycle); - nextVNode.children = nextInput; - if (nextHooksDefined && isFunction(nextRef.onComponentDidUpdate)) { - nextRef.onComponentDidUpdate(lastProps, nextProps); - } - } - else { - nextVNode.children = lastInput; - } - } - function patchText(lastVNode, nextVNode) { - var nextText = nextVNode.children; - var dom = (nextVNode.dom = lastVNode.dom); - if (nextText !== lastVNode.children) { - dom.nodeValue = nextText; - } - } - function patchNonKeyedChildren(lastChildren, nextChildren, dom, context, isSVG, lastChildrenLength, nextChildrenLength, nextNode, lifecycle) { - var commonLength = lastChildrenLength > nextChildrenLength ? nextChildrenLength : lastChildrenLength; - var i = 0; - var nextChild; - var lastChild; - for (; i < commonLength; ++i) { - nextChild = nextChildren[i]; - lastChild = lastChildren[i]; - if (nextChild.flags & 16384 /* InUse */) { - nextChild = nextChildren[i] = directClone(nextChild); - } - patch(lastChild, nextChild, dom, context, isSVG, nextNode, lifecycle); - lastChildren[i] = nextChild; - } - if (lastChildrenLength < nextChildrenLength) { - for (i = commonLength; i < nextChildrenLength; ++i) { - nextChild = nextChildren[i]; - if (nextChild.flags & 16384 /* InUse */) { - nextChild = nextChildren[i] = directClone(nextChild); - } - mount(nextChild, dom, context, isSVG, nextNode, lifecycle); - } - } - else if (lastChildrenLength > nextChildrenLength) { - for (i = commonLength; i < lastChildrenLength; ++i) { - remove(lastChildren[i], dom); - } - } - } - function patchKeyedChildren(a, b, dom, context, isSVG, aLength, bLength, outerEdge, parentVNode, lifecycle) { - var aEnd = aLength - 1; - var bEnd = bLength - 1; - var j = 0; - var aNode = a[j]; - var bNode = b[j]; - var nextPos; - var nextNode; - // Step 1 - // tslint:disable-next-line - outer: { - // Sync nodes with the same key at the beginning. - while (aNode.key === bNode.key) { - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - a[j] = bNode; - ++j; - if (j > aEnd || j > bEnd) { - break outer; - } - aNode = a[j]; - bNode = b[j]; - } - aNode = a[aEnd]; - bNode = b[bEnd]; - // Sync nodes with the same key at the end. - while (aNode.key === bNode.key) { - if (bNode.flags & 16384 /* InUse */) { - b[bEnd] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - a[aEnd] = bNode; - aEnd--; - bEnd--; - if (j > aEnd || j > bEnd) { - break outer; - } - aNode = a[aEnd]; - bNode = b[bEnd]; - } - } - if (j > aEnd) { - if (j <= bEnd) { - nextPos = bEnd + 1; - nextNode = nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge; - while (j <= bEnd) { - bNode = b[j]; - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - ++j; - mount(bNode, dom, context, isSVG, nextNode, lifecycle); - } - } - } - else if (j > bEnd) { - while (j <= aEnd) { - remove(a[j++], dom); - } - } - else { - patchKeyedChildrenComplex(a, b, context, aLength, bLength, aEnd, bEnd, j, dom, isSVG, outerEdge, parentVNode, lifecycle); - } - } - function patchKeyedChildrenComplex(a, b, context, aLength, bLength, aEnd, bEnd, j, dom, isSVG, outerEdge, parentVNode, lifecycle) { - var aNode; - var bNode; - var nextPos; - var i = 0; - var aStart = j; - var bStart = j; - var aLeft = aEnd - j + 1; - var bLeft = bEnd - j + 1; - var sources = new Int32Array(bLeft + 1); - // Keep track if its possible to remove whole DOM using textContent = ''; - var canRemoveWholeContent = aLeft === aLength; - var moved = false; - var pos = 0; - var patched = 0; - // When sizes are small, just loop them through - if (bLength < 4 || (aLeft | bLeft) < 32) { - for (i = aStart; i <= aEnd; ++i) { - aNode = a[i]; - if (patched < bLeft) { - for (j = bStart; j <= bEnd; j++) { - bNode = b[j]; - if (aNode.key === bNode.key) { - sources[j - bStart] = i + 1; - if (canRemoveWholeContent) { - canRemoveWholeContent = false; - while (aStart < i) { - remove(a[aStart++], dom); - } - } - if (pos > j) { - moved = true; - } - else { - pos = j; - } - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - ++patched; - break; - } - } - if (!canRemoveWholeContent && j > bEnd) { - remove(aNode, dom); - } - } - else if (!canRemoveWholeContent) { - remove(aNode, dom); - } - } - } - else { - var keyIndex = {}; - // Map keys by their index - for (i = bStart; i <= bEnd; ++i) { - keyIndex[b[i].key] = i; - } - // Try to patch same keys - for (i = aStart; i <= aEnd; ++i) { - aNode = a[i]; - if (patched < bLeft) { - j = keyIndex[aNode.key]; - if (j !== void 0) { - if (canRemoveWholeContent) { - canRemoveWholeContent = false; - while (i > aStart) { - remove(a[aStart++], dom); - } - } - sources[j - bStart] = i + 1; - if (pos > j) { - moved = true; - } - else { - pos = j; - } - bNode = b[j]; - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - ++patched; - } - else if (!canRemoveWholeContent) { - remove(aNode, dom); - } - } - else if (!canRemoveWholeContent) { - remove(aNode, dom); - } - } - } - // fast-path: if nothing patched remove all old and add all new - if (canRemoveWholeContent) { - removeAllChildren(dom, parentVNode, a); - mountArrayChildren(b, dom, context, isSVG, outerEdge, lifecycle); - } - else if (moved) { - var seq = lis_algorithm(sources); - j = seq.length - 1; - for (i = bLeft - 1; i >= 0; i--) { - if (sources[i] === 0) { - pos = i + bStart; - bNode = b[pos]; - if (bNode.flags & 16384 /* InUse */) { - b[pos] = bNode = directClone(bNode); - } - nextPos = pos + 1; - mount(bNode, dom, context, isSVG, nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge, lifecycle); - } - else if (j < 0 || i !== seq[j]) { - pos = i + bStart; - bNode = b[pos]; - nextPos = pos + 1; - moveVNodeDOM(bNode, dom, nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge); - } - else { - j--; - } - } - } - else if (patched !== bLeft) { - // when patched count doesn't match b length we need to insert those new ones - // loop backwards so we can use insertBefore - for (i = bLeft - 1; i >= 0; i--) { - if (sources[i] === 0) { - pos = i + bStart; - bNode = b[pos]; - if (bNode.flags & 16384 /* InUse */) { - b[pos] = bNode = directClone(bNode); - } - nextPos = pos + 1; - mount(bNode, dom, context, isSVG, nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge, lifecycle); - } - } - } - } - var result; - var p; - var maxLen = 0; - // https://en.wikipedia.org/wiki/Longest_increasing_subsequence - function lis_algorithm(arr) { - var arrI = 0; - var i = 0; - var j = 0; - var k = 0; - var u = 0; - var v = 0; - var c = 0; - var len = arr.length; - if (len > maxLen) { - maxLen = len; - result = new Int32Array(len); - p = new Int32Array(len); - } - for (; i < len; ++i) { - arrI = arr[i]; - if (arrI !== 0) { - j = result[k]; - if (arr[j] < arrI) { - p[i] = j; - result[++k] = i; - continue; - } - u = 0; - v = k; - while (u < v) { - c = (u + v) >> 1; - if (arr[result[c]] < arrI) { - u = c + 1; - } - else { - v = c; - } - } - if (arrI < arr[result[u]]) { - if (u > 0) { - p[i] = result[u - 1]; - } - result[u] = i; - } - } - } - u = k + 1; - var seq = new Int32Array(u); - v = result[u - 1]; - while (u-- > 0) { - seq[u] = v; - v = p[v]; - result[u] = 0; - } - return seq; - } - - var hasDocumentAvailable = typeof document !== 'undefined'; - if (hasDocumentAvailable) { - /* - * Defining $EV and $V properties on Node.prototype - * fixes v8 "wrong map" de-optimization - */ - if (window.Node) { - Node.prototype.$EV = null; - Node.prototype.$V = null; - } - } - function __render(input, parentDOM, callback, context) { - var lifecycle = []; - var rootInput = parentDOM.$V; - if (isNullOrUndef(rootInput)) { - if (!isNullOrUndef(input)) { - if (input.flags & 16384 /* InUse */) { - input = directClone(input); - } - mount(input, parentDOM, context, false, null, lifecycle); - parentDOM.$V = input; - rootInput = input; - } - } - else { - if (isNullOrUndef(input)) { - remove(rootInput, parentDOM); - parentDOM.$V = null; - } - else { - if (input.flags & 16384 /* InUse */) { - input = directClone(input); - } - patch(rootInput, input, parentDOM, context, false, null, lifecycle); - rootInput = parentDOM.$V = input; - } - } - callAll(lifecycle); - if (isFunction(callback)) { - callback(); - } - if (isFunction(options.renderComplete)) { - options.renderComplete(rootInput, parentDOM); - } - } - function render(input, parentDOM, callback, context) { - if ( callback === void 0 ) callback = null; - if ( context === void 0 ) context = EMPTY_OBJ; - - __render(input, parentDOM, callback, context); - } - typeof Promise !== 'undefined' - ? Promise.resolve().then.bind(Promise.resolve()) - : function (a) { - window.setTimeout(a, 0); - }; - - var version = "7.4.8"; - - /* - * The purpose of this benchmark is to test performance regressions in normalization process. - * This benchmark is slow intentionally. There are nested arrays and other "bad code". - */ - - uibench.init('Inferno (normalization test)', version); - - function TreeLeaf(_ref) { - var children = _ref.children; - return createVNode(1, "li", "TreeLeaf", children, 0, null, null, null); - } - - function shouldDataUpdate(lastProps, nextProps) { - return lastProps !== nextProps; - } - - function TreeNode(_ref2) { - var data = _ref2.data; - var length = data.children.length; - var children = new Array(length); - - for (var i = 0; i < length; i++) { - var n = data.children[i]; - var id = n.id; - - if (n.container) { - children[i] = createComponentVNode(2, TreeNode, { - "data": n - }, id, { - "onComponentShouldUpdate": shouldDataUpdate - }); - } else { - children[i] = createComponentVNode(2, TreeLeaf, { - children: id - }, id, { - "onComponentShouldUpdate": shouldDataUpdate - }); - } - } - - return createVNode(1, "ul", "TreeNode", children, 0, null, null, null); - } - - function tree(data) { - return createVNode(1, "div", "Tree", createComponentVNode(2, TreeNode, { - "data": data.root - }, null, { - "onComponentShouldUpdate": shouldDataUpdate - }), 2, null, null, null); - } - - function AnimBox(_ref3) { - var data = _ref3.data; - var time = data.time % 10; - var style = 'border-radius:' + time + 'px;' + 'background:rgba(0,0,0,' + (0.5 + time / 10) + ')'; - return createVNode(1, "div", "AnimBox", null, 1, { - "data-id": data.id, - "style": style - }, null, null); - } - - function anim(data) { - var items = data.items; - var length = items.length; - var children = new Array(length); - - for (var i = 0; i < length; i++) { - var item = items[i]; // Here we are using onComponentShouldUpdate functional Component hook, to short circuit rendering process of AnimBox Component - // When the data does not change - - children[i] = createComponentVNode(2, AnimBox, { - "data": item - }, item.id, { - "onComponentShouldUpdate": shouldDataUpdate - }); - } - - return createVNode(1, "div", "Anim", children, 0, null, null, null); - } - - function onClick(text, e) { - console.log('Clicked', text); - e.stopPropagation(); - } - - function TableCell(_ref4) { - var children = _ref4.children; - - /* - * The carbage code is intentional - */ - return createVNode(1, "td", "TableCell", [null, false, [children]], 0, { - "onClick": linkEvent(children, onClick) - }, null, null); - } - - function TableRow(_ref5) { - var data = _ref5.data; - var classes = 'TableRow'; - - if (data.active) { - classes = 'TableRow active'; - } - - var cells = data.props; - var length = cells.length + 1; - var children = new Array(length); - children[0] = createComponentVNode(2, TableCell, { - children: '#' + data.id - }, null, { - "onComponentShouldUpdate": shouldDataUpdate - }); - - for (var i = 1; i < length; i++) { - children[i] = createComponentVNode(2, TableCell, { - children: cells[i - 1] - }, null, { - "onComponentShouldUpdate": shouldDataUpdate - }); - } - /* - * The carbage code is intentional - */ - - - return createVNode(1, "tr", classes, [null, children, false], 0, { - "data-id": data.id - }, null, null); - } - - function table(data) { - var items = data.items; - var length = items.length; - var children = new Array(length); - - for (var i = 0; i < length; i++) { - var item = items[i]; - children[i] = createComponentVNode(2, TableRow, { - "data": item, - children: item - }, item.id, { - "onComponentShouldUpdate": shouldDataUpdate - }); - } - /* - * The carbage code is intentional - */ - - - return createVNode(1, "table", "Table", [[], children, [[]]], 0, null, null, null); - } - - function main(data) { - var location = data.location; - var section; - - if (location === 'table') { - section = table(data.table); - } else if (location === 'anim') { - section = anim(data.anim); - } else if (location === 'tree') { - section = tree(data.tree); - } - - return createVNode(1, "div", "Main", section, 0, null, null, null); - } - - document.addEventListener('DOMContentLoaded', function (e) { - var container = document.querySelector('#App'); - uibench.run(function (state) { - render(main(state), container); - }, function (samples) { - render(createVNode(1, "pre", null, JSON.stringify(samples, null, ' '), 0, null, null, null), container); - }); - }); - -}()); +!function(){"use strict";var e=Array.isArray;function n(e){var n=typeof e;return"string"===n||"number"===n}function t(e){return void 0===e||null===e}function r(e){return null===e||!1===e||!0===e||void 0===e}function l(e){return"function"===typeof e}function o(e){return"string"===typeof e}function i(e){return null===e}function a(e,n){var t={};if(e)for(var r in e)t[r]=e[r];if(n)for(var l in n)t[l]=n[l];return t}function u(e,n){if(l(n))return{data:e,event:n};return null}function c(e){return!i(e)&&"object"===typeof e}var f={};function s(e){return e.substr(2).toLowerCase()}function d(e,n){e.appendChild(n)}function p(e,n,t){i(t)?d(e,n):e.insertBefore(n,t)}function v(e,n){if(n)return document.createElementNS("http://www.w3.org/2000/svg",e);return document.createElement(e)}function h(e,n,t){e.replaceChild(n,t)}function m(e,n){e.removeChild(n)}function g(e){for(var n=0;n0,v=i(d),h=o(d)&&d[0]===U;p||v||h?(a=a||l.slice(0,f),(p||h)&&(s=E(s)),(v||h)&&(s.key=U+f),a.push(s)):a&&a.push(s),s.flags|=65536}}u=0===(a=a||l).length?1:8}else(a=l).flags|=65536,81920&l.flags&&(a=E(l)),u=2;return t.children=a,t.childFlags=u,t}function j(t){if(r(t)||n(t))return T(t,null);if(e(t))return D(t,0,null);return 16384&t.flags?E(t):t}var H="http://www.w3.org/1999/xlink",X="http://www.w3.org/XML/1998/namespace",_={"xlink:actuate":H,"xlink:arcrole":H,"xlink:href":H,"xlink:role":H,"xlink:show":H,"xlink:title":H,"xlink:type":H,"xml:base":X,"xml:lang":X,"xml:space":X};function K(e){return{onClick:e,onDblClick:e,onFocusIn:e,onFocusOut:e,onKeyDown:e,onKeyPress:e,onKeyUp:e,onMouseDown:e,onMouseMove:e,onMouseUp:e,onTouchEnd:e,onTouchMove:e,onTouchStart:e}}var q=K(0),z=K(null),G=K(!0);function J(e,n){var t=n.$EV;return t||(t=n.$EV=K(null)),t[e]||1===++q[e]&&(z[e]=ae(e)),t}function Q(e,n){var t=n.$EV;t&&t[e]&&(0===--q[e]&&(document.removeEventListener(s(e),z[e]),z[e]=null),t[e]=null)}function Y(e,n,t,r){if(l(t))J(e,r)[e]=t;else if(c(t)){if(P(n,t))return;J(e,r)[e]=t}else Q(e,r)}function Z(e){return l(e.composedPath)?e.composedPath()[0]:e.target}function ee(e,n,t,r){var l=Z(e);do{if(n&&l.disabled)return;var o=l.$EV;if(o){var a=o[t];if(a&&(r.dom=l,a.event?a.event(a.data,e):a(e),e.cancelBubble))return}l=l.parentNode}while(!i(l))}function ne(){this.cancelBubble=!0,this.immediatePropagationStopped||this.stopImmediatePropagation()}function te(){return this.defaultPrevented}function re(){return this.cancelBubble}function le(e){var n={dom:document};return e.isDefaultPrevented=te,e.isPropagationStopped=re,e.stopPropagation=ne,Object.defineProperty(e,"currentTarget",{configurable:!0,get:function(){return n.dom}}),n}function oe(e){return function(n){if(0!==n.button)return void n.stopPropagation();ee(n,!0,e,le(n))}}function ie(e){return function(n){ee(n,!1,e,le(n))}}function ae(e){var n="onClick"===e||"onDblClick"===e?oe(e):ie(e);return document.addEventListener(s(e),n),n}function ue(e,n){var t=document.createElement("i");return t.innerHTML=n,t.innerHTML===e.innerHTML}function ce(e,n,t){if(e[n]){var r=e[n];r.event?r.event(r.data,t):r(t)}else{var l=n.toLowerCase();e[l]&&e[l](t)}}function fe(e,n){var t=function(t){var r=this.$V;if(!r)return;var i=r.props||f,a=r.dom;if(o(e))ce(i,e,t);else for(var u=0;u-1&&n.options[i]&&(a=n.options[i].value),r&&t(a)&&(a=e.defaultValue),ye(l,a)}}var $e,Fe,Pe=fe("onInput",Ue),Se=fe("onChange");function xe(e,n){se(e,"input",Pe),n.onChange&&se(e,"change",Se)}function Ue(e,n,r){var l=e.value,o=n.value;if(t(l)){if(r){var i=e.defaultValue;t(i)||i===o||(n.defaultValue=i,n.value=i)}}else o!==l&&(n.defaultValue=l,n.value=l)}function Le(e,n,t,r,l,o){64&e?ge(r,t):256&e?we(r,t,l,n):128&e&&Ue(r,t,l),o&&(t.$V=n)}function Ve(e,n,t){64&e?me(n,t):256&e?Ce(n):128&e&&xe(n,t)}function Ae(e){return e.type&&de(e.type)?!t(e.checked):!t(e.value)}function Ne(e){e&&!x(e,null)&&e.current&&(e.current=null)}function Ie(e,n,t){e&&(l(e)||void 0!==e.current)&&t.push((function(){x(e,n)||void 0===e.current||(e.current=n)}))}function Me(e,n){Te(e),k(e,n)}function Te(e){var n,r=e.flags,o=e.children;if(481&r){n=e.ref;var a=e.props;Ne(n);var u=e.childFlags;if(!i(a))for(var c=Object.keys(a),s=0,d=c.length;s0;for(var a in i&&(o=Ae(t))&&Ve(n,r,t),t)He(a,null,t[a],r,l,o,null);i&&Le(n,e,r,t,!0,o)}function _e(e,n,t){var r=j(e.render(n,e.state,t)),o=t;return l(e.getChildContext)&&(o=a(t,e.getChildContext())),e.$CX=o,r}function Ke(e,n,t,r,o,a){var u=new n(t,r),c=u.$N=Boolean(n.getDerivedStateFromProps||u.getSnapshotBeforeUpdate);if(u.$SVG=o,u.$L=a,e.children=u,u.$BS=!1,u.context=r,u.props===f&&(u.props=t),c)u.state=w(u,t,u.state);else if(l(u.componentWillMount)){u.$BR=!0,u.componentWillMount();var s=u.$PS;if(!i(s)){var d=u.state;if(i(d))u.state=s;else for(var p in s)d[p]=s[p];u.$PS=null}u.$BR=!1}return u.$LI=_e(u,t,r),u}function qe(e,n){var t=e.props||f;return 32768&e.flags?e.type.render(t,e.ref,n):e.type(t,n)}function ze(e,n,t,r,l,o){var i=e.flags|=16384;481&i?Ye(e,n,t,r,l,o):4&i?en(e,n,t,r,l,o):8&i?(nn(e,n,t,r,l,o),on(e,o)):512&i||16&i?Qe(e,n,l):8192&i?Je(e,t,n,r,l,o):1024&i&&Ge(e,t,n,l,o)}function Ge(e,n,t,r,l){ze(e.children,e.ref,n,!1,null,l);var o=W();Qe(o,t,r),e.dom=o.dom}function Je(e,n,t,r,l,o){var i=e.children,a=e.childFlags;12&a&&0===i.length&&(a=e.childFlags=2,i=e.children=W()),2===a?ze(i,t,l,r,l,o):Ze(i,t,n,r,l,o)}function Qe(e,n,t){var r=e.dom=document.createTextNode(e.children);i(n)||p(n,r,t)}function Ye(e,n,r,l,o,a){var u=e.flags,c=e.props,f=e.className,s=e.childFlags,d=e.dom=v(e.type,l=l||(32&u)>0),h=e.children;if(t(f)||""===f||(l?d.setAttribute("class",f):d.className=f),16===s)F(d,h);else if(1!==s){var m=l&&"foreignObject"!==e.type;2===s?(16384&h.flags&&(e.children=h=E(h)),ze(h,d,r,m,null,a)):8!==s&&4!==s||Ze(h,d,r,m,null,a)}i(n)||p(n,d,o),i(c)||Xe(e,u,c,d,l),Ie(e.ref,d,a)}function Ze(e,n,t,r,l,o){for(var i=0;id)&&(f=b(i[d-1],!1).nextSibling)}hn(u,c,i,a,t,r,l,f,e,o)}function dn(e,n,t,l){var o=e.ref,i=n.ref,a=n.children;if(hn(e.childFlags,n.childFlags,e.children,a,o,t,!1,null,e,l),n.dom=e.dom,o!==i&&!r(a)){var u=a.dom;m(o,u),d(i,u)}}function pn(e,n,r,l,o,i){var a,u=n.dom=e.dom,c=e.props,s=n.props,d=!1,p=!1;if(l=l||(32&o)>0,c!==s){var v=c||f;if((a=s||f)!==f)for(var h in(d=(448&o)>0)&&(p=Ae(a)),a){var m=v[h],g=a[h];m!==g&&He(h,m,g,u,l,p,e)}if(v!==f)for(var y in v)t(a[y])&&!t(v[y])&&He(y,v[y],null,u,l,p,e)}var b=n.children,k=n.className;e.className!==k&&(t(k)?u.removeAttribute("class"):l?u.setAttribute("class",k):u.className=k),4096&o?fn(u,b):hn(e.childFlags,n.childFlags,e.children,b,u,r,l&&"foreignObject"!==n.type,null,e,i),d&&Le(o,n,u,a,!1,p);var C=n.ref,w=e.ref;w!==C&&(Ne(w),Ie(C,u,i))}function vn(e,n,t,r,l,o){Te(e),Ze(n,t,r,l,b(e,!0),o),k(e,t)}function hn(e,n,t,r,l,o,i,a,u,c){switch(e){case 2:switch(n){case 2:un(t,r,l,o,i,a,c);break;case 1:Me(t,l);break;case 16:Te(t),F(l,r);break;default:vn(t,r,l,o,i,c)}break;case 1:switch(n){case 2:ze(r,l,o,i,a,c);break;case 1:break;case 16:F(l,r);break;default:Ze(r,l,o,i,a,c)}break;case 16:switch(n){case 16:cn(t,r,l);break;case 2:Be(l),ze(r,l,o,i,a,c);break;case 1:Be(l);break;default:Be(l),Ze(r,l,o,i,a,c)}break;default:switch(n){case 16:De(t),F(l,r);break;case 2:Ee(l,u,t),ze(r,l,o,i,a,c);break;case 1:Ee(l,u,t);break;default:var f=0|t.length,s=0|r.length;0===f?s>0&&Ze(r,l,o,i,a,c):0===s?Ee(l,u,t):8===n&&8===e?wn(t,r,l,o,i,f,s,a,u,c):Cn(t,r,l,o,i,f,s,a,c)}}}function mn(e,n,t,r,l){l.push((function(){e.componentDidUpdate(n,t,r)}))}function gn(e,n,t,r,o,i,u,c,f){var s=e.state,d=e.props,p=Boolean(e.$N),v=l(e.shouldComponentUpdate);if(p&&(n=w(e,t,n!==s?a(s,n):n)),u||!v||v&&e.shouldComponentUpdate(t,n,o)){!p&&l(e.componentWillUpdate)&&e.componentWillUpdate(t,n,o),e.props=t,e.state=n,e.context=o;var h=null,m=_e(e,t,o);p&&l(e.getSnapshotBeforeUpdate)&&(h=e.getSnapshotBeforeUpdate(d,s)),un(e.$LI,m,r,e.$CX,i,c,f),e.$LI=m,l(e.componentDidUpdate)&&mn(e,d,s,h,f)}else e.props=t,e.state=n,e.context=o}function yn(e,n,t,r,o,u,c){var s=n.children=e.children;if(i(s))return;s.$L=c;var d=n.props||f,p=n.ref,v=e.ref,h=s.state;if(!s.$N){if(l(s.componentWillReceiveProps)){if(s.$BR=!0,s.componentWillReceiveProps(d,r),s.$UN)return;s.$BR=!1}i(s.$PS)||(h=a(h,s.$PS),s.$PS=null)}gn(s,h,d,t,r,o,!1,u,c),v!==p&&(Ne(v),Ie(p,s,c))}function bn(e,n,r,o,i,a,u){var c=!0,s=n.props||f,d=n.ref,p=e.props,v=!t(d),h=e.children;if(v&&l(d.onComponentShouldUpdate)&&(c=d.onComponentShouldUpdate(p,s)),!1!==c){v&&l(d.onComponentWillUpdate)&&d.onComponentWillUpdate(p,s);var m=j(qe(n,o));un(h,m,r,o,i,a,u),n.children=m,v&&l(d.onComponentDidUpdate)&&d.onComponentDidUpdate(p,s)}else n.children=h}function kn(e,n){var t=n.children,r=n.dom=e.dom;t!==e.children&&(r.nodeValue=t)}function Cn(e,n,t,r,l,o,i,a,u){for(var c,f,s=o>i?i:o,d=0;di)for(d=s;dd||v>p)break e;h=e[v],m=n[v]}for(h=e[d],m=n[p];h.key===m.key;){if(16384&m.flags&&(n[p]=m=E(m)),un(h,m,t,r,l,a,c),e[d]=m,p--,v>--d||v>p)break e;h=e[d],m=n[p]}}if(v>d){if(v<=p)for(s=(f=p+1)p)for(;v<=d;)Me(e[v++],t);else $n(e,n,r,o,i,d,p,v,t,l,a,u,c)}function $n(e,n,t,r,l,o,i,a,u,c,f,s,d){var p,v,h,m=0,g=a,y=a,k=o-a+1,w=i-a+1,$=new Int32Array(w+1),F=k===r,P=!1,S=0,x=0;if(l<4||(k|w)<32)for(m=g;m<=o;++m)if(p=e[m],xa?P=!0:S=a,16384&v.flags&&(n[a]=v=E(v)),un(p,v,u,t,c,f,d),++x;break}!F&&a>i&&Me(p,u)}else F||Me(p,u);else{var U={};for(m=y;m<=i;++m)U[n[m].key]=m;for(m=g;m<=o;++m)if(p=e[m],xg;)Me(e[g++],u);$[a-y]=m+1,S>a?P=!0:S=a,16384&(v=n[a]).flags&&(n[a]=v=E(v)),un(p,v,u,t,c,f,d),++x}else F||Me(p,u);else F||Me(p,u)}if(F)Ee(u,s,e),Ze(n,u,t,c,f,d);else if(P){var L=Pn($);for(a=L.length-1,m=w-1;m>=0;m--)0===$[m]?(16384&(v=n[S=m+y]).flags&&(n[S]=v=E(v)),ze(v,u,t,c,(h=S+1)=0;m--)0===$[m]&&(16384&(v=n[S=m+y]).flags&&(n[S]=v=E(v)),ze(v,u,t,c,(h=S+1)Fn&&(Fn=u,$e=new Int32Array(u),Fe=new Int32Array(u));t>1]]0&&(Fe[t]=$e[o-1]),$e[o]=t)}o=l+1;var c=new Int32Array(o);for(i=$e[o-1];o-- >0;)c[o]=i,i=Fe[i],$e[o]=0;return c}function Sn(e,n,r,o){var i=[],a=n.$V;t(a)?t(e)||(16384&e.flags&&(e=E(e)),ze(e,n,o,!1,null,i),n.$V=e,a=e):t(e)?(Me(a,n),n.$V=null):(16384&e.flags&&(e=E(e)),un(a,e,n,o,!1,null,i),a=n.$V=e),g(i),l(r)&&r(),l($.renderComplete)&&$.renderComplete(a,n)}function xn(e,n,t,r){void 0===t&&(t=null),void 0===r&&(r=f),Sn(e,n,t,r)}function Un(e){return V(1,"li","TreeLeaf",e.children,0,null,null,null)}function Ln(e,n){return e!==n}function Vn(e){for(var n=e.data,t=n.children.length,r=new Array(t),l=0;l 0; - var isNullKey = isNull(key); - var isPrefixed = isString(key) && key[0] === keyPrefix; - if (needsCloning || isNullKey || isPrefixed) { - newChildren = newChildren || children.slice(0, i); - if (needsCloning || isPrefixed) { - n = directClone(n); - } - if (isNullKey || isPrefixed) { - n.key = keyPrefix + i; - } - newChildren.push(n); - } - else if (newChildren) { - newChildren.push(n); - } - n.flags |= 65536 /* Normalized */; - } - } - newChildren = newChildren || children; - if (newChildren.length === 0) { - newChildFlags = 1 /* HasInvalidChildren */; - } - else { - newChildFlags = 8 /* HasKeyedChildren */; - } - } - else { - newChildren = children; - newChildren.flags |= 65536 /* Normalized */; - if (children.flags & 81920 /* InUseOrNormalized */) { - newChildren = directClone(children); - } - newChildFlags = 2 /* HasVNodeChildren */; - } - vNode.children = newChildren; - vNode.childFlags = newChildFlags; - return vNode; - } - function normalizeRoot(input) { - if (isInvalid(input) || isStringOrNumber(input)) { - return createTextVNode(input, null); - } - if (isArray(input)) { - return createFragment(input, 0 /* UnknownChildren */, null); - } - return input.flags & 16384 /* InUse */ ? directClone(input) : input; - } - - var xlinkNS = 'http://www.w3.org/1999/xlink'; - var xmlNS = 'http://www.w3.org/XML/1998/namespace'; - var namespaces = { - 'xlink:actuate': xlinkNS, - 'xlink:arcrole': xlinkNS, - 'xlink:href': xlinkNS, - 'xlink:role': xlinkNS, - 'xlink:show': xlinkNS, - 'xlink:title': xlinkNS, - 'xlink:type': xlinkNS, - 'xml:base': xmlNS, - 'xml:lang': xmlNS, - 'xml:space': xmlNS - }; - - function getDelegatedEventObject(v) { - return { - onClick: v, - onDblClick: v, - onFocusIn: v, - onFocusOut: v, - onKeyDown: v, - onKeyPress: v, - onKeyUp: v, - onMouseDown: v, - onMouseMove: v, - onMouseUp: v, - onTouchEnd: v, - onTouchMove: v, - onTouchStart: v - }; - } - var attachedEventCounts = getDelegatedEventObject(0); - var attachedEvents = getDelegatedEventObject(null); - var syntheticEvents = getDelegatedEventObject(true); - function updateOrAddSyntheticEvent(name, dom) { - var eventsObject = dom.$EV; - if (!eventsObject) { - eventsObject = dom.$EV = getDelegatedEventObject(null); - } - if (!eventsObject[name]) { - if (++attachedEventCounts[name] === 1) { - attachedEvents[name] = attachEventToDocument(name); - } - } - return eventsObject; - } - function unmountSyntheticEvent(name, dom) { - var eventsObject = dom.$EV; - if (eventsObject && eventsObject[name]) { - if (--attachedEventCounts[name] === 0) { - document.removeEventListener(normalizeEventName(name), attachedEvents[name]); - attachedEvents[name] = null; - } - eventsObject[name] = null; - } - } - function handleSyntheticEvent(name, lastEvent, nextEvent, dom) { - if (isFunction(nextEvent)) { - updateOrAddSyntheticEvent(name, dom)[name] = nextEvent; - } - else if (isLinkEventObject(nextEvent)) { - if (isLastValueSameLinkEvent(lastEvent, nextEvent)) { - return; - } - updateOrAddSyntheticEvent(name, dom)[name] = nextEvent; - } - else { - unmountSyntheticEvent(name, dom); - } - } - // When browsers fully support event.composedPath we could loop it through instead of using parentNode property - function getTargetNode(event) { - return isFunction(event.composedPath) ? event.composedPath()[0] : event.target; - } - function dispatchEvents(event, isClick, name, eventData) { - var dom = getTargetNode(event); - do { - // Html Nodes can be nested fe: span inside button in that scenario browser does not handle disabled attribute on parent, - // because the event listener is on document.body - // Don't process clicks on disabled elements - if (isClick && dom.disabled) { - return; - } - var eventsObject = dom.$EV; - if (eventsObject) { - var currentEvent = eventsObject[name]; - if (currentEvent) { - // linkEvent object - eventData.dom = dom; - currentEvent.event ? currentEvent.event(currentEvent.data, event) : currentEvent(event); - if (event.cancelBubble) { - return; - } - } - } - dom = dom.parentNode; - } while (!isNull(dom)); - } - function stopPropagation() { - this.cancelBubble = true; - if (!this.immediatePropagationStopped) { - this.stopImmediatePropagation(); - } - } - function isDefaultPrevented() { - return this.defaultPrevented; - } - function isPropagationStopped() { - return this.cancelBubble; - } - function extendEventProperties(event) { - // Event data needs to be object to save reference to currentTarget getter - var eventData = { - dom: document - }; - event.isDefaultPrevented = isDefaultPrevented; - event.isPropagationStopped = isPropagationStopped; - event.stopPropagation = stopPropagation; - Object.defineProperty(event, 'currentTarget', { - configurable: true, - get: function get() { - return eventData.dom; - } - }); - return eventData; - } - function rootClickEvent(name) { - return function (event) { - if (event.button !== 0) { - // Firefox incorrectly triggers click event for mid/right mouse buttons. - // This bug has been active for 17 years. - // https://bugzilla.mozilla.org/show_bug.cgi?id=184051 - event.stopPropagation(); - return; - } - dispatchEvents(event, true, name, extendEventProperties(event)); - }; - } - function rootEvent(name) { - return function (event) { - dispatchEvents(event, false, name, extendEventProperties(event)); - }; - } - function attachEventToDocument(name) { - var attachedEvent = name === 'onClick' || name === 'onDblClick' ? rootClickEvent(name) : rootEvent(name); - document.addEventListener(normalizeEventName(name), attachedEvent); - return attachedEvent; - } - - function isSameInnerHTML(dom, innerHTML) { - var tempdom = document.createElement('i'); - tempdom.innerHTML = innerHTML; - return tempdom.innerHTML === dom.innerHTML; - } - - function triggerEventListener(props, methodName, e) { - if (props[methodName]) { - var listener = props[methodName]; - if (listener.event) { - listener.event(listener.data, e); - } - else { - listener(e); - } - } - else { - var nativeListenerName = methodName.toLowerCase(); - if (props[nativeListenerName]) { - props[nativeListenerName](e); - } - } - } - function createWrappedFunction(methodName, applyValue) { - var fnMethod = function (e) { - var vNode = this.$V; - // If vNode is gone by the time event fires, no-op - if (!vNode) { - return; - } - var props = vNode.props || EMPTY_OBJ; - var dom = vNode.dom; - if (isString(methodName)) { - triggerEventListener(props, methodName, e); - } - else { - for (var i = 0; i < methodName.length; ++i) { - triggerEventListener(props, methodName[i], e); - } - } - if (isFunction(applyValue)) { - var newVNode = this.$V; - var newProps = newVNode.props || EMPTY_OBJ; - applyValue(newProps, dom, false, newVNode); - } - }; - Object.defineProperty(fnMethod, 'wrapped', { - configurable: false, - enumerable: false, - value: true, - writable: false - }); - return fnMethod; - } - - function attachEvent(dom, eventName, handler) { - var previousKey = "$" + eventName; - var previousArgs = dom[previousKey]; - if (previousArgs) { - if (previousArgs[1].wrapped) { - return; - } - dom.removeEventListener(previousArgs[0], previousArgs[1]); - dom[previousKey] = null; - } - if (isFunction(handler)) { - dom.addEventListener(eventName, handler); - dom[previousKey] = [eventName, handler]; - } - } - - function isCheckedType(type) { - return type === 'checkbox' || type === 'radio'; - } - var onTextInputChange = createWrappedFunction('onInput', applyValueInput); - var wrappedOnChange = createWrappedFunction(['onClick', 'onChange'], applyValueInput); - /* tslint:disable-next-line:no-empty */ - function emptywrapper(event) { - event.stopPropagation(); - } - emptywrapper.wrapped = true; - function inputEvents(dom, nextPropsOrEmpty) { - if (isCheckedType(nextPropsOrEmpty.type)) { - attachEvent(dom, 'change', wrappedOnChange); - attachEvent(dom, 'click', emptywrapper); - } - else { - attachEvent(dom, 'input', onTextInputChange); - } - } - function applyValueInput(nextPropsOrEmpty, dom) { - var type = nextPropsOrEmpty.type; - var value = nextPropsOrEmpty.value; - var checked = nextPropsOrEmpty.checked; - var multiple = nextPropsOrEmpty.multiple; - var defaultValue = nextPropsOrEmpty.defaultValue; - var hasValue = !isNullOrUndef(value); - if (type && type !== dom.type) { - dom.setAttribute('type', type); - } - if (!isNullOrUndef(multiple) && multiple !== dom.multiple) { - dom.multiple = multiple; - } - if (!isNullOrUndef(defaultValue) && !hasValue) { - dom.defaultValue = defaultValue + ''; - } - if (isCheckedType(type)) { - if (hasValue) { - dom.value = value; - } - if (!isNullOrUndef(checked)) { - dom.checked = checked; - } - } - else { - if (hasValue && dom.value !== value) { - dom.defaultValue = value; - dom.value = value; - } - else if (!isNullOrUndef(checked)) { - dom.checked = checked; - } - } - } - - function updateChildOptions(vNode, value) { - if (vNode.type === 'option') { - updateChildOption(vNode, value); - } - else { - var children = vNode.children; - var flags = vNode.flags; - if (flags & 4 /* ComponentClass */) { - updateChildOptions(children.$LI, value); - } - else if (flags & 8 /* ComponentFunction */) { - updateChildOptions(children, value); - } - else if (vNode.childFlags === 2 /* HasVNodeChildren */) { - updateChildOptions(children, value); - } - else if (vNode.childFlags & 12 /* MultipleChildren */) { - for (var i = 0, len = children.length; i < len; ++i) { - updateChildOptions(children[i], value); - } - } - } - } - function updateChildOption(vNode, value) { - var props = vNode.props || EMPTY_OBJ; - var dom = vNode.dom; - // we do this as multiple may have changed - dom.value = props.value; - if (props.value === value || (isArray(value) && value.indexOf(props.value) !== -1)) { - dom.selected = true; - } - else if (!isNullOrUndef(value) || !isNullOrUndef(props.selected)) { - dom.selected = props.selected || false; - } - } - var onSelectChange = createWrappedFunction('onChange', applyValueSelect); - function selectEvents(dom) { - attachEvent(dom, 'change', onSelectChange); - } - function applyValueSelect(nextPropsOrEmpty, dom, mounting, vNode) { - var multiplePropInBoolean = Boolean(nextPropsOrEmpty.multiple); - if (!isNullOrUndef(nextPropsOrEmpty.multiple) && multiplePropInBoolean !== dom.multiple) { - dom.multiple = multiplePropInBoolean; - } - var index = nextPropsOrEmpty.selectedIndex; - if (index === -1) { - dom.selectedIndex = -1; - } - var childFlags = vNode.childFlags; - if (childFlags !== 1 /* HasInvalidChildren */) { - var value = nextPropsOrEmpty.value; - if (isNumber(index) && index > -1 && dom.options[index]) { - value = dom.options[index].value; - } - if (mounting && isNullOrUndef(value)) { - value = nextPropsOrEmpty.defaultValue; - } - updateChildOptions(vNode, value); - } - } - - var onTextareaInputChange = createWrappedFunction('onInput', applyValueTextArea); - var wrappedOnChange$1 = createWrappedFunction('onChange'); - function textAreaEvents(dom, nextPropsOrEmpty) { - attachEvent(dom, 'input', onTextareaInputChange); - if (nextPropsOrEmpty.onChange) { - attachEvent(dom, 'change', wrappedOnChange$1); - } - } - function applyValueTextArea(nextPropsOrEmpty, dom, mounting) { - var value = nextPropsOrEmpty.value; - var domValue = dom.value; - if (isNullOrUndef(value)) { - if (mounting) { - var defaultValue = nextPropsOrEmpty.defaultValue; - if (!isNullOrUndef(defaultValue) && defaultValue !== domValue) { - dom.defaultValue = defaultValue; - dom.value = defaultValue; - } - } - } - else if (domValue !== value) { - /* There is value so keep it controlled */ - dom.defaultValue = value; - dom.value = value; - } - } - - function processElement(flags, vNode, dom, nextPropsOrEmpty, mounting, isControlled) { - if (flags & 64 /* InputElement */) { - applyValueInput(nextPropsOrEmpty, dom); - } - else if (flags & 256 /* SelectElement */) { - applyValueSelect(nextPropsOrEmpty, dom, mounting, vNode); - } - else if (flags & 128 /* TextareaElement */) { - applyValueTextArea(nextPropsOrEmpty, dom, mounting); - } - if (isControlled) { - dom.$V = vNode; - } - } - function addFormElementEventHandlers(flags, dom, nextPropsOrEmpty) { - if (flags & 64 /* InputElement */) { - inputEvents(dom, nextPropsOrEmpty); - } - else if (flags & 256 /* SelectElement */) { - selectEvents(dom); - } - else if (flags & 128 /* TextareaElement */) { - textAreaEvents(dom, nextPropsOrEmpty); - } - } - function isControlledFormElement(nextPropsOrEmpty) { - return nextPropsOrEmpty.type && isCheckedType(nextPropsOrEmpty.type) ? !isNullOrUndef(nextPropsOrEmpty.checked) : !isNullOrUndef(nextPropsOrEmpty.value); - } - function unmountRef(ref) { - if (ref) { - if (!safeCall1(ref, null) && ref.current) { - ref.current = null; - } - } - } - function mountRef(ref, value, lifecycle) { - if (ref && (isFunction(ref) || ref.current !== void 0)) { - lifecycle.push(function () { - if (!safeCall1(ref, value) && ref.current !== void 0) { - ref.current = value; - } - }); - } - } - - function remove(vNode, parentDOM) { - unmount(vNode); - removeVNodeDOM(vNode, parentDOM); - } - function unmount(vNode) { - var flags = vNode.flags; - var children = vNode.children; - var ref; - if (flags & 481 /* Element */) { - ref = vNode.ref; - var props = vNode.props; - unmountRef(ref); - var childFlags = vNode.childFlags; - if (!isNull(props)) { - var keys = Object.keys(props); - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i]; - if (syntheticEvents[key]) { - unmountSyntheticEvent(key, vNode.dom); - } - } - } - if (childFlags & 12 /* MultipleChildren */) { - unmountAllChildren(children); - } - else if (childFlags === 2 /* HasVNodeChildren */) { - unmount(children); - } - } - else if (children) { - if (flags & 4 /* ComponentClass */) { - if (isFunction(children.componentWillUnmount)) { - children.componentWillUnmount(); - } - unmountRef(vNode.ref); - children.$UN = true; - unmount(children.$LI); - } - else if (flags & 8 /* ComponentFunction */) { - ref = vNode.ref; - if (!isNullOrUndef(ref) && isFunction(ref.onComponentWillUnmount)) { - ref.onComponentWillUnmount(findDOMfromVNode(vNode, true), vNode.props || EMPTY_OBJ); - } - unmount(children); - } - else if (flags & 1024 /* Portal */) { - remove(children, vNode.ref); - } - else if (flags & 8192 /* Fragment */) { - if (vNode.childFlags & 12 /* MultipleChildren */) { - unmountAllChildren(children); - } - } - } - } - function unmountAllChildren(children) { - for (var i = 0, len = children.length; i < len; ++i) { - unmount(children[i]); - } - } - function clearDOM(dom) { - // Optimization for clearing dom - dom.textContent = ''; - } - function removeAllChildren(dom, vNode, children) { - unmountAllChildren(children); - if (vNode.flags & 8192 /* Fragment */) { - removeVNodeDOM(vNode, dom); - } - else { - clearDOM(dom); - } - } - - function wrapLinkEvent(nextValue) { - // This variable makes sure there is no "this" context in callback - var ev = nextValue.event; - return function (e) { - ev(nextValue.data, e); - }; - } - function patchEvent(name, lastValue, nextValue, dom) { - if (isLinkEventObject(nextValue)) { - if (isLastValueSameLinkEvent(lastValue, nextValue)) { - return; - } - nextValue = wrapLinkEvent(nextValue); - } - attachEvent(dom, normalizeEventName(name), nextValue); - } - // We are assuming here that we come from patchProp routine - // -nextAttrValue cannot be null or undefined - function patchStyle(lastAttrValue, nextAttrValue, dom) { - if (isNullOrUndef(nextAttrValue)) { - dom.removeAttribute('style'); - return; - } - var domStyle = dom.style; - var style; - var value; - if (isString(nextAttrValue)) { - domStyle.cssText = nextAttrValue; - return; - } - if (!isNullOrUndef(lastAttrValue) && !isString(lastAttrValue)) { - for (style in nextAttrValue) { - // do not add a hasOwnProperty check here, it affects performance - value = nextAttrValue[style]; - if (value !== lastAttrValue[style]) { - domStyle.setProperty(style, value); - } - } - for (style in lastAttrValue) { - if (isNullOrUndef(nextAttrValue[style])) { - domStyle.removeProperty(style); - } - } - } - else { - for (style in nextAttrValue) { - value = nextAttrValue[style]; - domStyle.setProperty(style, value); - } - } - } - function patchDangerInnerHTML(lastValue, nextValue, lastVNode, dom) { - var lastHtml = (lastValue && lastValue.__html) || ''; - var nextHtml = (nextValue && nextValue.__html) || ''; - if (lastHtml !== nextHtml) { - if (!isNullOrUndef(nextHtml) && !isSameInnerHTML(dom, nextHtml)) { - if (!isNull(lastVNode)) { - if (lastVNode.childFlags & 12 /* MultipleChildren */) { - unmountAllChildren(lastVNode.children); - } - else if (lastVNode.childFlags === 2 /* HasVNodeChildren */) { - unmount(lastVNode.children); - } - lastVNode.children = null; - lastVNode.childFlags = 1 /* HasInvalidChildren */; - } - dom.innerHTML = nextHtml; - } - } - } - function patchProp(prop, lastValue, nextValue, dom, isSVG, hasControlledValue, lastVNode) { - switch (prop) { - case 'children': - case 'childrenType': - case 'className': - case 'defaultValue': - case 'key': - case 'multiple': - case 'ref': - case 'selectedIndex': - break; - case 'autoFocus': - dom.autofocus = !!nextValue; - break; - case 'allowfullscreen': - case 'autoplay': - case 'capture': - case 'checked': - case 'controls': - case 'default': - case 'disabled': - case 'hidden': - case 'indeterminate': - case 'loop': - case 'muted': - case 'novalidate': - case 'open': - case 'readOnly': - case 'required': - case 'reversed': - case 'scoped': - case 'seamless': - case 'selected': - dom[prop] = !!nextValue; - break; - case 'defaultChecked': - case 'value': - case 'volume': - if (hasControlledValue && prop === 'value') { - break; - } - var value = isNullOrUndef(nextValue) ? '' : nextValue; - if (dom[prop] !== value) { - dom[prop] = value; - } - break; - case 'style': - patchStyle(lastValue, nextValue, dom); - break; - case 'dangerouslySetInnerHTML': - patchDangerInnerHTML(lastValue, nextValue, lastVNode, dom); - break; - default: - if (syntheticEvents[prop]) { - handleSyntheticEvent(prop, lastValue, nextValue, dom); - } - else if (prop.charCodeAt(0) === 111 && prop.charCodeAt(1) === 110) { - patchEvent(prop, lastValue, nextValue, dom); - } - else if (isNullOrUndef(nextValue)) { - dom.removeAttribute(prop); - } - else if (isSVG && namespaces[prop]) { - // We optimize for isSVG being false - // If we end up in this path we can read property again - dom.setAttributeNS(namespaces[prop], prop, nextValue); - } - else { - dom.setAttribute(prop, nextValue); - } - break; - } - } - function mountProps(vNode, flags, props, dom, isSVG) { - var hasControlledValue = false; - var isFormElement = (flags & 448 /* FormElement */) > 0; - if (isFormElement) { - hasControlledValue = isControlledFormElement(props); - if (hasControlledValue) { - addFormElementEventHandlers(flags, dom, props); - } - } - for (var prop in props) { - // do not add a hasOwnProperty check here, it affects performance - patchProp(prop, null, props[prop], dom, isSVG, hasControlledValue, null); - } - if (isFormElement) { - processElement(flags, vNode, dom, props, true, hasControlledValue); - } - } - - function renderNewInput(instance, props, context) { - var nextInput = normalizeRoot(instance.render(props, instance.state, context)); - var childContext = context; - if (isFunction(instance.getChildContext)) { - childContext = combineFrom(context, instance.getChildContext()); - } - instance.$CX = childContext; - return nextInput; - } - function createClassComponentInstance(vNode, Component, props, context, isSVG, lifecycle) { - var instance = new Component(props, context); - var usesNewAPI = (instance.$N = Boolean(Component.getDerivedStateFromProps || instance.getSnapshotBeforeUpdate)); - instance.$SVG = isSVG; - instance.$L = lifecycle; - vNode.children = instance; - instance.$BS = false; - instance.context = context; - if (instance.props === EMPTY_OBJ) { - instance.props = props; - } - if (!usesNewAPI) { - if (isFunction(instance.componentWillMount)) { - instance.$BR = true; - instance.componentWillMount(); - var pending = instance.$PS; - if (!isNull(pending)) { - var state = instance.state; - if (isNull(state)) { - instance.state = pending; - } - else { - for (var key in pending) { - state[key] = pending[key]; - } - } - instance.$PS = null; - } - instance.$BR = false; - } - } - else { - instance.state = createDerivedState(instance, props, instance.state); - } - instance.$LI = renderNewInput(instance, props, context); - return instance; - } - function renderFunctionalComponent(vNode, context) { - var props = vNode.props || EMPTY_OBJ; - return vNode.flags & 32768 /* ForwardRef */ ? vNode.type.render(props, vNode.ref, context) : vNode.type(props, context); - } - - function mount(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var flags = (vNode.flags |= 16384 /* InUse */); - if (flags & 481 /* Element */) { - mountElement(vNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (flags & 4 /* ComponentClass */) { - mountClassComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (flags & 8 /* ComponentFunction */) { - mountFunctionalComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle); - mountFunctionalComponentCallbacks(vNode, lifecycle); - } - else if (flags & 512 /* Void */ || flags & 16 /* Text */) { - mountText(vNode, parentDOM, nextNode); - } - else if (flags & 8192 /* Fragment */) { - mountFragment(vNode, context, parentDOM, isSVG, nextNode, lifecycle); - } - else if (flags & 1024 /* Portal */) { - mountPortal(vNode, context, parentDOM, nextNode, lifecycle); - } - else ; - } - function mountPortal(vNode, context, parentDOM, nextNode, lifecycle) { - mount(vNode.children, vNode.ref, context, false, null, lifecycle); - var placeHolderVNode = createVoidVNode(); - mountText(placeHolderVNode, parentDOM, nextNode); - vNode.dom = placeHolderVNode.dom; - } - function mountFragment(vNode, context, parentDOM, isSVG, nextNode, lifecycle) { - var children = vNode.children; - var childFlags = vNode.childFlags; - // When fragment is optimized for multiple children, check if there is no children and change flag to invalid - // This is the only normalization always done, to keep optimization flags API same for fragments and regular elements - if (childFlags & 12 /* MultipleChildren */ && children.length === 0) { - childFlags = vNode.childFlags = 2 /* HasVNodeChildren */; - children = vNode.children = createVoidVNode(); - } - if (childFlags === 2 /* HasVNodeChildren */) { - mount(children, parentDOM, nextNode, isSVG, nextNode, lifecycle); - } - else { - mountArrayChildren(children, parentDOM, context, isSVG, nextNode, lifecycle); - } - } - function mountText(vNode, parentDOM, nextNode) { - var dom = (vNode.dom = document.createTextNode(vNode.children)); - if (!isNull(parentDOM)) { - insertOrAppend(parentDOM, dom, nextNode); - } - } - function mountElement(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var flags = vNode.flags; - var props = vNode.props; - var className = vNode.className; - var childFlags = vNode.childFlags; - var dom = (vNode.dom = documentCreateElement(vNode.type, (isSVG = isSVG || (flags & 32 /* SvgElement */) > 0))); - var children = vNode.children; - if (!isNullOrUndef(className) && className !== '') { - if (isSVG) { - dom.setAttribute('class', className); - } - else { - dom.className = className; - } - } - if (childFlags === 16 /* HasTextChildren */) { - setTextContent(dom, children); - } - else if (childFlags !== 1 /* HasInvalidChildren */) { - var childrenIsSVG = isSVG && vNode.type !== 'foreignObject'; - if (childFlags === 2 /* HasVNodeChildren */) { - if (children.flags & 16384 /* InUse */) { - vNode.children = children = directClone(children); - } - mount(children, dom, context, childrenIsSVG, null, lifecycle); - } - else if (childFlags === 8 /* HasKeyedChildren */ || childFlags === 4 /* HasNonKeyedChildren */) { - mountArrayChildren(children, dom, context, childrenIsSVG, null, lifecycle); - } - } - if (!isNull(parentDOM)) { - insertOrAppend(parentDOM, dom, nextNode); - } - if (!isNull(props)) { - mountProps(vNode, flags, props, dom, isSVG); - } - mountRef(vNode.ref, dom, lifecycle); - } - function mountArrayChildren(children, dom, context, isSVG, nextNode, lifecycle) { - for (var i = 0; i < children.length; ++i) { - var child = children[i]; - if (child.flags & 16384 /* InUse */) { - children[i] = child = directClone(child); - } - mount(child, dom, context, isSVG, nextNode, lifecycle); - } - } - function mountClassComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var instance = createClassComponentInstance(vNode, vNode.type, vNode.props || EMPTY_OBJ, context, isSVG, lifecycle); - mount(instance.$LI, parentDOM, instance.$CX, isSVG, nextNode, lifecycle); - mountClassComponentCallbacks(vNode.ref, instance, lifecycle); - } - function mountFunctionalComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - mount((vNode.children = normalizeRoot(renderFunctionalComponent(vNode, context))), parentDOM, context, isSVG, nextNode, lifecycle); - } - function createClassMountCallback(instance) { - return function () { - instance.componentDidMount(); - }; - } - function mountClassComponentCallbacks(ref, instance, lifecycle) { - mountRef(ref, instance, lifecycle); - if (isFunction(instance.componentDidMount)) { - lifecycle.push(createClassMountCallback(instance)); - } - } - function createOnMountCallback(ref, vNode) { - return function () { - ref.onComponentDidMount(findDOMfromVNode(vNode, true), vNode.props || EMPTY_OBJ); - }; - } - function mountFunctionalComponentCallbacks(vNode, lifecycle) { - var ref = vNode.ref; - if (!isNullOrUndef(ref)) { - safeCall1(ref.onComponentWillMount, vNode.props || EMPTY_OBJ); - if (isFunction(ref.onComponentDidMount)) { - lifecycle.push(createOnMountCallback(ref, vNode)); - } - } - } - - function replaceWithNewNode(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle) { - unmount(lastVNode); - if ((nextVNode.flags & lastVNode.flags & 2033 /* DOMRef */) !== 0) { - mount(nextVNode, null, context, isSVG, null, lifecycle); - // Single DOM operation, when we have dom references available - replaceChild(parentDOM, nextVNode.dom, lastVNode.dom); - } - else { - mount(nextVNode, parentDOM, context, isSVG, findDOMfromVNode(lastVNode, true), lifecycle); - removeVNodeDOM(lastVNode, parentDOM); - } - } - function patch(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var nextFlags = (nextVNode.flags |= 16384 /* InUse */); - if (lastVNode.flags !== nextFlags || lastVNode.type !== nextVNode.type || lastVNode.key !== nextVNode.key || nextFlags & 2048 /* ReCreate */) { - if (lastVNode.flags & 16384 /* InUse */) { - replaceWithNewNode(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle); - } - else { - // Last vNode is not in use, it has crashed at application level. Just mount nextVNode and ignore last one - mount(nextVNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - } - else if (nextFlags & 481 /* Element */) { - patchElement(lastVNode, nextVNode, context, isSVG, nextFlags, lifecycle); - } - else if (nextFlags & 4 /* ComponentClass */) { - patchClassComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (nextFlags & 8 /* ComponentFunction */) { - patchFunctionalComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (nextFlags & 16 /* Text */) { - patchText(lastVNode, nextVNode); - } - else if (nextFlags & 512 /* Void */) { - nextVNode.dom = lastVNode.dom; - } - else if (nextFlags & 8192 /* Fragment */) { - patchFragment(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle); - } - else { - patchPortal(lastVNode, nextVNode, context, lifecycle); - } - } - function patchSingleTextChild(lastChildren, nextChildren, parentDOM) { - if (lastChildren !== nextChildren) { - if (lastChildren !== '') { - parentDOM.firstChild.nodeValue = nextChildren; - } - else { - setTextContent(parentDOM, nextChildren); - } - } - } - function patchContentEditableChildren(dom, nextChildren) { - if (dom.textContent !== nextChildren) { - dom.textContent = nextChildren; - } - } - function patchFragment(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle) { - var lastChildren = lastVNode.children; - var nextChildren = nextVNode.children; - var lastChildFlags = lastVNode.childFlags; - var nextChildFlags = nextVNode.childFlags; - var nextNode = null; - // When fragment is optimized for multiple children, check if there is no children and change flag to invalid - // This is the only normalization always done, to keep optimization flags API same for fragments and regular elements - if (nextChildFlags & 12 /* MultipleChildren */ && nextChildren.length === 0) { - nextChildFlags = nextVNode.childFlags = 2 /* HasVNodeChildren */; - nextChildren = nextVNode.children = createVoidVNode(); - } - var nextIsSingle = (nextChildFlags & 2 /* HasVNodeChildren */) !== 0; - if (lastChildFlags & 12 /* MultipleChildren */) { - var lastLen = lastChildren.length; - // We need to know Fragment's edge node when - if ( - // It uses keyed algorithm - (lastChildFlags & 8 /* HasKeyedChildren */ && nextChildFlags & 8 /* HasKeyedChildren */) || - // It transforms from many to single - nextIsSingle || - // It will append more nodes - (!nextIsSingle && nextChildren.length > lastLen)) { - // When fragment has multiple children there is always at least one vNode - nextNode = findDOMfromVNode(lastChildren[lastLen - 1], false).nextSibling; - } - } - patchChildren(lastChildFlags, nextChildFlags, lastChildren, nextChildren, parentDOM, context, isSVG, nextNode, lastVNode, lifecycle); - } - function patchPortal(lastVNode, nextVNode, context, lifecycle) { - var lastContainer = lastVNode.ref; - var nextContainer = nextVNode.ref; - var nextChildren = nextVNode.children; - patchChildren(lastVNode.childFlags, nextVNode.childFlags, lastVNode.children, nextChildren, lastContainer, context, false, null, lastVNode, lifecycle); - nextVNode.dom = lastVNode.dom; - if (lastContainer !== nextContainer && !isInvalid(nextChildren)) { - var node = nextChildren.dom; - removeChild(lastContainer, node); - appendChild(nextContainer, node); - } - } - function patchElement(lastVNode, nextVNode, context, isSVG, nextFlags, lifecycle) { - var dom = (nextVNode.dom = lastVNode.dom); - var lastProps = lastVNode.props; - var nextProps = nextVNode.props; - var isFormElement = false; - var hasControlledValue = false; - var nextPropsOrEmpty; - isSVG = isSVG || (nextFlags & 32 /* SvgElement */) > 0; - // inlined patchProps -- starts -- - if (lastProps !== nextProps) { - var lastPropsOrEmpty = lastProps || EMPTY_OBJ; - nextPropsOrEmpty = nextProps || EMPTY_OBJ; - if (nextPropsOrEmpty !== EMPTY_OBJ) { - isFormElement = (nextFlags & 448 /* FormElement */) > 0; - if (isFormElement) { - hasControlledValue = isControlledFormElement(nextPropsOrEmpty); - } - for (var prop in nextPropsOrEmpty) { - var lastValue = lastPropsOrEmpty[prop]; - var nextValue = nextPropsOrEmpty[prop]; - if (lastValue !== nextValue) { - patchProp(prop, lastValue, nextValue, dom, isSVG, hasControlledValue, lastVNode); - } - } - } - if (lastPropsOrEmpty !== EMPTY_OBJ) { - for (var prop$1 in lastPropsOrEmpty) { - if (isNullOrUndef(nextPropsOrEmpty[prop$1]) && !isNullOrUndef(lastPropsOrEmpty[prop$1])) { - patchProp(prop$1, lastPropsOrEmpty[prop$1], null, dom, isSVG, hasControlledValue, lastVNode); - } - } - } - } - var nextChildren = nextVNode.children; - var nextClassName = nextVNode.className; - // inlined patchProps -- ends -- - if (lastVNode.className !== nextClassName) { - if (isNullOrUndef(nextClassName)) { - dom.removeAttribute('class'); - } - else if (isSVG) { - dom.setAttribute('class', nextClassName); - } - else { - dom.className = nextClassName; - } - } - if (nextFlags & 4096 /* ContentEditable */) { - patchContentEditableChildren(dom, nextChildren); - } - else { - patchChildren(lastVNode.childFlags, nextVNode.childFlags, lastVNode.children, nextChildren, dom, context, isSVG && nextVNode.type !== 'foreignObject', null, lastVNode, lifecycle); - } - if (isFormElement) { - processElement(nextFlags, nextVNode, dom, nextPropsOrEmpty, false, hasControlledValue); - } - var nextRef = nextVNode.ref; - var lastRef = lastVNode.ref; - if (lastRef !== nextRef) { - unmountRef(lastRef); - mountRef(nextRef, dom, lifecycle); - } - } - function replaceOneVNodeWithMultipleVNodes(lastChildren, nextChildren, parentDOM, context, isSVG, lifecycle) { - unmount(lastChildren); - mountArrayChildren(nextChildren, parentDOM, context, isSVG, findDOMfromVNode(lastChildren, true), lifecycle); - removeVNodeDOM(lastChildren, parentDOM); - } - function patchChildren(lastChildFlags, nextChildFlags, lastChildren, nextChildren, parentDOM, context, isSVG, nextNode, parentVNode, lifecycle) { - switch (lastChildFlags) { - case 2 /* HasVNodeChildren */: - switch (nextChildFlags) { - case 2 /* HasVNodeChildren */: - patch(lastChildren, nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - remove(lastChildren, parentDOM); - break; - case 16 /* HasTextChildren */: - unmount(lastChildren); - setTextContent(parentDOM, nextChildren); - break; - default: - replaceOneVNodeWithMultipleVNodes(lastChildren, nextChildren, parentDOM, context, isSVG, lifecycle); - break; - } - break; - case 1 /* HasInvalidChildren */: - switch (nextChildFlags) { - case 2 /* HasVNodeChildren */: - mount(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - break; - case 16 /* HasTextChildren */: - setTextContent(parentDOM, nextChildren); - break; - default: - mountArrayChildren(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - } - break; - case 16 /* HasTextChildren */: - switch (nextChildFlags) { - case 16 /* HasTextChildren */: - patchSingleTextChild(lastChildren, nextChildren, parentDOM); - break; - case 2 /* HasVNodeChildren */: - clearDOM(parentDOM); - mount(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - clearDOM(parentDOM); - break; - default: - clearDOM(parentDOM); - mountArrayChildren(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - } - break; - default: - switch (nextChildFlags) { - case 16 /* HasTextChildren */: - unmountAllChildren(lastChildren); - setTextContent(parentDOM, nextChildren); - break; - case 2 /* HasVNodeChildren */: - removeAllChildren(parentDOM, parentVNode, lastChildren); - mount(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - removeAllChildren(parentDOM, parentVNode, lastChildren); - break; - default: - var lastLength = lastChildren.length | 0; - var nextLength = nextChildren.length | 0; - // Fast path's for both algorithms - if (lastLength === 0) { - if (nextLength > 0) { - mountArrayChildren(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - } - } - else if (nextLength === 0) { - removeAllChildren(parentDOM, parentVNode, lastChildren); - } - else if (nextChildFlags === 8 /* HasKeyedChildren */ && lastChildFlags === 8 /* HasKeyedChildren */) { - patchKeyedChildren(lastChildren, nextChildren, parentDOM, context, isSVG, lastLength, nextLength, nextNode, parentVNode, lifecycle); - } - else { - patchNonKeyedChildren(lastChildren, nextChildren, parentDOM, context, isSVG, lastLength, nextLength, nextNode, lifecycle); - } - break; - } - break; - } - } - function createDidUpdate(instance, lastProps, lastState, snapshot, lifecycle) { - lifecycle.push(function () { - instance.componentDidUpdate(lastProps, lastState, snapshot); - }); - } - function updateClassComponent(instance, nextState, nextProps, parentDOM, context, isSVG, force, nextNode, lifecycle) { - var lastState = instance.state; - var lastProps = instance.props; - var usesNewAPI = Boolean(instance.$N); - var hasSCU = isFunction(instance.shouldComponentUpdate); - if (usesNewAPI) { - nextState = createDerivedState(instance, nextProps, nextState !== lastState ? combineFrom(lastState, nextState) : nextState); - } - if (force || !hasSCU || (hasSCU && instance.shouldComponentUpdate(nextProps, nextState, context))) { - if (!usesNewAPI && isFunction(instance.componentWillUpdate)) { - instance.componentWillUpdate(nextProps, nextState, context); - } - instance.props = nextProps; - instance.state = nextState; - instance.context = context; - var snapshot = null; - var nextInput = renderNewInput(instance, nextProps, context); - if (usesNewAPI && isFunction(instance.getSnapshotBeforeUpdate)) { - snapshot = instance.getSnapshotBeforeUpdate(lastProps, lastState); - } - patch(instance.$LI, nextInput, parentDOM, instance.$CX, isSVG, nextNode, lifecycle); - // Dont update Last input, until patch has been succesfully executed - instance.$LI = nextInput; - if (isFunction(instance.componentDidUpdate)) { - createDidUpdate(instance, lastProps, lastState, snapshot, lifecycle); - } - } - else { - instance.props = nextProps; - instance.state = nextState; - instance.context = context; - } - } - function patchClassComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var instance = (nextVNode.children = lastVNode.children); - // If Component has crashed, ignore it to stay functional - if (isNull(instance)) { - return; - } - instance.$L = lifecycle; - var nextProps = nextVNode.props || EMPTY_OBJ; - var nextRef = nextVNode.ref; - var lastRef = lastVNode.ref; - var nextState = instance.state; - if (!instance.$N) { - if (isFunction(instance.componentWillReceiveProps)) { - instance.$BR = true; - instance.componentWillReceiveProps(nextProps, context); - // If instance component was removed during its own update do nothing. - if (instance.$UN) { - return; - } - instance.$BR = false; - } - if (!isNull(instance.$PS)) { - nextState = combineFrom(nextState, instance.$PS); - instance.$PS = null; - } - } - updateClassComponent(instance, nextState, nextProps, parentDOM, context, isSVG, false, nextNode, lifecycle); - if (lastRef !== nextRef) { - unmountRef(lastRef); - mountRef(nextRef, instance, lifecycle); - } - } - function patchFunctionalComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var shouldUpdate = true; - var nextProps = nextVNode.props || EMPTY_OBJ; - var nextRef = nextVNode.ref; - var lastProps = lastVNode.props; - var nextHooksDefined = !isNullOrUndef(nextRef); - var lastInput = lastVNode.children; - if (nextHooksDefined && isFunction(nextRef.onComponentShouldUpdate)) { - shouldUpdate = nextRef.onComponentShouldUpdate(lastProps, nextProps); - } - if (shouldUpdate !== false) { - if (nextHooksDefined && isFunction(nextRef.onComponentWillUpdate)) { - nextRef.onComponentWillUpdate(lastProps, nextProps); - } - var nextInput = normalizeRoot(renderFunctionalComponent(nextVNode, context)); - patch(lastInput, nextInput, parentDOM, context, isSVG, nextNode, lifecycle); - nextVNode.children = nextInput; - if (nextHooksDefined && isFunction(nextRef.onComponentDidUpdate)) { - nextRef.onComponentDidUpdate(lastProps, nextProps); - } - } - else { - nextVNode.children = lastInput; - } - } - function patchText(lastVNode, nextVNode) { - var nextText = nextVNode.children; - var dom = (nextVNode.dom = lastVNode.dom); - if (nextText !== lastVNode.children) { - dom.nodeValue = nextText; - } - } - function patchNonKeyedChildren(lastChildren, nextChildren, dom, context, isSVG, lastChildrenLength, nextChildrenLength, nextNode, lifecycle) { - var commonLength = lastChildrenLength > nextChildrenLength ? nextChildrenLength : lastChildrenLength; - var i = 0; - var nextChild; - var lastChild; - for (; i < commonLength; ++i) { - nextChild = nextChildren[i]; - lastChild = lastChildren[i]; - if (nextChild.flags & 16384 /* InUse */) { - nextChild = nextChildren[i] = directClone(nextChild); - } - patch(lastChild, nextChild, dom, context, isSVG, nextNode, lifecycle); - lastChildren[i] = nextChild; - } - if (lastChildrenLength < nextChildrenLength) { - for (i = commonLength; i < nextChildrenLength; ++i) { - nextChild = nextChildren[i]; - if (nextChild.flags & 16384 /* InUse */) { - nextChild = nextChildren[i] = directClone(nextChild); - } - mount(nextChild, dom, context, isSVG, nextNode, lifecycle); - } - } - else if (lastChildrenLength > nextChildrenLength) { - for (i = commonLength; i < lastChildrenLength; ++i) { - remove(lastChildren[i], dom); - } - } - } - function patchKeyedChildren(a, b, dom, context, isSVG, aLength, bLength, outerEdge, parentVNode, lifecycle) { - var aEnd = aLength - 1; - var bEnd = bLength - 1; - var j = 0; - var aNode = a[j]; - var bNode = b[j]; - var nextPos; - var nextNode; - // Step 1 - // tslint:disable-next-line - outer: { - // Sync nodes with the same key at the beginning. - while (aNode.key === bNode.key) { - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - a[j] = bNode; - ++j; - if (j > aEnd || j > bEnd) { - break outer; - } - aNode = a[j]; - bNode = b[j]; - } - aNode = a[aEnd]; - bNode = b[bEnd]; - // Sync nodes with the same key at the end. - while (aNode.key === bNode.key) { - if (bNode.flags & 16384 /* InUse */) { - b[bEnd] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - a[aEnd] = bNode; - aEnd--; - bEnd--; - if (j > aEnd || j > bEnd) { - break outer; - } - aNode = a[aEnd]; - bNode = b[bEnd]; - } - } - if (j > aEnd) { - if (j <= bEnd) { - nextPos = bEnd + 1; - nextNode = nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge; - while (j <= bEnd) { - bNode = b[j]; - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - ++j; - mount(bNode, dom, context, isSVG, nextNode, lifecycle); - } - } - } - else if (j > bEnd) { - while (j <= aEnd) { - remove(a[j++], dom); - } - } - else { - patchKeyedChildrenComplex(a, b, context, aLength, bLength, aEnd, bEnd, j, dom, isSVG, outerEdge, parentVNode, lifecycle); - } - } - function patchKeyedChildrenComplex(a, b, context, aLength, bLength, aEnd, bEnd, j, dom, isSVG, outerEdge, parentVNode, lifecycle) { - var aNode; - var bNode; - var nextPos; - var i = 0; - var aStart = j; - var bStart = j; - var aLeft = aEnd - j + 1; - var bLeft = bEnd - j + 1; - var sources = new Int32Array(bLeft + 1); - // Keep track if its possible to remove whole DOM using textContent = ''; - var canRemoveWholeContent = aLeft === aLength; - var moved = false; - var pos = 0; - var patched = 0; - // When sizes are small, just loop them through - if (bLength < 4 || (aLeft | bLeft) < 32) { - for (i = aStart; i <= aEnd; ++i) { - aNode = a[i]; - if (patched < bLeft) { - for (j = bStart; j <= bEnd; j++) { - bNode = b[j]; - if (aNode.key === bNode.key) { - sources[j - bStart] = i + 1; - if (canRemoveWholeContent) { - canRemoveWholeContent = false; - while (aStart < i) { - remove(a[aStart++], dom); - } - } - if (pos > j) { - moved = true; - } - else { - pos = j; - } - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - ++patched; - break; - } - } - if (!canRemoveWholeContent && j > bEnd) { - remove(aNode, dom); - } - } - else if (!canRemoveWholeContent) { - remove(aNode, dom); - } - } - } - else { - var keyIndex = {}; - // Map keys by their index - for (i = bStart; i <= bEnd; ++i) { - keyIndex[b[i].key] = i; - } - // Try to patch same keys - for (i = aStart; i <= aEnd; ++i) { - aNode = a[i]; - if (patched < bLeft) { - j = keyIndex[aNode.key]; - if (j !== void 0) { - if (canRemoveWholeContent) { - canRemoveWholeContent = false; - while (i > aStart) { - remove(a[aStart++], dom); - } - } - sources[j - bStart] = i + 1; - if (pos > j) { - moved = true; - } - else { - pos = j; - } - bNode = b[j]; - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - ++patched; - } - else if (!canRemoveWholeContent) { - remove(aNode, dom); - } - } - else if (!canRemoveWholeContent) { - remove(aNode, dom); - } - } - } - // fast-path: if nothing patched remove all old and add all new - if (canRemoveWholeContent) { - removeAllChildren(dom, parentVNode, a); - mountArrayChildren(b, dom, context, isSVG, outerEdge, lifecycle); - } - else if (moved) { - var seq = lis_algorithm(sources); - j = seq.length - 1; - for (i = bLeft - 1; i >= 0; i--) { - if (sources[i] === 0) { - pos = i + bStart; - bNode = b[pos]; - if (bNode.flags & 16384 /* InUse */) { - b[pos] = bNode = directClone(bNode); - } - nextPos = pos + 1; - mount(bNode, dom, context, isSVG, nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge, lifecycle); - } - else if (j < 0 || i !== seq[j]) { - pos = i + bStart; - bNode = b[pos]; - nextPos = pos + 1; - moveVNodeDOM(bNode, dom, nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge); - } - else { - j--; - } - } - } - else if (patched !== bLeft) { - // when patched count doesn't match b length we need to insert those new ones - // loop backwards so we can use insertBefore - for (i = bLeft - 1; i >= 0; i--) { - if (sources[i] === 0) { - pos = i + bStart; - bNode = b[pos]; - if (bNode.flags & 16384 /* InUse */) { - b[pos] = bNode = directClone(bNode); - } - nextPos = pos + 1; - mount(bNode, dom, context, isSVG, nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge, lifecycle); - } - } - } - } - var result; - var p; - var maxLen = 0; - // https://en.wikipedia.org/wiki/Longest_increasing_subsequence - function lis_algorithm(arr) { - var arrI = 0; - var i = 0; - var j = 0; - var k = 0; - var u = 0; - var v = 0; - var c = 0; - var len = arr.length; - if (len > maxLen) { - maxLen = len; - result = new Int32Array(len); - p = new Int32Array(len); - } - for (; i < len; ++i) { - arrI = arr[i]; - if (arrI !== 0) { - j = result[k]; - if (arr[j] < arrI) { - p[i] = j; - result[++k] = i; - continue; - } - u = 0; - v = k; - while (u < v) { - c = (u + v) >> 1; - if (arr[result[c]] < arrI) { - u = c + 1; - } - else { - v = c; - } - } - if (arrI < arr[result[u]]) { - if (u > 0) { - p[i] = result[u - 1]; - } - result[u] = i; - } - } - } - u = k + 1; - var seq = new Int32Array(u); - v = result[u - 1]; - while (u-- > 0) { - seq[u] = v; - v = p[v]; - result[u] = 0; - } - return seq; - } - - var hasDocumentAvailable = typeof document !== 'undefined'; - if (hasDocumentAvailable) { - /* - * Defining $EV and $V properties on Node.prototype - * fixes v8 "wrong map" de-optimization - */ - if (window.Node) { - Node.prototype.$EV = null; - Node.prototype.$V = null; - } - } - function __render(input, parentDOM, callback, context) { - var lifecycle = []; - var rootInput = parentDOM.$V; - renderCheck.v = true; - if (isNullOrUndef(rootInput)) { - if (!isNullOrUndef(input)) { - if (input.flags & 16384 /* InUse */) { - input = directClone(input); - } - mount(input, parentDOM, context, false, null, lifecycle); - parentDOM.$V = input; - rootInput = input; - } - } - else { - if (isNullOrUndef(input)) { - remove(rootInput, parentDOM); - parentDOM.$V = null; - } - else { - if (input.flags & 16384 /* InUse */) { - input = directClone(input); - } - patch(rootInput, input, parentDOM, context, false, null, lifecycle); - rootInput = parentDOM.$V = input; - } - } - callAll(lifecycle); - renderCheck.v = false; - if (isFunction(callback)) { - callback(); - } - if (isFunction(options.renderComplete)) { - options.renderComplete(rootInput, parentDOM); - } - } - function render(input, parentDOM, callback, context) { - if ( callback === void 0 ) callback = null; - if ( context === void 0 ) context = EMPTY_OBJ; - - __render(input, parentDOM, callback, context); - } - - var QUEUE = []; - var nextTick = typeof Promise !== 'undefined' - ? Promise.resolve().then.bind(Promise.resolve()) - : function (a) { - window.setTimeout(a, 0); - }; - var microTaskPending = false; - function queueStateChanges(component, newState, callback, force) { - var pending = component.$PS; - if (isFunction(newState)) { - newState = newState(pending ? combineFrom(component.state, pending) : component.state, component.props, component.context); - } - if (isNullOrUndef(pending)) { - component.$PS = newState; - } - else { - for (var stateKey in newState) { - pending[stateKey] = newState[stateKey]; - } - } - if (!component.$BR) { - if (!renderCheck.v) { - if (QUEUE.length === 0) { - applyState(component, force); - if (isFunction(callback)) { - callback.call(component); - } - return; - } - } - if (QUEUE.indexOf(component) === -1) { - QUEUE.push(component); - } - if (force) { - component.$F = true; - } - if (!microTaskPending) { - microTaskPending = true; - nextTick(rerender); - } - if (isFunction(callback)) { - var QU = component.$QU; - if (!QU) { - QU = component.$QU = []; - } - QU.push(callback); - } - } - else if (isFunction(callback)) { - component.$L.push(callback.bind(component)); - } - } - function callSetStateCallbacks(component) { - var queue = component.$QU; - for (var i = 0; i < queue.length; ++i) { - queue[i].call(component); - } - component.$QU = null; - } - function rerender() { - var component; - microTaskPending = false; - while ((component = QUEUE.shift())) { - if (!component.$UN) { - var force = component.$F; - component.$F = false; - applyState(component, force); - if (component.$QU) { - callSetStateCallbacks(component); - } - } - } - } - function applyState(component, force) { - if (force || !component.$BR) { - var pendingState = component.$PS; - component.$PS = null; - var lifecycle = []; - renderCheck.v = true; - updateClassComponent(component, combineFrom(component.state, pendingState), component.props, findDOMfromVNode(component.$LI, true).parentNode, component.context, component.$SVG, force, null, lifecycle); - callAll(lifecycle); - renderCheck.v = false; - } - else { - component.state = component.$PS; - component.$PS = null; - } - } - var Component = function Component(props, context) { - // Public - this.state = null; - // Internal properties - this.$BR = false; // BLOCK RENDER - this.$BS = true; // BLOCK STATE - this.$PS = null; // PENDING STATE (PARTIAL or FULL) - this.$LI = null; // LAST INPUT - this.$UN = false; // UNMOUNTED - this.$CX = null; // CHILDCONTEXT - this.$QU = null; // QUEUE - this.$N = false; // Uses new lifecycle API Flag - this.$L = null; // Current lifecycle of this component - this.$SVG = false; // Flag to keep track if component is inside SVG tree - this.$F = false; // Force update flag - this.props = props || EMPTY_OBJ; - this.context = context || EMPTY_OBJ; // context should not be mutable - }; - Component.prototype.forceUpdate = function forceUpdate (callback) { - if (this.$UN) { - return; - } - // Do not allow double render during force update - queueStateChanges(this, {}, callback, true); - }; - Component.prototype.setState = function setState (newState, callback) { - if (this.$UN) { - return; - } - if (!this.$BS) { - queueStateChanges(this, newState, callback, false); - } - }; - Component.prototype.render = function render (_nextProps, _nextState, _nextContext) { - return null; - }; - - var version = "7.4.8"; - - uibench.init('Inferno [same as react]', version); - - var TableCell = /*#__PURE__*/function (_Component) { - _inheritsLoose(TableCell, _Component); - - function TableCell(props) { - var _this; - - _this = _Component.call(this, props) || this; - _this.onClick = _this.onClick.bind(_assertThisInitialized(_this)); - return _this; - } - - var _proto = TableCell.prototype; - - _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) { - return this.props.text !== nextProps.text; - }; - - _proto.onClick = function onClick(e) { - console.log('Clicked' + this.props.text); - e.stopPropagation(); - }; - - _proto.render = function render() { - return createVNode(1, "td", "TableCell", this.props.text, 0, { - "onClick": this.onClick - }, null, null); - }; - - return TableCell; - }(Component); - - var TableRow = /*#__PURE__*/function (_Component2) { - _inheritsLoose(TableRow, _Component2); - - function TableRow() { - return _Component2.apply(this, arguments) || this; - } - - var _proto2 = TableRow.prototype; - - _proto2.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) { - return this.props.data !== nextProps.data; - }; - - _proto2.render = function render() { - var data = this.props.data; // Interned strings - - var classes = data.active ? 'TableRow active' : 'TableRow'; - var cells = data.props; - var children = [createComponentVNode(2, TableCell, { - "text": '#' + data.id - }, -1, null)]; - - for (var i = 0; i < cells.length; i++) { - // Key is used because React prints warnings that there should be a key, libraries that can detect that children - // shape isn't changing should render cells without keys. - children.push(createComponentVNode(2, TableCell, { - "text": cells[i] - }, i, null)); - } // First table cell is inserted this way to prevent react from printing warning that it doesn't have key property - - - return createVNode(1, "tr", classes, children, 0, { - "data-id": data.id - }, null, null); - }; - - return TableRow; - }(Component); - - var Table = /*#__PURE__*/function (_Component3) { - _inheritsLoose(Table, _Component3); - - function Table() { - return _Component3.apply(this, arguments) || this; - } - - var _proto3 = Table.prototype; - - _proto3.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) { - return this.props.data !== nextProps.data; - }; - - _proto3.render = function render() { - var items = this.props.data.items; - var children = []; - - for (var i = 0; i < items.length; i++) { - var item = items[i]; - children.push(createComponentVNode(2, TableRow, { - "data": item - }, item.id, null)); - } - - return createVNode(1, "table", "Table", createVNode(1, "tbody", null, children, 0, null, null, null), 2, null, null, null); - }; - - return Table; - }(Component); - - var AnimBox = /*#__PURE__*/function (_Component4) { - _inheritsLoose(AnimBox, _Component4); - - function AnimBox() { - return _Component4.apply(this, arguments) || this; - } - - var _proto4 = AnimBox.prototype; - - _proto4.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) { - return this.props.data !== nextProps.data; - }; - - _proto4.render = function render() { - var data = this.props.data; - var time = data.time; - var style = { - 'border-radius': (time % 10).toString() + 'px', - 'background': 'rgba(0,0,0,' + (0.5 + time % 10 / 10).toString() + ')' - }; - return createVNode(1, "div", "AnimBox", null, 1, { - "data-id": data.id, - "style": style - }, null, null); - }; - - return AnimBox; - }(Component); - - var Anim = /*#__PURE__*/function (_Component5) { - _inheritsLoose(Anim, _Component5); - - function Anim() { - return _Component5.apply(this, arguments) || this; - } - - var _proto5 = Anim.prototype; - - _proto5.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) { - return this.props.data !== nextProps.data; - }; - - _proto5.render = function render() { - var items = this.props.data.items; - var children = []; - - for (var i = 0; i < items.length; i++) { - var item = items[i]; - children.push(createComponentVNode(2, AnimBox, { - "data": item - }, item.id, null)); - } - - return createVNode(1, "div", "Anim", children, 0, null, null, null); - }; - - return Anim; - }(Component); - - var TreeLeaf = /*#__PURE__*/function (_Component6) { - _inheritsLoose(TreeLeaf, _Component6); - - function TreeLeaf() { - return _Component6.apply(this, arguments) || this; - } - - var _proto6 = TreeLeaf.prototype; - - _proto6.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) { - return this.props.data !== nextProps.data; - }; - - _proto6.render = function render() { - return createVNode(1, "li", "TreeLeaf", this.props.data.id, 0, null, null, null); - }; - - return TreeLeaf; - }(Component); - - var TreeNode = /*#__PURE__*/function (_Component7) { - _inheritsLoose(TreeNode, _Component7); - - function TreeNode() { - return _Component7.apply(this, arguments) || this; - } - - var _proto7 = TreeNode.prototype; - - _proto7.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) { - return this.props.data !== nextProps.data; - }; - - _proto7.render = function render() { - var data = this.props.data; - var children = []; - - for (var i = 0; i < data.children.length; i++) { - var n = data.children[i]; - - if (n.container) { - children.push(createComponentVNode(2, TreeNode, { - "data": n - }, n.id, null)); - } else { - children.push(createComponentVNode(2, TreeLeaf, { - "data": n - }, n.id, null)); - } - } - - return createVNode(1, "ul", "TreeNode", children, 0, null, null, null); - }; - - return TreeNode; - }(Component); - - var Tree = /*#__PURE__*/function (_Component8) { - _inheritsLoose(Tree, _Component8); - - function Tree() { - return _Component8.apply(this, arguments) || this; - } - - var _proto8 = Tree.prototype; - - _proto8.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) { - return this.props.data !== nextProps.data; - }; - - _proto8.render = function render() { - return createVNode(1, "div", "Tree", createComponentVNode(2, TreeNode, { - "data": this.props.data.root - }, null, null), 2, null, null, null); - }; - - return Tree; - }(Component); - - var Main = /*#__PURE__*/function (_Component9) { - _inheritsLoose(Main, _Component9); - - function Main() { - return _Component9.apply(this, arguments) || this; - } - - var _proto9 = Main.prototype; - - _proto9.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) { - return this.props.data !== nextProps.data; - }; - - _proto9.render = function render() { - var data = this.props.data; - var location = data.location; - var section; - - if (location === 'table') { - section = createComponentVNode(2, Table, { - "data": data.table - }, null, null); - } else if (location === 'anim') { - section = createComponentVNode(2, Anim, { - "data": data.anim - }, null, null); - } else if (location === 'tree') { - section = createComponentVNode(2, Tree, { - "data": data.tree - }, null, null); - } - - return createVNode(1, "div", "Main", section, 0, null, null, null); - }; - - return Main; - }(Component); - - document.addEventListener('DOMContentLoaded', function (e) { - var container = document.querySelector('#App'); - uibench.run(function (state) { - render(createComponentVNode(2, Main, { - "data": state - }, null, null), container); - }, function (samples) { - render(createVNode(1, "pre", null, JSON.stringify(samples, null, ' '), 0, null, null, null), container); - }); - }); - -}()); +!function(){"use strict";function n(n,t){n.prototype=Object.create(t.prototype),n.prototype.constructor=n,e(n,t)}function e(n,t){return e=Object.setPrototypeOf||function(n,e){return n.__proto__=e,n},e(n,t)}function t(n){if(void 0===n)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}var r=Array.isArray;function o(n){var e=typeof n;return"string"===e||"number"===e}function l(n){return void 0===n||null===n}function i(n){return null===n||!1===n||!0===n||void 0===n}function a(n){return"function"===typeof n}function u(n){return"string"===typeof n}function c(n){return null===n}function s(n,e){var t={};if(n)for(var r in n)t[r]=n[r];if(e)for(var o in e)t[o]=e[o];return t}function f(n){return!c(n)&&"object"===typeof n}var d={};function p(n){return n.substr(2).toLowerCase()}function h(n,e){n.appendChild(e)}function v(n,e,t){c(t)?h(n,e):n.insertBefore(e,t)}function m(n,e){if(e)return document.createElementNS("http://www.w3.org/2000/svg",n);return document.createElement(n)}function g(n,e,t){n.replaceChild(e,t)}function y(n,e){n.removeChild(e)}function b(n){for(var e=0;e0,h=c(d),v=u(d)&&d[0]===V;p||h||v?(t=t||e.slice(0,s),(p||v)&&(f=R(f)),(h||v)&&(f.key=V+s),t.push(f)):t&&t.push(f),f.flags|=65536}}l=0===(t=t||e).length?1:8}else(t=e).flags|=65536,81920&e.flags&&(t=R(e)),l=2;return n.children=t,n.childFlags=l,n}function Q(n){if(i(n)||o(n))return E(n,null);if(r(n))return O(n,0,null);return 16384&n.flags?R(n):n}var X="http://www.w3.org/1999/xlink",G="http://www.w3.org/XML/1998/namespace",K={"xlink:actuate":X,"xlink:arcrole":X,"xlink:href":X,"xlink:role":X,"xlink:show":X,"xlink:title":X,"xlink:type":X,"xml:base":G,"xml:lang":G,"xml:space":G};function q(n){return{onClick:n,onDblClick:n,onFocusIn:n,onFocusOut:n,onKeyDown:n,onKeyPress:n,onKeyUp:n,onMouseDown:n,onMouseMove:n,onMouseUp:n,onTouchEnd:n,onTouchMove:n,onTouchStart:n}}var J=q(0),z=q(null),Y=q(!0);function Z(n,e){var t=e.$EV;return t||(t=e.$EV=q(null)),t[n]||1===++J[n]&&(z[n]=fn(n)),t}function nn(n,e){var t=e.$EV;t&&t[n]&&(0===--J[n]&&(document.removeEventListener(p(n),z[n]),z[n]=null),t[n]=null)}function en(n,e,t,r){if(a(t))Z(n,r)[n]=t;else if(f(t)){if(S(e,t))return;Z(n,r)[n]=t}else nn(n,r)}function tn(n){return a(n.composedPath)?n.composedPath()[0]:n.target}function rn(n,e,t,r){var o=tn(n);do{if(e&&o.disabled)return;var l=o.$EV;if(l){var i=l[t];if(i&&(r.dom=o,i.event?i.event(i.data,n):i(n),n.cancelBubble))return}o=o.parentNode}while(!c(o))}function on(){this.cancelBubble=!0,this.immediatePropagationStopped||this.stopImmediatePropagation()}function ln(){return this.defaultPrevented}function an(){return this.cancelBubble}function un(n){var e={dom:document};return n.isDefaultPrevented=ln,n.isPropagationStopped=an,n.stopPropagation=on,Object.defineProperty(n,"currentTarget",{configurable:!0,get:function(){return e.dom}}),e}function cn(n){return function(e){if(0!==e.button)return void e.stopPropagation();rn(e,!0,n,un(e))}}function sn(n){return function(e){rn(e,!1,n,un(e))}}function fn(n){var e="onClick"===n||"onDblClick"===n?cn(n):sn(n);return document.addEventListener(p(n),e),e}function dn(n,e){var t=document.createElement("i");return t.innerHTML=e,t.innerHTML===n.innerHTML}function pn(n,e,t){if(n[e]){var r=n[e];r.event?r.event(r.data,t):r(t)}else{var o=e.toLowerCase();n[o]&&n[o](t)}}function hn(n,e){var t=function(t){var r=this.$V;if(!r)return;var o=r.props||d,l=r.dom;if(u(n))pn(o,n,t);else for(var i=0;i-1&&e.options[i]&&(a=e.options[i].value),t&&l(a)&&(a=n.defaultValue),Cn(r,a)}}var Fn,Sn,Ln=hn("onInput",In),Nn=hn("onChange");function Vn(n,e){vn(n,"input",Ln),e.onChange&&vn(n,"change",Nn)}function In(n,e,t){var r=n.value,o=e.value;if(l(r)){if(t){var i=n.defaultValue;l(i)||i===o||(e.defaultValue=i,e.value=i)}}else o!==r&&(e.defaultValue=r,e.value=r)}function Bn(n,e,t,r,o,l){64&n?kn(r,t):256&n?Pn(r,t,o,e):128&n&&In(r,t,o),l&&(t.$V=e)}function Mn(n,e,t){64&n?$n(e,t):256&n?xn(e):128&n&&Vn(e,t)}function Tn(n){return n.type&&mn(n.type)?!l(n.checked):!l(n.value)}function An(n){n&&!N(n,null)&&n.current&&(n.current=null)}function Dn(n,e,t){n&&(a(n)||void 0!==n.current)&&t.push((function(){N(n,e)||void 0===n.current||(n.current=e)}))}function En(n,e){On(n),C(n,e)}function On(n){var e,t=n.flags,r=n.children;if(481&t){e=n.ref;var o=n.props;An(e);var i=n.childFlags;if(!c(o))for(var u=Object.keys(o),s=0,f=u.length;s0;for(var a in i&&(l=Tn(t))&&Mn(e,r,t),t)Gn(a,null,t[a],r,o,l,null);i&&Bn(e,n,r,t,!0,l)}function qn(n,e,t){var r=Q(n.render(e,n.state,t)),o=t;return a(n.getChildContext)&&(o=s(t,n.getChildContext())),n.$CX=o,r}function Jn(n,e,t,r,o,l){var i=new e(t,r),u=i.$N=Boolean(e.getDerivedStateFromProps||i.getSnapshotBeforeUpdate);if(i.$SVG=o,i.$L=l,n.children=i,i.$BS=!1,i.context=r,i.props===d&&(i.props=t),u)i.state=U(i,t,i.state);else if(a(i.componentWillMount)){i.$BR=!0,i.componentWillMount();var s=i.$PS;if(!c(s)){var f=i.state;if(c(f))i.state=s;else for(var p in s)f[p]=s[p];i.$PS=null}i.$BR=!1}return i.$LI=qn(i,t,r),i}function zn(n,e){var t=n.props||d;return 32768&n.flags?n.type.render(t,n.ref,e):n.type(t,e)}function Yn(n,e,t,r,o,l){var i=n.flags|=16384;481&i?te(n,e,t,r,o,l):4&i?oe(n,e,t,r,o,l):8&i?(le(n,e,t,r,o,l),ce(n,l)):512&i||16&i?ee(n,e,o):8192&i?ne(n,t,e,r,o,l):1024&i&&Zn(n,t,e,o,l)}function Zn(n,e,t,r,o){Yn(n.children,n.ref,e,!1,null,o);var l=j();ee(l,t,r),n.dom=l.dom}function ne(n,e,t,r,o,l){var i=n.children,a=n.childFlags;12&a&&0===i.length&&(a=n.childFlags=2,i=n.children=j()),2===a?Yn(i,t,o,r,o,l):re(i,t,e,r,o,l)}function ee(n,e,t){var r=n.dom=document.createTextNode(n.children);c(e)||v(e,r,t)}function te(n,e,t,r,o,i){var a=n.flags,u=n.props,s=n.className,f=n.childFlags,d=n.dom=m(n.type,r=r||(32&a)>0),p=n.children;if(l(s)||""===s||(r?d.setAttribute("class",s):d.className=s),16===f)F(d,p);else if(1!==f){var h=r&&"foreignObject"!==n.type;2===f?(16384&p.flags&&(n.children=p=R(p)),Yn(p,d,t,h,null,i)):8!==f&&4!==f||re(p,d,t,h,null,i)}c(e)||v(e,d,o),c(u)||Kn(n,a,u,d,r),Dn(n.ref,d,i)}function re(n,e,t,r,o,l){for(var i=0;id)&&(s=k(i[d-1],!1).nextSibling)}ye(u,c,i,a,t,r,o,s,n,l)}function ve(n,e,t,r){var o=n.ref,l=e.ref,a=e.children;if(ye(n.childFlags,e.childFlags,n.children,a,o,t,!1,null,n,r),e.dom=n.dom,o!==l&&!i(a)){var u=a.dom;y(o,u),h(l,u)}}function me(n,e,t,r,o,i){var a,u=e.dom=n.dom,c=n.props,s=e.props,f=!1,p=!1;if(r=r||(32&o)>0,c!==s){var h=c||d;if((a=s||d)!==d)for(var v in(f=(448&o)>0)&&(p=Tn(a)),a){var m=h[v],g=a[v];m!==g&&Gn(v,m,g,u,r,p,n)}if(h!==d)for(var y in h)l(a[y])&&!l(h[y])&&Gn(y,h[y],null,u,r,p,n)}var b=e.children,$=e.className;n.className!==$&&(l($)?u.removeAttribute("class"):r?u.setAttribute("class",$):u.className=$),4096&o?pe(u,b):ye(n.childFlags,e.childFlags,n.children,b,u,t,r&&"foreignObject"!==e.type,null,n,i),f&&Bn(o,e,u,a,!1,p);var k=e.ref,C=n.ref;C!==k&&(An(C),Dn(k,u,i))}function ge(n,e,t,r,o,l){On(n),re(e,t,r,o,k(n,!0),l),C(n,t)}function ye(n,e,t,r,o,l,i,a,u,c){switch(n){case 2:switch(e){case 2:fe(t,r,o,l,i,a,c);break;case 1:En(t,o);break;case 16:On(t),F(o,r);break;default:ge(t,r,o,l,i,c)}break;case 1:switch(e){case 2:Yn(r,o,l,i,a,c);break;case 1:break;case 16:F(o,r);break;default:re(r,o,l,i,a,c)}break;case 16:switch(e){case 16:de(t,r,o);break;case 2:Rn(o),Yn(r,o,l,i,a,c);break;case 1:Rn(o);break;default:Rn(o),re(r,o,l,i,a,c)}break;default:switch(e){case 16:Wn(t),F(o,r);break;case 2:jn(o,u,t),Yn(r,o,l,i,a,c);break;case 1:jn(o,u,t);break;default:var s=0|t.length,f=0|r.length;0===s?f>0&&re(r,o,l,i,a,c):0===f?jn(o,u,t):8===e&&8===n?xe(t,r,o,l,i,s,f,a,u,c):Ue(t,r,o,l,i,s,f,a,c)}}}function be(n,e,t,r,o){o.push((function(){n.componentDidUpdate(e,t,r)}))}function $e(n,e,t,r,o,l,i,u,c){var f=n.state,d=n.props,p=Boolean(n.$N),h=a(n.shouldComponentUpdate);if(p&&(e=U(n,t,e!==f?s(f,e):e)),i||!h||h&&n.shouldComponentUpdate(t,e,o)){!p&&a(n.componentWillUpdate)&&n.componentWillUpdate(t,e,o),n.props=t,n.state=e,n.context=o;var v=null,m=qn(n,t,o);p&&a(n.getSnapshotBeforeUpdate)&&(v=n.getSnapshotBeforeUpdate(d,f)),fe(n.$LI,m,r,n.$CX,l,u,c),n.$LI=m,a(n.componentDidUpdate)&&be(n,d,f,v,c)}else n.props=t,n.state=e,n.context=o}function ke(n,e,t,r,o,l,i){var u=e.children=n.children;if(c(u))return;u.$L=i;var f=e.props||d,p=e.ref,h=n.ref,v=u.state;if(!u.$N){if(a(u.componentWillReceiveProps)){if(u.$BR=!0,u.componentWillReceiveProps(f,r),u.$UN)return;u.$BR=!1}c(u.$PS)||(v=s(v,u.$PS),u.$PS=null)}$e(u,v,f,t,r,o,!1,l,i),h!==p&&(An(h),Dn(p,u,i))}function Ce(n,e,t,r,o,i,u){var c=!0,s=e.props||d,f=e.ref,p=n.props,h=!l(f),v=n.children;if(h&&a(f.onComponentShouldUpdate)&&(c=f.onComponentShouldUpdate(p,s)),!1!==c){h&&a(f.onComponentWillUpdate)&&f.onComponentWillUpdate(p,s);var m=Q(zn(e,r));fe(v,m,t,r,o,i,u),e.children=m,h&&a(f.onComponentDidUpdate)&&f.onComponentDidUpdate(p,s)}else e.children=v}function we(n,e){var t=e.children,r=e.dom=n.dom;t!==n.children&&(r.nodeValue=t)}function Ue(n,e,t,r,o,l,i,a,u){for(var c,s,f=l>i?i:l,d=0;di)for(d=f;dd||h>p)break n;v=n[h],m=e[h]}for(v=n[d],m=e[p];v.key===m.key;){if(16384&m.flags&&(e[p]=m=R(m)),fe(v,m,t,r,o,a,c),n[d]=m,p--,h>--d||h>p)break n;v=n[d],m=e[p]}}if(h>d){if(h<=p)for(f=(s=p+1)p)for(;h<=d;)En(n[h++],t);else Pe(n,e,r,l,i,d,p,h,t,o,a,u,c)}function Pe(n,e,t,r,o,l,i,a,u,c,s,f,d){var p,h,v,m=0,g=a,y=a,b=l-a+1,$=i-a+1,C=new Int32Array($+1),U=b===r,x=!1,P=0,F=0;if(o<4||(b|$)<32)for(m=g;m<=l;++m)if(p=n[m],F<$){for(a=y;a<=i;a++)if(h=e[a],p.key===h.key){if(C[a-y]=m+1,U)for(U=!1;ga?x=!0:P=a,16384&h.flags&&(e[a]=h=R(h)),fe(p,h,u,t,c,s,d),++F;break}!U&&a>i&&En(p,u)}else U||En(p,u);else{var S={};for(m=y;m<=i;++m)S[e[m].key]=m;for(m=g;m<=l;++m)if(p=n[m],F<$)if(void 0!==(a=S[p.key])){if(U)for(U=!1;m>g;)En(n[g++],u);C[a-y]=m+1,P>a?x=!0:P=a,16384&(h=e[a]).flags&&(e[a]=h=R(h)),fe(p,h,u,t,c,s,d),++F}else U||En(p,u);else U||En(p,u)}if(U)jn(u,f,n),re(e,u,t,c,s,d);else if(x){var L=Se(C);for(a=L.length-1,m=$-1;m>=0;m--)0===C[m]?(16384&(h=e[P=m+y]).flags&&(e[P]=h=R(h)),Yn(h,u,t,c,(v=P+1)=0;m--)0===C[m]&&(16384&(h=e[P=m+y]).flags&&(e[P]=h=R(h)),Yn(h,u,t,c,(v=P+1)Fe&&(Fe=u,Fn=new Int32Array(u),Sn=new Int32Array(u));t>1]]0&&(Sn[t]=Fn[l-1]),Fn[l]=t)}l=o+1;var c=new Int32Array(l);for(i=Fn[l-1];l-- >0;)c[l]=i,i=Sn[i],Fn[l]=0;return c}function Le(n,e,t,r){var o=[],i=e.$V;x.v=!0,l(i)?l(n)||(16384&n.flags&&(n=R(n)),Yn(n,e,r,!1,null,o),e.$V=n,i=n):l(n)?(En(i,e),e.$V=null):(16384&n.flags&&(n=R(n)),fe(i,n,e,r,!1,null,o),i=e.$V=n),b(o),x.v=!1,a(t)&&t(),a(P.renderComplete)&&P.renderComplete(i,e)}function Ne(n,e,t,r){void 0===t&&(t=null),void 0===r&&(r=d),Le(n,e,t,r)}"undefined"!==typeof document&&window.Node&&(Node.prototype.$EV=null,Node.prototype.$V=null);var Ve=[],Ie="undefined"!==typeof Promise?Promise.resolve().then.bind(Promise.resolve()):function(n){window.setTimeout(n,0)},Be=!1;function Me(n,e,t,r){var o=n.$PS;if(a(e)&&(e=e(o?s(n.state,o):n.state,n.props,n.context)),l(o))n.$PS=e;else for(var i in e)o[i]=e[i];if(n.$BR)a(t)&&n.$L.push(t.bind(n));else{if(!x.v&&0===Ve.length)return De(n,r),void(a(t)&&t.call(n));if(-1===Ve.indexOf(n)&&Ve.push(n),r&&(n.$F=!0),Be||(Be=!0,Ie(Ae)),a(t)){var u=n.$QU;u||(u=n.$QU=[]),u.push(t)}}}function Te(n){for(var e=n.$QU,t=0;t 0; - var isNullKey = isNull(key); - var isPrefixed = isString(key) && key[0] === keyPrefix; - if (needsCloning || isNullKey || isPrefixed) { - newChildren = newChildren || children.slice(0, i); - if (needsCloning || isPrefixed) { - n = directClone(n); - } - if (isNullKey || isPrefixed) { - n.key = keyPrefix + i; - } - newChildren.push(n); - } - else if (newChildren) { - newChildren.push(n); - } - n.flags |= 65536 /* Normalized */; - } - } - newChildren = newChildren || children; - if (newChildren.length === 0) { - newChildFlags = 1 /* HasInvalidChildren */; - } - else { - newChildFlags = 8 /* HasKeyedChildren */; - } - } - else { - newChildren = children; - newChildren.flags |= 65536 /* Normalized */; - if (children.flags & 81920 /* InUseOrNormalized */) { - newChildren = directClone(children); - } - newChildFlags = 2 /* HasVNodeChildren */; - } - vNode.children = newChildren; - vNode.childFlags = newChildFlags; - return vNode; - } - function normalizeRoot(input) { - if (isInvalid(input) || isStringOrNumber(input)) { - return createTextVNode(input, null); - } - if (isArray(input)) { - return createFragment(input, 0 /* UnknownChildren */, null); - } - return input.flags & 16384 /* InUse */ ? directClone(input) : input; - } - - var xlinkNS = 'http://www.w3.org/1999/xlink'; - var xmlNS = 'http://www.w3.org/XML/1998/namespace'; - var namespaces = { - 'xlink:actuate': xlinkNS, - 'xlink:arcrole': xlinkNS, - 'xlink:href': xlinkNS, - 'xlink:role': xlinkNS, - 'xlink:show': xlinkNS, - 'xlink:title': xlinkNS, - 'xlink:type': xlinkNS, - 'xml:base': xmlNS, - 'xml:lang': xmlNS, - 'xml:space': xmlNS - }; - - function getDelegatedEventObject(v) { - return { - onClick: v, - onDblClick: v, - onFocusIn: v, - onFocusOut: v, - onKeyDown: v, - onKeyPress: v, - onKeyUp: v, - onMouseDown: v, - onMouseMove: v, - onMouseUp: v, - onTouchEnd: v, - onTouchMove: v, - onTouchStart: v - }; - } - var attachedEventCounts = getDelegatedEventObject(0); - var attachedEvents = getDelegatedEventObject(null); - var syntheticEvents = getDelegatedEventObject(true); - function updateOrAddSyntheticEvent(name, dom) { - var eventsObject = dom.$EV; - if (!eventsObject) { - eventsObject = dom.$EV = getDelegatedEventObject(null); - } - if (!eventsObject[name]) { - if (++attachedEventCounts[name] === 1) { - attachedEvents[name] = attachEventToDocument(name); - } - } - return eventsObject; - } - function unmountSyntheticEvent(name, dom) { - var eventsObject = dom.$EV; - if (eventsObject && eventsObject[name]) { - if (--attachedEventCounts[name] === 0) { - document.removeEventListener(normalizeEventName(name), attachedEvents[name]); - attachedEvents[name] = null; - } - eventsObject[name] = null; - } - } - function handleSyntheticEvent(name, lastEvent, nextEvent, dom) { - if (isFunction(nextEvent)) { - updateOrAddSyntheticEvent(name, dom)[name] = nextEvent; - } - else if (isLinkEventObject(nextEvent)) { - if (isLastValueSameLinkEvent(lastEvent, nextEvent)) { - return; - } - updateOrAddSyntheticEvent(name, dom)[name] = nextEvent; - } - else { - unmountSyntheticEvent(name, dom); - } - } - // When browsers fully support event.composedPath we could loop it through instead of using parentNode property - function getTargetNode(event) { - return isFunction(event.composedPath) ? event.composedPath()[0] : event.target; - } - function dispatchEvents(event, isClick, name, eventData) { - var dom = getTargetNode(event); - do { - // Html Nodes can be nested fe: span inside button in that scenario browser does not handle disabled attribute on parent, - // because the event listener is on document.body - // Don't process clicks on disabled elements - if (isClick && dom.disabled) { - return; - } - var eventsObject = dom.$EV; - if (eventsObject) { - var currentEvent = eventsObject[name]; - if (currentEvent) { - // linkEvent object - eventData.dom = dom; - currentEvent.event ? currentEvent.event(currentEvent.data, event) : currentEvent(event); - if (event.cancelBubble) { - return; - } - } - } - dom = dom.parentNode; - } while (!isNull(dom)); - } - function stopPropagation() { - this.cancelBubble = true; - if (!this.immediatePropagationStopped) { - this.stopImmediatePropagation(); - } - } - function isDefaultPrevented() { - return this.defaultPrevented; - } - function isPropagationStopped() { - return this.cancelBubble; - } - function extendEventProperties(event) { - // Event data needs to be object to save reference to currentTarget getter - var eventData = { - dom: document - }; - event.isDefaultPrevented = isDefaultPrevented; - event.isPropagationStopped = isPropagationStopped; - event.stopPropagation = stopPropagation; - Object.defineProperty(event, 'currentTarget', { - configurable: true, - get: function get() { - return eventData.dom; - } - }); - return eventData; - } - function rootClickEvent(name) { - return function (event) { - if (event.button !== 0) { - // Firefox incorrectly triggers click event for mid/right mouse buttons. - // This bug has been active for 17 years. - // https://bugzilla.mozilla.org/show_bug.cgi?id=184051 - event.stopPropagation(); - return; - } - dispatchEvents(event, true, name, extendEventProperties(event)); - }; - } - function rootEvent(name) { - return function (event) { - dispatchEvents(event, false, name, extendEventProperties(event)); - }; - } - function attachEventToDocument(name) { - var attachedEvent = name === 'onClick' || name === 'onDblClick' ? rootClickEvent(name) : rootEvent(name); - document.addEventListener(normalizeEventName(name), attachedEvent); - return attachedEvent; - } - - function isSameInnerHTML(dom, innerHTML) { - var tempdom = document.createElement('i'); - tempdom.innerHTML = innerHTML; - return tempdom.innerHTML === dom.innerHTML; - } - - function triggerEventListener(props, methodName, e) { - if (props[methodName]) { - var listener = props[methodName]; - if (listener.event) { - listener.event(listener.data, e); - } - else { - listener(e); - } - } - else { - var nativeListenerName = methodName.toLowerCase(); - if (props[nativeListenerName]) { - props[nativeListenerName](e); - } - } - } - function createWrappedFunction(methodName, applyValue) { - var fnMethod = function (e) { - var vNode = this.$V; - // If vNode is gone by the time event fires, no-op - if (!vNode) { - return; - } - var props = vNode.props || EMPTY_OBJ; - var dom = vNode.dom; - if (isString(methodName)) { - triggerEventListener(props, methodName, e); - } - else { - for (var i = 0; i < methodName.length; ++i) { - triggerEventListener(props, methodName[i], e); - } - } - if (isFunction(applyValue)) { - var newVNode = this.$V; - var newProps = newVNode.props || EMPTY_OBJ; - applyValue(newProps, dom, false, newVNode); - } - }; - Object.defineProperty(fnMethod, 'wrapped', { - configurable: false, - enumerable: false, - value: true, - writable: false - }); - return fnMethod; - } - - function attachEvent(dom, eventName, handler) { - var previousKey = "$" + eventName; - var previousArgs = dom[previousKey]; - if (previousArgs) { - if (previousArgs[1].wrapped) { - return; - } - dom.removeEventListener(previousArgs[0], previousArgs[1]); - dom[previousKey] = null; - } - if (isFunction(handler)) { - dom.addEventListener(eventName, handler); - dom[previousKey] = [eventName, handler]; - } - } - - function isCheckedType(type) { - return type === 'checkbox' || type === 'radio'; - } - var onTextInputChange = createWrappedFunction('onInput', applyValueInput); - var wrappedOnChange = createWrappedFunction(['onClick', 'onChange'], applyValueInput); - /* tslint:disable-next-line:no-empty */ - function emptywrapper(event) { - event.stopPropagation(); - } - emptywrapper.wrapped = true; - function inputEvents(dom, nextPropsOrEmpty) { - if (isCheckedType(nextPropsOrEmpty.type)) { - attachEvent(dom, 'change', wrappedOnChange); - attachEvent(dom, 'click', emptywrapper); - } - else { - attachEvent(dom, 'input', onTextInputChange); - } - } - function applyValueInput(nextPropsOrEmpty, dom) { - var type = nextPropsOrEmpty.type; - var value = nextPropsOrEmpty.value; - var checked = nextPropsOrEmpty.checked; - var multiple = nextPropsOrEmpty.multiple; - var defaultValue = nextPropsOrEmpty.defaultValue; - var hasValue = !isNullOrUndef(value); - if (type && type !== dom.type) { - dom.setAttribute('type', type); - } - if (!isNullOrUndef(multiple) && multiple !== dom.multiple) { - dom.multiple = multiple; - } - if (!isNullOrUndef(defaultValue) && !hasValue) { - dom.defaultValue = defaultValue + ''; - } - if (isCheckedType(type)) { - if (hasValue) { - dom.value = value; - } - if (!isNullOrUndef(checked)) { - dom.checked = checked; - } - } - else { - if (hasValue && dom.value !== value) { - dom.defaultValue = value; - dom.value = value; - } - else if (!isNullOrUndef(checked)) { - dom.checked = checked; - } - } - } - - function updateChildOptions(vNode, value) { - if (vNode.type === 'option') { - updateChildOption(vNode, value); - } - else { - var children = vNode.children; - var flags = vNode.flags; - if (flags & 4 /* ComponentClass */) { - updateChildOptions(children.$LI, value); - } - else if (flags & 8 /* ComponentFunction */) { - updateChildOptions(children, value); - } - else if (vNode.childFlags === 2 /* HasVNodeChildren */) { - updateChildOptions(children, value); - } - else if (vNode.childFlags & 12 /* MultipleChildren */) { - for (var i = 0, len = children.length; i < len; ++i) { - updateChildOptions(children[i], value); - } - } - } - } - function updateChildOption(vNode, value) { - var props = vNode.props || EMPTY_OBJ; - var dom = vNode.dom; - // we do this as multiple may have changed - dom.value = props.value; - if (props.value === value || (isArray(value) && value.indexOf(props.value) !== -1)) { - dom.selected = true; - } - else if (!isNullOrUndef(value) || !isNullOrUndef(props.selected)) { - dom.selected = props.selected || false; - } - } - var onSelectChange = createWrappedFunction('onChange', applyValueSelect); - function selectEvents(dom) { - attachEvent(dom, 'change', onSelectChange); - } - function applyValueSelect(nextPropsOrEmpty, dom, mounting, vNode) { - var multiplePropInBoolean = Boolean(nextPropsOrEmpty.multiple); - if (!isNullOrUndef(nextPropsOrEmpty.multiple) && multiplePropInBoolean !== dom.multiple) { - dom.multiple = multiplePropInBoolean; - } - var index = nextPropsOrEmpty.selectedIndex; - if (index === -1) { - dom.selectedIndex = -1; - } - var childFlags = vNode.childFlags; - if (childFlags !== 1 /* HasInvalidChildren */) { - var value = nextPropsOrEmpty.value; - if (isNumber(index) && index > -1 && dom.options[index]) { - value = dom.options[index].value; - } - if (mounting && isNullOrUndef(value)) { - value = nextPropsOrEmpty.defaultValue; - } - updateChildOptions(vNode, value); - } - } - - var onTextareaInputChange = createWrappedFunction('onInput', applyValueTextArea); - var wrappedOnChange$1 = createWrappedFunction('onChange'); - function textAreaEvents(dom, nextPropsOrEmpty) { - attachEvent(dom, 'input', onTextareaInputChange); - if (nextPropsOrEmpty.onChange) { - attachEvent(dom, 'change', wrappedOnChange$1); - } - } - function applyValueTextArea(nextPropsOrEmpty, dom, mounting) { - var value = nextPropsOrEmpty.value; - var domValue = dom.value; - if (isNullOrUndef(value)) { - if (mounting) { - var defaultValue = nextPropsOrEmpty.defaultValue; - if (!isNullOrUndef(defaultValue) && defaultValue !== domValue) { - dom.defaultValue = defaultValue; - dom.value = defaultValue; - } - } - } - else if (domValue !== value) { - /* There is value so keep it controlled */ - dom.defaultValue = value; - dom.value = value; - } - } - - function processElement(flags, vNode, dom, nextPropsOrEmpty, mounting, isControlled) { - if (flags & 64 /* InputElement */) { - applyValueInput(nextPropsOrEmpty, dom); - } - else if (flags & 256 /* SelectElement */) { - applyValueSelect(nextPropsOrEmpty, dom, mounting, vNode); - } - else if (flags & 128 /* TextareaElement */) { - applyValueTextArea(nextPropsOrEmpty, dom, mounting); - } - if (isControlled) { - dom.$V = vNode; - } - } - function addFormElementEventHandlers(flags, dom, nextPropsOrEmpty) { - if (flags & 64 /* InputElement */) { - inputEvents(dom, nextPropsOrEmpty); - } - else if (flags & 256 /* SelectElement */) { - selectEvents(dom); - } - else if (flags & 128 /* TextareaElement */) { - textAreaEvents(dom, nextPropsOrEmpty); - } - } - function isControlledFormElement(nextPropsOrEmpty) { - return nextPropsOrEmpty.type && isCheckedType(nextPropsOrEmpty.type) ? !isNullOrUndef(nextPropsOrEmpty.checked) : !isNullOrUndef(nextPropsOrEmpty.value); - } - function unmountRef(ref) { - if (ref) { - if (!safeCall1(ref, null) && ref.current) { - ref.current = null; - } - } - } - function mountRef(ref, value, lifecycle) { - if (ref && (isFunction(ref) || ref.current !== void 0)) { - lifecycle.push(function () { - if (!safeCall1(ref, value) && ref.current !== void 0) { - ref.current = value; - } - }); - } - } - - function remove(vNode, parentDOM) { - unmount(vNode); - removeVNodeDOM(vNode, parentDOM); - } - function unmount(vNode) { - var flags = vNode.flags; - var children = vNode.children; - var ref; - if (flags & 481 /* Element */) { - ref = vNode.ref; - var props = vNode.props; - unmountRef(ref); - var childFlags = vNode.childFlags; - if (!isNull(props)) { - var keys = Object.keys(props); - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i]; - if (syntheticEvents[key]) { - unmountSyntheticEvent(key, vNode.dom); - } - } - } - if (childFlags & 12 /* MultipleChildren */) { - unmountAllChildren(children); - } - else if (childFlags === 2 /* HasVNodeChildren */) { - unmount(children); - } - } - else if (children) { - if (flags & 4 /* ComponentClass */) { - if (isFunction(children.componentWillUnmount)) { - children.componentWillUnmount(); - } - unmountRef(vNode.ref); - children.$UN = true; - unmount(children.$LI); - } - else if (flags & 8 /* ComponentFunction */) { - ref = vNode.ref; - if (!isNullOrUndef(ref) && isFunction(ref.onComponentWillUnmount)) { - ref.onComponentWillUnmount(findDOMfromVNode(vNode, true), vNode.props || EMPTY_OBJ); - } - unmount(children); - } - else if (flags & 1024 /* Portal */) { - remove(children, vNode.ref); - } - else if (flags & 8192 /* Fragment */) { - if (vNode.childFlags & 12 /* MultipleChildren */) { - unmountAllChildren(children); - } - } - } - } - function unmountAllChildren(children) { - for (var i = 0, len = children.length; i < len; ++i) { - unmount(children[i]); - } - } - function clearDOM(dom) { - // Optimization for clearing dom - dom.textContent = ''; - } - function removeAllChildren(dom, vNode, children) { - unmountAllChildren(children); - if (vNode.flags & 8192 /* Fragment */) { - removeVNodeDOM(vNode, dom); - } - else { - clearDOM(dom); - } - } - - function wrapLinkEvent(nextValue) { - // This variable makes sure there is no "this" context in callback - var ev = nextValue.event; - return function (e) { - ev(nextValue.data, e); - }; - } - function patchEvent(name, lastValue, nextValue, dom) { - if (isLinkEventObject(nextValue)) { - if (isLastValueSameLinkEvent(lastValue, nextValue)) { - return; - } - nextValue = wrapLinkEvent(nextValue); - } - attachEvent(dom, normalizeEventName(name), nextValue); - } - // We are assuming here that we come from patchProp routine - // -nextAttrValue cannot be null or undefined - function patchStyle(lastAttrValue, nextAttrValue, dom) { - if (isNullOrUndef(nextAttrValue)) { - dom.removeAttribute('style'); - return; - } - var domStyle = dom.style; - var style; - var value; - if (isString(nextAttrValue)) { - domStyle.cssText = nextAttrValue; - return; - } - if (!isNullOrUndef(lastAttrValue) && !isString(lastAttrValue)) { - for (style in nextAttrValue) { - // do not add a hasOwnProperty check here, it affects performance - value = nextAttrValue[style]; - if (value !== lastAttrValue[style]) { - domStyle.setProperty(style, value); - } - } - for (style in lastAttrValue) { - if (isNullOrUndef(nextAttrValue[style])) { - domStyle.removeProperty(style); - } - } - } - else { - for (style in nextAttrValue) { - value = nextAttrValue[style]; - domStyle.setProperty(style, value); - } - } - } - function patchDangerInnerHTML(lastValue, nextValue, lastVNode, dom) { - var lastHtml = (lastValue && lastValue.__html) || ''; - var nextHtml = (nextValue && nextValue.__html) || ''; - if (lastHtml !== nextHtml) { - if (!isNullOrUndef(nextHtml) && !isSameInnerHTML(dom, nextHtml)) { - if (!isNull(lastVNode)) { - if (lastVNode.childFlags & 12 /* MultipleChildren */) { - unmountAllChildren(lastVNode.children); - } - else if (lastVNode.childFlags === 2 /* HasVNodeChildren */) { - unmount(lastVNode.children); - } - lastVNode.children = null; - lastVNode.childFlags = 1 /* HasInvalidChildren */; - } - dom.innerHTML = nextHtml; - } - } - } - function patchProp(prop, lastValue, nextValue, dom, isSVG, hasControlledValue, lastVNode) { - switch (prop) { - case 'children': - case 'childrenType': - case 'className': - case 'defaultValue': - case 'key': - case 'multiple': - case 'ref': - case 'selectedIndex': - break; - case 'autoFocus': - dom.autofocus = !!nextValue; - break; - case 'allowfullscreen': - case 'autoplay': - case 'capture': - case 'checked': - case 'controls': - case 'default': - case 'disabled': - case 'hidden': - case 'indeterminate': - case 'loop': - case 'muted': - case 'novalidate': - case 'open': - case 'readOnly': - case 'required': - case 'reversed': - case 'scoped': - case 'seamless': - case 'selected': - dom[prop] = !!nextValue; - break; - case 'defaultChecked': - case 'value': - case 'volume': - if (hasControlledValue && prop === 'value') { - break; - } - var value = isNullOrUndef(nextValue) ? '' : nextValue; - if (dom[prop] !== value) { - dom[prop] = value; - } - break; - case 'style': - patchStyle(lastValue, nextValue, dom); - break; - case 'dangerouslySetInnerHTML': - patchDangerInnerHTML(lastValue, nextValue, lastVNode, dom); - break; - default: - if (syntheticEvents[prop]) { - handleSyntheticEvent(prop, lastValue, nextValue, dom); - } - else if (prop.charCodeAt(0) === 111 && prop.charCodeAt(1) === 110) { - patchEvent(prop, lastValue, nextValue, dom); - } - else if (isNullOrUndef(nextValue)) { - dom.removeAttribute(prop); - } - else if (isSVG && namespaces[prop]) { - // We optimize for isSVG being false - // If we end up in this path we can read property again - dom.setAttributeNS(namespaces[prop], prop, nextValue); - } - else { - dom.setAttribute(prop, nextValue); - } - break; - } - } - function mountProps(vNode, flags, props, dom, isSVG) { - var hasControlledValue = false; - var isFormElement = (flags & 448 /* FormElement */) > 0; - if (isFormElement) { - hasControlledValue = isControlledFormElement(props); - if (hasControlledValue) { - addFormElementEventHandlers(flags, dom, props); - } - } - for (var prop in props) { - // do not add a hasOwnProperty check here, it affects performance - patchProp(prop, null, props[prop], dom, isSVG, hasControlledValue, null); - } - if (isFormElement) { - processElement(flags, vNode, dom, props, true, hasControlledValue); - } - } - - function renderNewInput(instance, props, context) { - var nextInput = normalizeRoot(instance.render(props, instance.state, context)); - var childContext = context; - if (isFunction(instance.getChildContext)) { - childContext = combineFrom(context, instance.getChildContext()); - } - instance.$CX = childContext; - return nextInput; - } - function createClassComponentInstance(vNode, Component, props, context, isSVG, lifecycle) { - var instance = new Component(props, context); - var usesNewAPI = (instance.$N = Boolean(Component.getDerivedStateFromProps || instance.getSnapshotBeforeUpdate)); - instance.$SVG = isSVG; - instance.$L = lifecycle; - vNode.children = instance; - instance.$BS = false; - instance.context = context; - if (instance.props === EMPTY_OBJ) { - instance.props = props; - } - if (!usesNewAPI) { - if (isFunction(instance.componentWillMount)) { - instance.$BR = true; - instance.componentWillMount(); - var pending = instance.$PS; - if (!isNull(pending)) { - var state = instance.state; - if (isNull(state)) { - instance.state = pending; - } - else { - for (var key in pending) { - state[key] = pending[key]; - } - } - instance.$PS = null; - } - instance.$BR = false; - } - } - else { - instance.state = createDerivedState(instance, props, instance.state); - } - instance.$LI = renderNewInput(instance, props, context); - return instance; - } - function renderFunctionalComponent(vNode, context) { - var props = vNode.props || EMPTY_OBJ; - return vNode.flags & 32768 /* ForwardRef */ ? vNode.type.render(props, vNode.ref, context) : vNode.type(props, context); - } - - function mount(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var flags = (vNode.flags |= 16384 /* InUse */); - if (flags & 481 /* Element */) { - mountElement(vNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (flags & 4 /* ComponentClass */) { - mountClassComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (flags & 8 /* ComponentFunction */) { - mountFunctionalComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle); - mountFunctionalComponentCallbacks(vNode, lifecycle); - } - else if (flags & 512 /* Void */ || flags & 16 /* Text */) { - mountText(vNode, parentDOM, nextNode); - } - else if (flags & 8192 /* Fragment */) { - mountFragment(vNode, context, parentDOM, isSVG, nextNode, lifecycle); - } - else if (flags & 1024 /* Portal */) { - mountPortal(vNode, context, parentDOM, nextNode, lifecycle); - } - else ; - } - function mountPortal(vNode, context, parentDOM, nextNode, lifecycle) { - mount(vNode.children, vNode.ref, context, false, null, lifecycle); - var placeHolderVNode = createVoidVNode(); - mountText(placeHolderVNode, parentDOM, nextNode); - vNode.dom = placeHolderVNode.dom; - } - function mountFragment(vNode, context, parentDOM, isSVG, nextNode, lifecycle) { - var children = vNode.children; - var childFlags = vNode.childFlags; - // When fragment is optimized for multiple children, check if there is no children and change flag to invalid - // This is the only normalization always done, to keep optimization flags API same for fragments and regular elements - if (childFlags & 12 /* MultipleChildren */ && children.length === 0) { - childFlags = vNode.childFlags = 2 /* HasVNodeChildren */; - children = vNode.children = createVoidVNode(); - } - if (childFlags === 2 /* HasVNodeChildren */) { - mount(children, parentDOM, nextNode, isSVG, nextNode, lifecycle); - } - else { - mountArrayChildren(children, parentDOM, context, isSVG, nextNode, lifecycle); - } - } - function mountText(vNode, parentDOM, nextNode) { - var dom = (vNode.dom = document.createTextNode(vNode.children)); - if (!isNull(parentDOM)) { - insertOrAppend(parentDOM, dom, nextNode); - } - } - function mountElement(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var flags = vNode.flags; - var props = vNode.props; - var className = vNode.className; - var childFlags = vNode.childFlags; - var dom = (vNode.dom = documentCreateElement(vNode.type, (isSVG = isSVG || (flags & 32 /* SvgElement */) > 0))); - var children = vNode.children; - if (!isNullOrUndef(className) && className !== '') { - if (isSVG) { - dom.setAttribute('class', className); - } - else { - dom.className = className; - } - } - if (childFlags === 16 /* HasTextChildren */) { - setTextContent(dom, children); - } - else if (childFlags !== 1 /* HasInvalidChildren */) { - var childrenIsSVG = isSVG && vNode.type !== 'foreignObject'; - if (childFlags === 2 /* HasVNodeChildren */) { - if (children.flags & 16384 /* InUse */) { - vNode.children = children = directClone(children); - } - mount(children, dom, context, childrenIsSVG, null, lifecycle); - } - else if (childFlags === 8 /* HasKeyedChildren */ || childFlags === 4 /* HasNonKeyedChildren */) { - mountArrayChildren(children, dom, context, childrenIsSVG, null, lifecycle); - } - } - if (!isNull(parentDOM)) { - insertOrAppend(parentDOM, dom, nextNode); - } - if (!isNull(props)) { - mountProps(vNode, flags, props, dom, isSVG); - } - mountRef(vNode.ref, dom, lifecycle); - } - function mountArrayChildren(children, dom, context, isSVG, nextNode, lifecycle) { - for (var i = 0; i < children.length; ++i) { - var child = children[i]; - if (child.flags & 16384 /* InUse */) { - children[i] = child = directClone(child); - } - mount(child, dom, context, isSVG, nextNode, lifecycle); - } - } - function mountClassComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var instance = createClassComponentInstance(vNode, vNode.type, vNode.props || EMPTY_OBJ, context, isSVG, lifecycle); - mount(instance.$LI, parentDOM, instance.$CX, isSVG, nextNode, lifecycle); - mountClassComponentCallbacks(vNode.ref, instance, lifecycle); - } - function mountFunctionalComponent(vNode, parentDOM, context, isSVG, nextNode, lifecycle) { - mount((vNode.children = normalizeRoot(renderFunctionalComponent(vNode, context))), parentDOM, context, isSVG, nextNode, lifecycle); - } - function createClassMountCallback(instance) { - return function () { - instance.componentDidMount(); - }; - } - function mountClassComponentCallbacks(ref, instance, lifecycle) { - mountRef(ref, instance, lifecycle); - if (isFunction(instance.componentDidMount)) { - lifecycle.push(createClassMountCallback(instance)); - } - } - function createOnMountCallback(ref, vNode) { - return function () { - ref.onComponentDidMount(findDOMfromVNode(vNode, true), vNode.props || EMPTY_OBJ); - }; - } - function mountFunctionalComponentCallbacks(vNode, lifecycle) { - var ref = vNode.ref; - if (!isNullOrUndef(ref)) { - safeCall1(ref.onComponentWillMount, vNode.props || EMPTY_OBJ); - if (isFunction(ref.onComponentDidMount)) { - lifecycle.push(createOnMountCallback(ref, vNode)); - } - } - } - - function replaceWithNewNode(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle) { - unmount(lastVNode); - if ((nextVNode.flags & lastVNode.flags & 2033 /* DOMRef */) !== 0) { - mount(nextVNode, null, context, isSVG, null, lifecycle); - // Single DOM operation, when we have dom references available - replaceChild(parentDOM, nextVNode.dom, lastVNode.dom); - } - else { - mount(nextVNode, parentDOM, context, isSVG, findDOMfromVNode(lastVNode, true), lifecycle); - removeVNodeDOM(lastVNode, parentDOM); - } - } - function patch(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var nextFlags = (nextVNode.flags |= 16384 /* InUse */); - if (lastVNode.flags !== nextFlags || lastVNode.type !== nextVNode.type || lastVNode.key !== nextVNode.key || nextFlags & 2048 /* ReCreate */) { - if (lastVNode.flags & 16384 /* InUse */) { - replaceWithNewNode(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle); - } - else { - // Last vNode is not in use, it has crashed at application level. Just mount nextVNode and ignore last one - mount(nextVNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - } - else if (nextFlags & 481 /* Element */) { - patchElement(lastVNode, nextVNode, context, isSVG, nextFlags, lifecycle); - } - else if (nextFlags & 4 /* ComponentClass */) { - patchClassComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (nextFlags & 8 /* ComponentFunction */) { - patchFunctionalComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle); - } - else if (nextFlags & 16 /* Text */) { - patchText(lastVNode, nextVNode); - } - else if (nextFlags & 512 /* Void */) { - nextVNode.dom = lastVNode.dom; - } - else if (nextFlags & 8192 /* Fragment */) { - patchFragment(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle); - } - else { - patchPortal(lastVNode, nextVNode, context, lifecycle); - } - } - function patchSingleTextChild(lastChildren, nextChildren, parentDOM) { - if (lastChildren !== nextChildren) { - if (lastChildren !== '') { - parentDOM.firstChild.nodeValue = nextChildren; - } - else { - setTextContent(parentDOM, nextChildren); - } - } - } - function patchContentEditableChildren(dom, nextChildren) { - if (dom.textContent !== nextChildren) { - dom.textContent = nextChildren; - } - } - function patchFragment(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle) { - var lastChildren = lastVNode.children; - var nextChildren = nextVNode.children; - var lastChildFlags = lastVNode.childFlags; - var nextChildFlags = nextVNode.childFlags; - var nextNode = null; - // When fragment is optimized for multiple children, check if there is no children and change flag to invalid - // This is the only normalization always done, to keep optimization flags API same for fragments and regular elements - if (nextChildFlags & 12 /* MultipleChildren */ && nextChildren.length === 0) { - nextChildFlags = nextVNode.childFlags = 2 /* HasVNodeChildren */; - nextChildren = nextVNode.children = createVoidVNode(); - } - var nextIsSingle = (nextChildFlags & 2 /* HasVNodeChildren */) !== 0; - if (lastChildFlags & 12 /* MultipleChildren */) { - var lastLen = lastChildren.length; - // We need to know Fragment's edge node when - if ( - // It uses keyed algorithm - (lastChildFlags & 8 /* HasKeyedChildren */ && nextChildFlags & 8 /* HasKeyedChildren */) || - // It transforms from many to single - nextIsSingle || - // It will append more nodes - (!nextIsSingle && nextChildren.length > lastLen)) { - // When fragment has multiple children there is always at least one vNode - nextNode = findDOMfromVNode(lastChildren[lastLen - 1], false).nextSibling; - } - } - patchChildren(lastChildFlags, nextChildFlags, lastChildren, nextChildren, parentDOM, context, isSVG, nextNode, lastVNode, lifecycle); - } - function patchPortal(lastVNode, nextVNode, context, lifecycle) { - var lastContainer = lastVNode.ref; - var nextContainer = nextVNode.ref; - var nextChildren = nextVNode.children; - patchChildren(lastVNode.childFlags, nextVNode.childFlags, lastVNode.children, nextChildren, lastContainer, context, false, null, lastVNode, lifecycle); - nextVNode.dom = lastVNode.dom; - if (lastContainer !== nextContainer && !isInvalid(nextChildren)) { - var node = nextChildren.dom; - removeChild(lastContainer, node); - appendChild(nextContainer, node); - } - } - function patchElement(lastVNode, nextVNode, context, isSVG, nextFlags, lifecycle) { - var dom = (nextVNode.dom = lastVNode.dom); - var lastProps = lastVNode.props; - var nextProps = nextVNode.props; - var isFormElement = false; - var hasControlledValue = false; - var nextPropsOrEmpty; - isSVG = isSVG || (nextFlags & 32 /* SvgElement */) > 0; - // inlined patchProps -- starts -- - if (lastProps !== nextProps) { - var lastPropsOrEmpty = lastProps || EMPTY_OBJ; - nextPropsOrEmpty = nextProps || EMPTY_OBJ; - if (nextPropsOrEmpty !== EMPTY_OBJ) { - isFormElement = (nextFlags & 448 /* FormElement */) > 0; - if (isFormElement) { - hasControlledValue = isControlledFormElement(nextPropsOrEmpty); - } - for (var prop in nextPropsOrEmpty) { - var lastValue = lastPropsOrEmpty[prop]; - var nextValue = nextPropsOrEmpty[prop]; - if (lastValue !== nextValue) { - patchProp(prop, lastValue, nextValue, dom, isSVG, hasControlledValue, lastVNode); - } - } - } - if (lastPropsOrEmpty !== EMPTY_OBJ) { - for (var prop$1 in lastPropsOrEmpty) { - if (isNullOrUndef(nextPropsOrEmpty[prop$1]) && !isNullOrUndef(lastPropsOrEmpty[prop$1])) { - patchProp(prop$1, lastPropsOrEmpty[prop$1], null, dom, isSVG, hasControlledValue, lastVNode); - } - } - } - } - var nextChildren = nextVNode.children; - var nextClassName = nextVNode.className; - // inlined patchProps -- ends -- - if (lastVNode.className !== nextClassName) { - if (isNullOrUndef(nextClassName)) { - dom.removeAttribute('class'); - } - else if (isSVG) { - dom.setAttribute('class', nextClassName); - } - else { - dom.className = nextClassName; - } - } - if (nextFlags & 4096 /* ContentEditable */) { - patchContentEditableChildren(dom, nextChildren); - } - else { - patchChildren(lastVNode.childFlags, nextVNode.childFlags, lastVNode.children, nextChildren, dom, context, isSVG && nextVNode.type !== 'foreignObject', null, lastVNode, lifecycle); - } - if (isFormElement) { - processElement(nextFlags, nextVNode, dom, nextPropsOrEmpty, false, hasControlledValue); - } - var nextRef = nextVNode.ref; - var lastRef = lastVNode.ref; - if (lastRef !== nextRef) { - unmountRef(lastRef); - mountRef(nextRef, dom, lifecycle); - } - } - function replaceOneVNodeWithMultipleVNodes(lastChildren, nextChildren, parentDOM, context, isSVG, lifecycle) { - unmount(lastChildren); - mountArrayChildren(nextChildren, parentDOM, context, isSVG, findDOMfromVNode(lastChildren, true), lifecycle); - removeVNodeDOM(lastChildren, parentDOM); - } - function patchChildren(lastChildFlags, nextChildFlags, lastChildren, nextChildren, parentDOM, context, isSVG, nextNode, parentVNode, lifecycle) { - switch (lastChildFlags) { - case 2 /* HasVNodeChildren */: - switch (nextChildFlags) { - case 2 /* HasVNodeChildren */: - patch(lastChildren, nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - remove(lastChildren, parentDOM); - break; - case 16 /* HasTextChildren */: - unmount(lastChildren); - setTextContent(parentDOM, nextChildren); - break; - default: - replaceOneVNodeWithMultipleVNodes(lastChildren, nextChildren, parentDOM, context, isSVG, lifecycle); - break; - } - break; - case 1 /* HasInvalidChildren */: - switch (nextChildFlags) { - case 2 /* HasVNodeChildren */: - mount(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - break; - case 16 /* HasTextChildren */: - setTextContent(parentDOM, nextChildren); - break; - default: - mountArrayChildren(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - } - break; - case 16 /* HasTextChildren */: - switch (nextChildFlags) { - case 16 /* HasTextChildren */: - patchSingleTextChild(lastChildren, nextChildren, parentDOM); - break; - case 2 /* HasVNodeChildren */: - clearDOM(parentDOM); - mount(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - clearDOM(parentDOM); - break; - default: - clearDOM(parentDOM); - mountArrayChildren(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - } - break; - default: - switch (nextChildFlags) { - case 16 /* HasTextChildren */: - unmountAllChildren(lastChildren); - setTextContent(parentDOM, nextChildren); - break; - case 2 /* HasVNodeChildren */: - removeAllChildren(parentDOM, parentVNode, lastChildren); - mount(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - break; - case 1 /* HasInvalidChildren */: - removeAllChildren(parentDOM, parentVNode, lastChildren); - break; - default: - var lastLength = lastChildren.length | 0; - var nextLength = nextChildren.length | 0; - // Fast path's for both algorithms - if (lastLength === 0) { - if (nextLength > 0) { - mountArrayChildren(nextChildren, parentDOM, context, isSVG, nextNode, lifecycle); - } - } - else if (nextLength === 0) { - removeAllChildren(parentDOM, parentVNode, lastChildren); - } - else if (nextChildFlags === 8 /* HasKeyedChildren */ && lastChildFlags === 8 /* HasKeyedChildren */) { - patchKeyedChildren(lastChildren, nextChildren, parentDOM, context, isSVG, lastLength, nextLength, nextNode, parentVNode, lifecycle); - } - else { - patchNonKeyedChildren(lastChildren, nextChildren, parentDOM, context, isSVG, lastLength, nextLength, nextNode, lifecycle); - } - break; - } - break; - } - } - function createDidUpdate(instance, lastProps, lastState, snapshot, lifecycle) { - lifecycle.push(function () { - instance.componentDidUpdate(lastProps, lastState, snapshot); - }); - } - function updateClassComponent(instance, nextState, nextProps, parentDOM, context, isSVG, force, nextNode, lifecycle) { - var lastState = instance.state; - var lastProps = instance.props; - var usesNewAPI = Boolean(instance.$N); - var hasSCU = isFunction(instance.shouldComponentUpdate); - if (usesNewAPI) { - nextState = createDerivedState(instance, nextProps, nextState !== lastState ? combineFrom(lastState, nextState) : nextState); - } - if (force || !hasSCU || (hasSCU && instance.shouldComponentUpdate(nextProps, nextState, context))) { - if (!usesNewAPI && isFunction(instance.componentWillUpdate)) { - instance.componentWillUpdate(nextProps, nextState, context); - } - instance.props = nextProps; - instance.state = nextState; - instance.context = context; - var snapshot = null; - var nextInput = renderNewInput(instance, nextProps, context); - if (usesNewAPI && isFunction(instance.getSnapshotBeforeUpdate)) { - snapshot = instance.getSnapshotBeforeUpdate(lastProps, lastState); - } - patch(instance.$LI, nextInput, parentDOM, instance.$CX, isSVG, nextNode, lifecycle); - // Dont update Last input, until patch has been succesfully executed - instance.$LI = nextInput; - if (isFunction(instance.componentDidUpdate)) { - createDidUpdate(instance, lastProps, lastState, snapshot, lifecycle); - } - } - else { - instance.props = nextProps; - instance.state = nextState; - instance.context = context; - } - } - function patchClassComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var instance = (nextVNode.children = lastVNode.children); - // If Component has crashed, ignore it to stay functional - if (isNull(instance)) { - return; - } - instance.$L = lifecycle; - var nextProps = nextVNode.props || EMPTY_OBJ; - var nextRef = nextVNode.ref; - var lastRef = lastVNode.ref; - var nextState = instance.state; - if (!instance.$N) { - if (isFunction(instance.componentWillReceiveProps)) { - instance.$BR = true; - instance.componentWillReceiveProps(nextProps, context); - // If instance component was removed during its own update do nothing. - if (instance.$UN) { - return; - } - instance.$BR = false; - } - if (!isNull(instance.$PS)) { - nextState = combineFrom(nextState, instance.$PS); - instance.$PS = null; - } - } - updateClassComponent(instance, nextState, nextProps, parentDOM, context, isSVG, false, nextNode, lifecycle); - if (lastRef !== nextRef) { - unmountRef(lastRef); - mountRef(nextRef, instance, lifecycle); - } - } - function patchFunctionalComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle) { - var shouldUpdate = true; - var nextProps = nextVNode.props || EMPTY_OBJ; - var nextRef = nextVNode.ref; - var lastProps = lastVNode.props; - var nextHooksDefined = !isNullOrUndef(nextRef); - var lastInput = lastVNode.children; - if (nextHooksDefined && isFunction(nextRef.onComponentShouldUpdate)) { - shouldUpdate = nextRef.onComponentShouldUpdate(lastProps, nextProps); - } - if (shouldUpdate !== false) { - if (nextHooksDefined && isFunction(nextRef.onComponentWillUpdate)) { - nextRef.onComponentWillUpdate(lastProps, nextProps); - } - var nextInput = normalizeRoot(renderFunctionalComponent(nextVNode, context)); - patch(lastInput, nextInput, parentDOM, context, isSVG, nextNode, lifecycle); - nextVNode.children = nextInput; - if (nextHooksDefined && isFunction(nextRef.onComponentDidUpdate)) { - nextRef.onComponentDidUpdate(lastProps, nextProps); - } - } - else { - nextVNode.children = lastInput; - } - } - function patchText(lastVNode, nextVNode) { - var nextText = nextVNode.children; - var dom = (nextVNode.dom = lastVNode.dom); - if (nextText !== lastVNode.children) { - dom.nodeValue = nextText; - } - } - function patchNonKeyedChildren(lastChildren, nextChildren, dom, context, isSVG, lastChildrenLength, nextChildrenLength, nextNode, lifecycle) { - var commonLength = lastChildrenLength > nextChildrenLength ? nextChildrenLength : lastChildrenLength; - var i = 0; - var nextChild; - var lastChild; - for (; i < commonLength; ++i) { - nextChild = nextChildren[i]; - lastChild = lastChildren[i]; - if (nextChild.flags & 16384 /* InUse */) { - nextChild = nextChildren[i] = directClone(nextChild); - } - patch(lastChild, nextChild, dom, context, isSVG, nextNode, lifecycle); - lastChildren[i] = nextChild; - } - if (lastChildrenLength < nextChildrenLength) { - for (i = commonLength; i < nextChildrenLength; ++i) { - nextChild = nextChildren[i]; - if (nextChild.flags & 16384 /* InUse */) { - nextChild = nextChildren[i] = directClone(nextChild); - } - mount(nextChild, dom, context, isSVG, nextNode, lifecycle); - } - } - else if (lastChildrenLength > nextChildrenLength) { - for (i = commonLength; i < lastChildrenLength; ++i) { - remove(lastChildren[i], dom); - } - } - } - function patchKeyedChildren(a, b, dom, context, isSVG, aLength, bLength, outerEdge, parentVNode, lifecycle) { - var aEnd = aLength - 1; - var bEnd = bLength - 1; - var j = 0; - var aNode = a[j]; - var bNode = b[j]; - var nextPos; - var nextNode; - // Step 1 - // tslint:disable-next-line - outer: { - // Sync nodes with the same key at the beginning. - while (aNode.key === bNode.key) { - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - a[j] = bNode; - ++j; - if (j > aEnd || j > bEnd) { - break outer; - } - aNode = a[j]; - bNode = b[j]; - } - aNode = a[aEnd]; - bNode = b[bEnd]; - // Sync nodes with the same key at the end. - while (aNode.key === bNode.key) { - if (bNode.flags & 16384 /* InUse */) { - b[bEnd] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - a[aEnd] = bNode; - aEnd--; - bEnd--; - if (j > aEnd || j > bEnd) { - break outer; - } - aNode = a[aEnd]; - bNode = b[bEnd]; - } - } - if (j > aEnd) { - if (j <= bEnd) { - nextPos = bEnd + 1; - nextNode = nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge; - while (j <= bEnd) { - bNode = b[j]; - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - ++j; - mount(bNode, dom, context, isSVG, nextNode, lifecycle); - } - } - } - else if (j > bEnd) { - while (j <= aEnd) { - remove(a[j++], dom); - } - } - else { - patchKeyedChildrenComplex(a, b, context, aLength, bLength, aEnd, bEnd, j, dom, isSVG, outerEdge, parentVNode, lifecycle); - } - } - function patchKeyedChildrenComplex(a, b, context, aLength, bLength, aEnd, bEnd, j, dom, isSVG, outerEdge, parentVNode, lifecycle) { - var aNode; - var bNode; - var nextPos; - var i = 0; - var aStart = j; - var bStart = j; - var aLeft = aEnd - j + 1; - var bLeft = bEnd - j + 1; - var sources = new Int32Array(bLeft + 1); - // Keep track if its possible to remove whole DOM using textContent = ''; - var canRemoveWholeContent = aLeft === aLength; - var moved = false; - var pos = 0; - var patched = 0; - // When sizes are small, just loop them through - if (bLength < 4 || (aLeft | bLeft) < 32) { - for (i = aStart; i <= aEnd; ++i) { - aNode = a[i]; - if (patched < bLeft) { - for (j = bStart; j <= bEnd; j++) { - bNode = b[j]; - if (aNode.key === bNode.key) { - sources[j - bStart] = i + 1; - if (canRemoveWholeContent) { - canRemoveWholeContent = false; - while (aStart < i) { - remove(a[aStart++], dom); - } - } - if (pos > j) { - moved = true; - } - else { - pos = j; - } - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - ++patched; - break; - } - } - if (!canRemoveWholeContent && j > bEnd) { - remove(aNode, dom); - } - } - else if (!canRemoveWholeContent) { - remove(aNode, dom); - } - } - } - else { - var keyIndex = {}; - // Map keys by their index - for (i = bStart; i <= bEnd; ++i) { - keyIndex[b[i].key] = i; - } - // Try to patch same keys - for (i = aStart; i <= aEnd; ++i) { - aNode = a[i]; - if (patched < bLeft) { - j = keyIndex[aNode.key]; - if (j !== void 0) { - if (canRemoveWholeContent) { - canRemoveWholeContent = false; - while (i > aStart) { - remove(a[aStart++], dom); - } - } - sources[j - bStart] = i + 1; - if (pos > j) { - moved = true; - } - else { - pos = j; - } - bNode = b[j]; - if (bNode.flags & 16384 /* InUse */) { - b[j] = bNode = directClone(bNode); - } - patch(aNode, bNode, dom, context, isSVG, outerEdge, lifecycle); - ++patched; - } - else if (!canRemoveWholeContent) { - remove(aNode, dom); - } - } - else if (!canRemoveWholeContent) { - remove(aNode, dom); - } - } - } - // fast-path: if nothing patched remove all old and add all new - if (canRemoveWholeContent) { - removeAllChildren(dom, parentVNode, a); - mountArrayChildren(b, dom, context, isSVG, outerEdge, lifecycle); - } - else if (moved) { - var seq = lis_algorithm(sources); - j = seq.length - 1; - for (i = bLeft - 1; i >= 0; i--) { - if (sources[i] === 0) { - pos = i + bStart; - bNode = b[pos]; - if (bNode.flags & 16384 /* InUse */) { - b[pos] = bNode = directClone(bNode); - } - nextPos = pos + 1; - mount(bNode, dom, context, isSVG, nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge, lifecycle); - } - else if (j < 0 || i !== seq[j]) { - pos = i + bStart; - bNode = b[pos]; - nextPos = pos + 1; - moveVNodeDOM(bNode, dom, nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge); - } - else { - j--; - } - } - } - else if (patched !== bLeft) { - // when patched count doesn't match b length we need to insert those new ones - // loop backwards so we can use insertBefore - for (i = bLeft - 1; i >= 0; i--) { - if (sources[i] === 0) { - pos = i + bStart; - bNode = b[pos]; - if (bNode.flags & 16384 /* InUse */) { - b[pos] = bNode = directClone(bNode); - } - nextPos = pos + 1; - mount(bNode, dom, context, isSVG, nextPos < bLength ? findDOMfromVNode(b[nextPos], true) : outerEdge, lifecycle); - } - } - } - } - var result; - var p; - var maxLen = 0; - // https://en.wikipedia.org/wiki/Longest_increasing_subsequence - function lis_algorithm(arr) { - var arrI = 0; - var i = 0; - var j = 0; - var k = 0; - var u = 0; - var v = 0; - var c = 0; - var len = arr.length; - if (len > maxLen) { - maxLen = len; - result = new Int32Array(len); - p = new Int32Array(len); - } - for (; i < len; ++i) { - arrI = arr[i]; - if (arrI !== 0) { - j = result[k]; - if (arr[j] < arrI) { - p[i] = j; - result[++k] = i; - continue; - } - u = 0; - v = k; - while (u < v) { - c = (u + v) >> 1; - if (arr[result[c]] < arrI) { - u = c + 1; - } - else { - v = c; - } - } - if (arrI < arr[result[u]]) { - if (u > 0) { - p[i] = result[u - 1]; - } - result[u] = i; - } - } - } - u = k + 1; - var seq = new Int32Array(u); - v = result[u - 1]; - while (u-- > 0) { - seq[u] = v; - v = p[v]; - result[u] = 0; - } - return seq; - } - - var hasDocumentAvailable = typeof document !== 'undefined'; - if (hasDocumentAvailable) { - /* - * Defining $EV and $V properties on Node.prototype - * fixes v8 "wrong map" de-optimization - */ - if (window.Node) { - Node.prototype.$EV = null; - Node.prototype.$V = null; - } - } - function __render(input, parentDOM, callback, context) { - var lifecycle = []; - var rootInput = parentDOM.$V; - if (isNullOrUndef(rootInput)) { - if (!isNullOrUndef(input)) { - if (input.flags & 16384 /* InUse */) { - input = directClone(input); - } - mount(input, parentDOM, context, false, null, lifecycle); - parentDOM.$V = input; - rootInput = input; - } - } - else { - if (isNullOrUndef(input)) { - remove(rootInput, parentDOM); - parentDOM.$V = null; - } - else { - if (input.flags & 16384 /* InUse */) { - input = directClone(input); - } - patch(rootInput, input, parentDOM, context, false, null, lifecycle); - rootInput = parentDOM.$V = input; - } - } - callAll(lifecycle); - if (isFunction(callback)) { - callback(); - } - if (isFunction(options.renderComplete)) { - options.renderComplete(rootInput, parentDOM); - } - } - function render(input, parentDOM, callback, context) { - if ( callback === void 0 ) callback = null; - if ( context === void 0 ) context = EMPTY_OBJ; - - __render(input, parentDOM, callback, context); - } - typeof Promise !== 'undefined' - ? Promise.resolve().then.bind(Promise.resolve()) - : function (a) { - window.setTimeout(a, 0); - }; - - var version = "7.4.8"; - - uibench.init('Inferno', version); - - function shouldDataUpdate(lastProps, nextProps) { - return lastProps !== nextProps; - } - - var SCU_hooks = { - onComponentShouldUpdate: shouldDataUpdate - }; - - function TreeLeaf(_ref) { - var children = _ref.children; - return createVNode(1, "li", "TreeLeaf", children, 16, null, null, null); - } - - TreeLeaf.defaultHooks = SCU_hooks; - - function TreeNode(_ref2) { - var data = _ref2.data; - var length = data.children.length; - var children = new Array(length); - - for (var i = 0; i < length; i++) { - var n = data.children[i]; - var id = n.id; - - if (n.container) { - children[i] = createComponentVNode(2, TreeNode, { - "data": n - }, id, null); - } else { - children[i] = createComponentVNode(2, TreeLeaf, { - children: id - }, id, null); - } - } - - return createVNode(1, "ul", "TreeNode", children, 8, null, null, null); - } - - TreeNode.defaultHooks = SCU_hooks; - - function tree(data) { - /* - * $HasVNodeChildren flag is not needed here, because shape of children is known by the compiler - *
    has static children so there is no need for $HasVNodeChildren - */ - return createVNode(1, "div", "Tree", createComponentVNode(2, TreeNode, { - "data": data.root - }, null, null), 2, null, null, null); - } - - function AnimBox(_ref3) { - var data = _ref3.data; - var time = data.time % 10; - var style = 'border-radius:' + time + 'px;' + 'background:rgba(0,0,0,' + (0.5 + time / 10) + ')'; // We don't need to use $HasVNodeChildren here, because there is no Children - - return createVNode(1, "div", "AnimBox", null, 1, { - "data-id": data.id, - "style": style - }, null, null); - } - - AnimBox.defaultHooks = SCU_hooks; - - function anim(data) { - var items = data.items; - var length = items.length; - var children = []; - - for (var i = 0; i < length; i++) { - var item = items[i]; - children.push(createComponentVNode(2, AnimBox, { - "data": item - }, item.id, null)); - } - - return createVNode(1, "div", "Anim", children, 8, null, null, null); - } - - function onClick(text, e) { - console.log('Clicked', text); - e.stopPropagation(); - } - - function TableCell(_ref4) { - var children = _ref4.children; - - /* - * Here we want to optimize for having text child vNode, - * It can be done by using $HasVNodeChildren on parent element - * and manually calling createTextVNode(value) for the children - * - * linkEvent is used here to bind the first parameter (text) into second parameter onClick function - * linkEvent has benefit of not creating function, it basically returns pre-defined object shape that inferno knows how to handle - * the main benefit is that no ".bind" or arrow function "() => {}" is needed. It works well with functional Components - */ - return createVNode(1, "td", "TableCell", children, 16, { - "onClick": linkEvent(children, onClick) - }, null, null); - } - - TableCell.defaultHooks = SCU_hooks; - - function TableRow(_ref5) { - var data = _ref5.data; - var classes = 'TableRow'; - - if (data.active) { - classes = 'TableRow active'; - } - - var cells = data.props; - var length = cells.length + 1; - var children = [createComponentVNode(2, TableCell, { - children: '#' + data.id - }, null, null)]; - - for (var i = 1; i < length; i++) { - children.push(createComponentVNode(2, TableCell, { - children: cells[i - 1] - }, null, null)); - } - /* - * Again there is element vNode which children is always constant shape. - * Add optimization flags for Children type - * This time childrens does not have key, so the type is $HasNonKeyedChildren - */ - - - return createVNode(1, "tr", classes, children, 4, { - "data-id": data.id - }, null, null); - } - - TableRow.defaultHooks = SCU_hooks; - - function table(data) { - var items = data.items; - var length = items.length; - var children = []; - - for (var i = 0; i < length; i++) { - var item = items[i]; // Components does not need ChildrenType flags, it does not hurt, but gains nothing - // Because Component children will be passed through props and will not be normalized before rendering anyway - - children.push(createComponentVNode(2, TableRow, { - "data": item - }, item.id, null)); - } - /* - * When its known that given element has only one type of children we can optimize this compile time - * by adding children type $HasKeyedChildren (list of children - all keyed) - * $HasKeyedChildren means that there are no holes in the children array and all keys are correctly set - */ - - - return createVNode(1, "table", "Table", children, 8, null, null, null); - } - - function main(data) { - var location = data.location; - var section; - - if (location === 'table') { - section = table(data.table); - } else if (location === 'anim') { - section = anim(data.anim); - } else if (location === 'tree') { - section = tree(data.tree); - } - /* - * We know that this div will always have single vNode as its children, - * so we can optimize here and add flag $NoNormalize - */ - - - return createVNode(1, "div", "Main", section, 2, null, null, null); - } - - document.addEventListener('DOMContentLoaded', function (e) { - var container = document.querySelector('#App'); - uibench.run(function (state) { - render(main(state), container); - }, function (samples) { - render(createVNode(1, "pre", null, JSON.stringify(samples, null, ' '), 16, null, null, null), container); - }); - }); - -}()); +!function(){"use strict";var e=Array.isArray;function n(e){var n=typeof e;return"string"===n||"number"===n}function t(e){return void 0===e||null===e}function r(e){return null===e||!1===e||!0===e||void 0===e}function l(e){return"function"===typeof e}function o(e){return"string"===typeof e}function i(e){return null===e}function a(e,n){var t={};if(e)for(var r in e)t[r]=e[r];if(n)for(var l in n)t[l]=n[l];return t}function u(e,n){if(l(n))return{data:e,event:n};return null}function c(e){return!i(e)&&"object"===typeof e}var f={};function s(e){return e.substr(2).toLowerCase()}function d(e,n){e.appendChild(n)}function p(e,n,t){i(t)?d(e,n):e.insertBefore(n,t)}function v(e,n){if(n)return document.createElementNS("http://www.w3.org/2000/svg",e);return document.createElement(e)}function h(e,n,t){e.replaceChild(n,t)}function g(e,n){e.removeChild(n)}function m(e){for(var n=0;n0,v=i(d),h=o(d)&&d[0]===S;p||v||h?(a=a||l.slice(0,f),(p||h)&&(s=E(s)),(v||h)&&(s.key=S+f),a.push(s)):a&&a.push(s),s.flags|=65536}}u=0===(a=a||l).length?1:8}else(a=l).flags|=65536,81920&l.flags&&(a=E(l)),u=2;return t.children=a,t.childFlags=u,t}function R(t){if(r(t)||n(t))return T(t,null);if(e(t))return D(t,0,null);return 16384&t.flags?E(t):t}var j="http://www.w3.org/1999/xlink",X="http://www.w3.org/XML/1998/namespace",_={"xlink:actuate":j,"xlink:arcrole":j,"xlink:href":j,"xlink:role":j,"xlink:show":j,"xlink:title":j,"xlink:type":j,"xml:base":X,"xml:lang":X,"xml:space":X};function K(e){return{onClick:e,onDblClick:e,onFocusIn:e,onFocusOut:e,onKeyDown:e,onKeyPress:e,onKeyUp:e,onMouseDown:e,onMouseMove:e,onMouseUp:e,onTouchEnd:e,onTouchMove:e,onTouchStart:e}}var q=K(0),G=K(null),J=K(!0);function z(e,n){var t=n.$EV;return t||(t=n.$EV=K(null)),t[e]||1===++q[e]&&(G[e]=ae(e)),t}function Q(e,n){var t=n.$EV;t&&t[e]&&(0===--q[e]&&(document.removeEventListener(s(e),G[e]),G[e]=null),t[e]=null)}function Y(e,n,t,r){if(l(t))z(e,r)[e]=t;else if(c(t)){if(P(n,t))return;z(e,r)[e]=t}else Q(e,r)}function Z(e){return l(e.composedPath)?e.composedPath()[0]:e.target}function ee(e,n,t,r){var l=Z(e);do{if(n&&l.disabled)return;var o=l.$EV;if(o){var a=o[t];if(a&&(r.dom=l,a.event?a.event(a.data,e):a(e),e.cancelBubble))return}l=l.parentNode}while(!i(l))}function ne(){this.cancelBubble=!0,this.immediatePropagationStopped||this.stopImmediatePropagation()}function te(){return this.defaultPrevented}function re(){return this.cancelBubble}function le(e){var n={dom:document};return e.isDefaultPrevented=te,e.isPropagationStopped=re,e.stopPropagation=ne,Object.defineProperty(e,"currentTarget",{configurable:!0,get:function(){return n.dom}}),n}function oe(e){return function(n){if(0!==n.button)return void n.stopPropagation();ee(n,!0,e,le(n))}}function ie(e){return function(n){ee(n,!1,e,le(n))}}function ae(e){var n="onClick"===e||"onDblClick"===e?oe(e):ie(e);return document.addEventListener(s(e),n),n}function ue(e,n){var t=document.createElement("i");return t.innerHTML=n,t.innerHTML===e.innerHTML}function ce(e,n,t){if(e[n]){var r=e[n];r.event?r.event(r.data,t):r(t)}else{var l=n.toLowerCase();e[l]&&e[l](t)}}function fe(e,n){var t=function(t){var r=this.$V;if(!r)return;var i=r.props||f,a=r.dom;if(o(e))ce(i,e,t);else for(var u=0;u-1&&n.options[i]&&(a=n.options[i].value),r&&t(a)&&(a=e.defaultValue),ke(l,a)}}var $e,Fe,Pe=fe("onInput",Se),xe=fe("onChange");function Le(e,n){se(e,"input",Pe),n.onChange&&se(e,"change",xe)}function Se(e,n,r){var l=e.value,o=n.value;if(t(l)){if(r){var i=e.defaultValue;t(i)||i===o||(n.defaultValue=i,n.value=i)}}else o!==l&&(n.defaultValue=l,n.value=l)}function Ve(e,n,t,r,l,o){64&e?me(r,t):256&e?we(r,t,l,n):128&e&&Se(r,t,l),o&&(t.$V=n)}function Ue(e,n,t){64&e?ge(n,t):256&e?Ce(n):128&e&&Le(n,t)}function Ne(e){return e.type&&de(e.type)?!t(e.checked):!t(e.value)}function Ie(e){e&&!L(e,null)&&e.current&&(e.current=null)}function Ae(e,n,t){e&&(l(e)||void 0!==e.current)&&t.push((function(){L(e,n)||void 0===e.current||(e.current=n)}))}function Me(e,n){Te(e),y(e,n)}function Te(e){var n,r=e.flags,o=e.children;if(481&r){n=e.ref;var a=e.props;Ie(n);var u=e.childFlags;if(!i(a))for(var c=Object.keys(a),s=0,d=c.length;s0;for(var a in i&&(o=Ne(t))&&Ue(n,r,t),t)je(a,null,t[a],r,l,o,null);i&&Ve(n,e,r,t,!0,o)}function _e(e,n,t){var r=R(e.render(n,e.state,t)),o=t;return l(e.getChildContext)&&(o=a(t,e.getChildContext())),e.$CX=o,r}function Ke(e,n,t,r,o,a){var u=new n(t,r),c=u.$N=Boolean(n.getDerivedStateFromProps||u.getSnapshotBeforeUpdate);if(u.$SVG=o,u.$L=a,e.children=u,u.$BS=!1,u.context=r,u.props===f&&(u.props=t),c)u.state=w(u,t,u.state);else if(l(u.componentWillMount)){u.$BR=!0,u.componentWillMount();var s=u.$PS;if(!i(s)){var d=u.state;if(i(d))u.state=s;else for(var p in s)d[p]=s[p];u.$PS=null}u.$BR=!1}return u.$LI=_e(u,t,r),u}function qe(e,n){var t=e.props||f;return 32768&e.flags?e.type.render(t,e.ref,n):e.type(t,n)}function Ge(e,n,t,r,l,o){var i=e.flags|=16384;481&i?Ye(e,n,t,r,l,o):4&i?en(e,n,t,r,l,o):8&i?(nn(e,n,t,r,l,o),on(e,o)):512&i||16&i?Qe(e,n,l):8192&i?ze(e,t,n,r,l,o):1024&i&&Je(e,t,n,l,o)}function Je(e,n,t,r,l){Ge(e.children,e.ref,n,!1,null,l);var o=W();Qe(o,t,r),e.dom=o.dom}function ze(e,n,t,r,l,o){var i=e.children,a=e.childFlags;12&a&&0===i.length&&(a=e.childFlags=2,i=e.children=W()),2===a?Ge(i,t,l,r,l,o):Ze(i,t,n,r,l,o)}function Qe(e,n,t){var r=e.dom=document.createTextNode(e.children);i(n)||p(n,r,t)}function Ye(e,n,r,l,o,a){var u=e.flags,c=e.props,f=e.className,s=e.childFlags,d=e.dom=v(e.type,l=l||(32&u)>0),h=e.children;if(t(f)||""===f||(l?d.setAttribute("class",f):d.className=f),16===s)F(d,h);else if(1!==s){var g=l&&"foreignObject"!==e.type;2===s?(16384&h.flags&&(e.children=h=E(h)),Ge(h,d,r,g,null,a)):8!==s&&4!==s||Ze(h,d,r,g,null,a)}i(n)||p(n,d,o),i(c)||Xe(e,u,c,d,l),Ae(e.ref,d,a)}function Ze(e,n,t,r,l,o){for(var i=0;id)&&(f=b(i[d-1],!1).nextSibling)}hn(u,c,i,a,t,r,l,f,e,o)}function dn(e,n,t,l){var o=e.ref,i=n.ref,a=n.children;if(hn(e.childFlags,n.childFlags,e.children,a,o,t,!1,null,e,l),n.dom=e.dom,o!==i&&!r(a)){var u=a.dom;g(o,u),d(i,u)}}function pn(e,n,r,l,o,i){var a,u=n.dom=e.dom,c=e.props,s=n.props,d=!1,p=!1;if(l=l||(32&o)>0,c!==s){var v=c||f;if((a=s||f)!==f)for(var h in(d=(448&o)>0)&&(p=Ne(a)),a){var g=v[h],m=a[h];g!==m&&je(h,g,m,u,l,p,e)}if(v!==f)for(var k in v)t(a[k])&&!t(v[k])&&je(k,v[k],null,u,l,p,e)}var b=n.children,y=n.className;e.className!==y&&(t(y)?u.removeAttribute("class"):l?u.setAttribute("class",y):u.className=y),4096&o?fn(u,b):hn(e.childFlags,n.childFlags,e.children,b,u,r,l&&"foreignObject"!==n.type,null,e,i),d&&Ve(o,n,u,a,!1,p);var C=n.ref,w=e.ref;w!==C&&(Ie(w),Ae(C,u,i))}function vn(e,n,t,r,l,o){Te(e),Ze(n,t,r,l,b(e,!0),o),y(e,t)}function hn(e,n,t,r,l,o,i,a,u,c){switch(e){case 2:switch(n){case 2:un(t,r,l,o,i,a,c);break;case 1:Me(t,l);break;case 16:Te(t),F(l,r);break;default:vn(t,r,l,o,i,c)}break;case 1:switch(n){case 2:Ge(r,l,o,i,a,c);break;case 1:break;case 16:F(l,r);break;default:Ze(r,l,o,i,a,c)}break;case 16:switch(n){case 16:cn(t,r,l);break;case 2:Be(l),Ge(r,l,o,i,a,c);break;case 1:Be(l);break;default:Be(l),Ze(r,l,o,i,a,c)}break;default:switch(n){case 16:De(t),F(l,r);break;case 2:Ee(l,u,t),Ge(r,l,o,i,a,c);break;case 1:Ee(l,u,t);break;default:var f=0|t.length,s=0|r.length;0===f?s>0&&Ze(r,l,o,i,a,c):0===s?Ee(l,u,t):8===n&&8===e?wn(t,r,l,o,i,f,s,a,u,c):Cn(t,r,l,o,i,f,s,a,c)}}}function gn(e,n,t,r,l){l.push((function(){e.componentDidUpdate(n,t,r)}))}function mn(e,n,t,r,o,i,u,c,f){var s=e.state,d=e.props,p=Boolean(e.$N),v=l(e.shouldComponentUpdate);if(p&&(n=w(e,t,n!==s?a(s,n):n)),u||!v||v&&e.shouldComponentUpdate(t,n,o)){!p&&l(e.componentWillUpdate)&&e.componentWillUpdate(t,n,o),e.props=t,e.state=n,e.context=o;var h=null,g=_e(e,t,o);p&&l(e.getSnapshotBeforeUpdate)&&(h=e.getSnapshotBeforeUpdate(d,s)),un(e.$LI,g,r,e.$CX,i,c,f),e.$LI=g,l(e.componentDidUpdate)&&gn(e,d,s,h,f)}else e.props=t,e.state=n,e.context=o}function kn(e,n,t,r,o,u,c){var s=n.children=e.children;if(i(s))return;s.$L=c;var d=n.props||f,p=n.ref,v=e.ref,h=s.state;if(!s.$N){if(l(s.componentWillReceiveProps)){if(s.$BR=!0,s.componentWillReceiveProps(d,r),s.$UN)return;s.$BR=!1}i(s.$PS)||(h=a(h,s.$PS),s.$PS=null)}mn(s,h,d,t,r,o,!1,u,c),v!==p&&(Ie(v),Ae(p,s,c))}function bn(e,n,r,o,i,a,u){var c=!0,s=n.props||f,d=n.ref,p=e.props,v=!t(d),h=e.children;if(v&&l(d.onComponentShouldUpdate)&&(c=d.onComponentShouldUpdate(p,s)),!1!==c){v&&l(d.onComponentWillUpdate)&&d.onComponentWillUpdate(p,s);var g=R(qe(n,o));un(h,g,r,o,i,a,u),n.children=g,v&&l(d.onComponentDidUpdate)&&d.onComponentDidUpdate(p,s)}else n.children=h}function yn(e,n){var t=n.children,r=n.dom=e.dom;t!==e.children&&(r.nodeValue=t)}function Cn(e,n,t,r,l,o,i,a,u){for(var c,f,s=o>i?i:o,d=0;di)for(d=s;dd||v>p)break e;h=e[v],g=n[v]}for(h=e[d],g=n[p];h.key===g.key;){if(16384&g.flags&&(n[p]=g=E(g)),un(h,g,t,r,l,a,c),e[d]=g,p--,v>--d||v>p)break e;h=e[d],g=n[p]}}if(v>d){if(v<=p)for(s=(f=p+1)p)for(;v<=d;)Me(e[v++],t);else $n(e,n,r,o,i,d,p,v,t,l,a,u,c)}function $n(e,n,t,r,l,o,i,a,u,c,f,s,d){var p,v,h,g=0,m=a,k=a,y=o-a+1,w=i-a+1,$=new Int32Array(w+1),F=y===r,P=!1,x=0,L=0;if(l<4||(y|w)<32)for(g=m;g<=o;++g)if(p=e[g],La?P=!0:x=a,16384&v.flags&&(n[a]=v=E(v)),un(p,v,u,t,c,f,d),++L;break}!F&&a>i&&Me(p,u)}else F||Me(p,u);else{var S={};for(g=k;g<=i;++g)S[n[g].key]=g;for(g=m;g<=o;++g)if(p=e[g],Lm;)Me(e[m++],u);$[a-k]=g+1,x>a?P=!0:x=a,16384&(v=n[a]).flags&&(n[a]=v=E(v)),un(p,v,u,t,c,f,d),++L}else F||Me(p,u);else F||Me(p,u)}if(F)Ee(u,s,e),Ze(n,u,t,c,f,d);else if(P){var V=Pn($);for(a=V.length-1,g=w-1;g>=0;g--)0===$[g]?(16384&(v=n[x=g+k]).flags&&(n[x]=v=E(v)),Ge(v,u,t,c,(h=x+1)=0;g--)0===$[g]&&(16384&(v=n[x=g+k]).flags&&(n[x]=v=E(v)),Ge(v,u,t,c,(h=x+1)Fn&&(Fn=u,$e=new Int32Array(u),Fe=new Int32Array(u));t>1]]0&&(Fe[t]=$e[o-1]),$e[o]=t)}o=l+1;var c=new Int32Array(o);for(i=$e[o-1];o-- >0;)c[o]=i,i=Fe[i],$e[o]=0;return c}function xn(e,n,r,o){var i=[],a=n.$V;t(a)?t(e)||(16384&e.flags&&(e=E(e)),Ge(e,n,o,!1,null,i),n.$V=e,a=e):t(e)?(Me(a,n),n.$V=null):(16384&e.flags&&(e=E(e)),un(a,e,n,o,!1,null,i),a=n.$V=e),m(i),l(r)&&r(),l($.renderComplete)&&$.renderComplete(a,n)}function Ln(e,n,t,r){void 0===t&&(t=null),void 0===r&&(r=f),xn(e,n,t,r)}"undefined"!==typeof document&&window.Node&&(Node.prototype.$EV=null,Node.prototype.$V=null),"undefined"!==typeof Promise&&Promise.resolve().then.bind(Promise.resolve()),uibench.init("Inferno","7.4.10");var Sn={onComponentShouldUpdate:function(e,n){return e!==n}};function Vn(e){return U(1,"li","TreeLeaf",e.children,16,null,null,null)}function Un(e){for(var n=e.data,t=n.children.length,r=new Array(t),l=0;l (https://terinstock.com/)", @@ -28,11 +28,11 @@ "directory": "packages/inferno-hyperscript" }, "dependencies": { - "inferno": "7.4.10" + "inferno": "8.0.0-alpha.0" }, "devDependencies": { - "inferno-shared": "7.4.10", - "inferno-vnode-flags": "7.4.10" + "inferno-shared": "8.0.0-alpha.0", + "inferno-vnode-flags": "8.0.0-alpha.0" }, "rollup": { "bundledDependencies": [ diff --git a/packages/inferno-mobx/package.json b/packages/inferno-mobx/package.json index 7580ee13c..b4cd0663f 100644 --- a/packages/inferno-mobx/package.json +++ b/packages/inferno-mobx/package.json @@ -1,6 +1,6 @@ { "name": "inferno-mobx", - "version": "7.4.10", + "version": "8.0.0-alpha.0", "license": "MIT", "description": "Official Inferno bindings for Mobx", "author": { @@ -40,11 +40,11 @@ }, "dependencies": { "hoist-non-inferno-statics": "^1.1.3", - "inferno": "7.4.10", - "inferno-create-class": "7.4.10", - "inferno-create-element": "7.4.10", - "inferno-shared": "7.4.10", - "inferno-vnode-flags": "7.4.10" + "inferno": "8.0.0-alpha.0", + "inferno-create-class": "8.0.0-alpha.0", + "inferno-create-element": "8.0.0-alpha.0", + "inferno-shared": "8.0.0-alpha.0", + "inferno-vnode-flags": "8.0.0-alpha.0" }, "devDependencies": { "mobx": "*" diff --git a/packages/inferno-redux/package.json b/packages/inferno-redux/package.json index c57bd73fc..7bb4d76a2 100644 --- a/packages/inferno-redux/package.json +++ b/packages/inferno-redux/package.json @@ -1,6 +1,6 @@ { "name": "inferno-redux", - "version": "7.4.10", + "version": "8.0.0-alpha.0", "license": "MIT", "description": "Official Inferno bindings for Redux", "author": { @@ -40,12 +40,12 @@ }, "dependencies": { "hoist-non-inferno-statics": "^1.1.3", - "inferno": "7.4.10" + "inferno": "8.0.0-alpha.0" }, "devDependencies": { - "inferno-create-class": "7.4.10", - "inferno-create-element": "7.4.10", - "inferno-shared": "7.4.10", + "inferno-create-class": "8.0.0-alpha.0", + "inferno-create-element": "8.0.0-alpha.0", + "inferno-shared": "8.0.0-alpha.0", "redux": "^4" }, "rollup": { diff --git a/packages/inferno-router/package.json b/packages/inferno-router/package.json index 99f6455f4..a3427b1a7 100644 --- a/packages/inferno-router/package.json +++ b/packages/inferno-router/package.json @@ -1,6 +1,6 @@ { "name": "inferno-router", - "version": "7.4.10", + "version": "8.0.0-alpha.0", "license": "MIT", "description": "Provides routing functionality for Inferno", "author": { @@ -42,11 +42,11 @@ "dependencies": { "history": "^5.0.1", "hoist-non-inferno-statics": "^1.1.3", - "inferno": "7.4.10", + "inferno": "8.0.0-alpha.0", "path-to-regexp-es6": "1.7.0" }, "devDependencies": { - "inferno-vnode-flags": "7.4.10", + "inferno-vnode-flags": "8.0.0-alpha.0", "mobx": "*" }, "rollup": { diff --git a/packages/inferno-server/package.json b/packages/inferno-server/package.json index 18b2ab0a7..2a93e2e25 100644 --- a/packages/inferno-server/package.json +++ b/packages/inferno-server/package.json @@ -1,6 +1,6 @@ { "name": "inferno-server", - "version": "7.4.10", + "version": "8.0.0-alpha.0", "license": "MIT", "description": "Provides methods to render HTML strings from Inferno elements", "author": { @@ -45,15 +45,15 @@ "node": ">=8" }, "devDependencies": { - "inferno-create-class": "7.4.10", - "inferno-create-element": "7.4.10", - "inferno-hydrate": "7.4.10", - "inferno-shared": "7.4.10", - "inferno-vnode-flags": "7.4.10", + "inferno-create-class": "8.0.0-alpha.0", + "inferno-create-element": "8.0.0-alpha.0", + "inferno-hydrate": "8.0.0-alpha.0", + "inferno-shared": "8.0.0-alpha.0", + "inferno-vnode-flags": "8.0.0-alpha.0", "mobx": "*" }, "dependencies": { - "inferno": "7.4.10" + "inferno": "8.0.0-alpha.0" }, "rollup": { "bundledDependencies": [ diff --git a/packages/inferno-shared/package.json b/packages/inferno-shared/package.json index 8cae63ae5..e9e0d3247 100644 --- a/packages/inferno-shared/package.json +++ b/packages/inferno-shared/package.json @@ -1,6 +1,6 @@ { "name": "inferno-shared", - "version": "7.4.10", + "version": "8.0.0-alpha.0", "license": "MIT", "description": "Helpers functions for Inferno", "author": { diff --git a/packages/inferno-test-utils/package.json b/packages/inferno-test-utils/package.json index 9b2e83119..c662c6671 100644 --- a/packages/inferno-test-utils/package.json +++ b/packages/inferno-test-utils/package.json @@ -1,6 +1,6 @@ { "name": "inferno-test-utils", - "version": "7.4.10", + "version": "8.0.0-alpha.0", "license": "MIT", "description": "Suite of utilities for testing Inferno applications", "author": { @@ -21,11 +21,11 @@ "utils" ], "devDependencies": { - "inferno-shared": "7.4.10", - "inferno-vnode-flags": "7.4.10" + "inferno-shared": "8.0.0-alpha.0", + "inferno-vnode-flags": "8.0.0-alpha.0" }, "dependencies": { - "inferno": "7.4.10" + "inferno": "8.0.0-alpha.0" }, "rollup": { "bundledDependencies": [ diff --git a/packages/inferno-utils/package.json b/packages/inferno-utils/package.json index 8eb7c1545..20e7fe8fd 100644 --- a/packages/inferno-utils/package.json +++ b/packages/inferno-utils/package.json @@ -1,6 +1,6 @@ { "name": "inferno-utils", - "version": "7.4.10", + "version": "8.0.0-alpha.0", "description": "Meta test utilities which are not for userland", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -11,8 +11,8 @@ "directory": "packages/inferno-utils" }, "devDependencies": { - "inferno-shared": "7.4.10", - "inferno-vnode-flags": "7.4.10" + "inferno-shared": "8.0.0-alpha.0", + "inferno-vnode-flags": "8.0.0-alpha.0" }, "keywords": [], "author": "", diff --git a/packages/inferno-vnode-flags/package.json b/packages/inferno-vnode-flags/package.json index 82811acf9..8af2e9fa5 100644 --- a/packages/inferno-vnode-flags/package.json +++ b/packages/inferno-vnode-flags/package.json @@ -1,6 +1,6 @@ { "name": "inferno-vnode-flags", - "version": "7.4.10", + "version": "8.0.0-alpha.0", "license": "MIT", "description": "Provides an enum of all possible VNode Flags used when calling Inferno.createVNode", "author": { diff --git a/packages/inferno/package.json b/packages/inferno/package.json index 8e9b7877e..ac6195d72 100644 --- a/packages/inferno/package.json +++ b/packages/inferno/package.json @@ -1,6 +1,6 @@ { "name": "inferno", - "version": "7.4.10", + "version": "8.0.0-alpha.0", "license": "MIT", "description": "An extremely fast, React-like JavaScript library for building modern user interfaces", "author": { @@ -57,11 +57,11 @@ "directory": "packages/inferno" }, "devDependencies": { - "inferno-utils": "7.4.10" + "inferno-utils": "8.0.0-alpha.0" }, "dependencies": { - "inferno-shared": "7.4.10", - "inferno-vnode-flags": "7.4.10", + "inferno-shared": "8.0.0-alpha.0", + "inferno-vnode-flags": "8.0.0-alpha.0", "opencollective-postinstall": "^2.0.3" } }