From a95656432d9b2c58abd87a8ee3f5e784f484466a Mon Sep 17 00:00:00 2001 From: Fops Date: Thu, 18 Aug 2016 18:36:19 +0200 Subject: [PATCH 1/4] =?UTF-8?q?fixing=20Uncaught=20TypeError:=20Cannot=20r?= =?UTF-8?q?ead=20property=20'isComponent'=20of=20undefined(=E2=80=A6)patch?= =?UTF-8?q?VNodeWithBlueprint...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/DOM/patching.js | 1668 +++++++++++++++++++++---------------------- 1 file changed, 814 insertions(+), 854 deletions(-) diff --git a/src/DOM/patching.js b/src/DOM/patching.js index b1519aa51..16f4bb2cd 100644 --- a/src/DOM/patching.js +++ b/src/DOM/patching.js @@ -1,914 +1,874 @@ -import { - isNullOrUndefined, - isString, - addChildrenToProps, - isStatefulComponent, - isStringOrNumber, - isInvalidNode, - NO_RENDER, - isNumber, - isFunction, - isArray -} from './../core/utils'; -import { - mount, - mountVText, - mountVPlaceholder, - mountVList, - mountArrayChildren, - mountComponent, - mountEvents -} from './mounting'; -import { - insertOrAppend, - remove, - isKeyed, - replaceNode, - isUnitlessNumber, - booleanProps, - strictProps, - namespaces, - isVText, - isVPlaceholder, - replaceVListWithNode, - isVList, - normaliseChild, - setFormElementProperties, - removeAllChildren, - replaceWithNewNode, - removeEvents, - selectValue, - isVNode, - normalise -} from './utils'; +import { isNullOrUndefined, isString, addChildrenToProps, isStatefulComponent, isStringOrNumber, isInvalidNode, NO_RENDER, isNumber, isFunction, isArray } from './../core/utils'; +import { mount, mountVText, mountVPlaceholder, mountVList, mountArrayChildren, mountComponent, mountEvents } from './mounting'; +import { insertOrAppend, remove, isKeyed, replaceNode, isUnitlessNumber, booleanProps, strictProps, namespaces, isVText, isVPlaceholder, replaceVListWithNode, isVList, normaliseChild, setFormElementProperties, removeAllChildren, replaceWithNewNode, removeEvents, selectValue, isVNode, normalise } from './utils'; import { componentToDOMNodeMap } from './rendering'; import { createVPlaceholder, createVText } from '../core/shapes'; import { unmount, unmountVNode } from './unmounting'; export function patch(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG) { - if (lastInput !== nextInput) { - if (isInvalidNode(lastInput)) { - mount(nextInput, parentDom, lifecycle, context, instance, isSVG); - } else if (isInvalidNode(nextInput)) { - remove(lastInput, parentDom); - } else if (isStringOrNumber(lastInput)) { - if (isStringOrNumber(nextInput)) { - parentDom.firstChild.nodeValue = nextInput; - } else { - const dom = mount(nextInput, null, lifecycle, context, instance, isSVG); - - nextInput.dom = dom; - replaceNode(parentDom, dom, parentDom.firstChild); - } - } else if (isStringOrNumber(nextInput)) { - replaceNode(parentDom, document.createTextNode(nextInput), lastInput.dom); - } else { - if (isVList(nextInput)) { - if (isVList(lastInput)) { - patchVList(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG); - } else { - replaceNode(parentDom, mountVList(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); - unmount(lastInput, null); - } - } else if (isVList(lastInput)) { - replaceVListWithNode(parentDom, lastInput, mount(nextInput, null, lifecycle, context, instance, isSVG)); - } else if (isVPlaceholder(nextInput)) { - if (isVPlaceholder(lastInput)) { - patchVFragment(lastInput, nextInput); - } else { - replaceNode(parentDom, mountVPlaceholder(nextInput, null), lastInput.dom); - unmount(lastInput, null); - } - } else if (isVPlaceholder(lastInput)) { - replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); - } else if (isVText(nextInput)) { - if (isVText(lastInput)) { - patchVText(lastInput, nextInput); - } else { - replaceNode(parentDom, mountVText(nextInput, null), lastInput.dom); - unmount(lastInput, null); - } - } else if (isVText(lastInput)) { - replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); - } else if (isVNode(nextInput)) { - if (isVNode(lastInput)) { - patchVNode(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG, false); - } else { - replaceNode(parentDom, mountVNode(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); - unmount(lastInput, null); - } - } else if (isVNode(lastInput)) { - replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); - unmount(lastInput, null); - } else { - return patch(lastInput, normalise(nextInput), parentDom, lifecycle, context, instance, isSVG); - } - } - } - return nextInput; + if (lastInput !== nextInput) { + if (isInvalidNode(lastInput)) { + mount(nextInput, parentDom, lifecycle, context, instance, isSVG); + } else if (isInvalidNode(nextInput)) { + remove(lastInput, parentDom); + } else if (isStringOrNumber(lastInput)) { + if (isStringOrNumber(nextInput)) { + parentDom.firstChild.nodeValue = nextInput; + } else { + const dom = mount(nextInput, null, lifecycle, context, instance, isSVG); + + nextInput.dom = dom; + replaceNode(parentDom, dom, parentDom.firstChild); + } + } else if (isStringOrNumber(nextInput)) { + replaceNode(parentDom, document.createTextNode(nextInput), lastInput.dom); + } else { + if (isVList(nextInput)) { + if (isVList(lastInput)) { + patchVList(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG); + } else { + replaceNode(parentDom, mountVList(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); + unmount(lastInput, null); + } + } else if (isVList(lastInput)) { + replaceVListWithNode(parentDom, lastInput, mount(nextInput, null, lifecycle, context, instance, isSVG)); + } else if (isVPlaceholder(nextInput)) { + if (isVPlaceholder(lastInput)) { + patchVFragment(lastInput, nextInput); + } else { + replaceNode(parentDom, mountVPlaceholder(nextInput, null), lastInput.dom); + unmount(lastInput, null); + } + } else if (isVPlaceholder(lastInput)) { + replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); + } else if (isVText(nextInput)) { + if (isVText(lastInput)) { + patchVText(lastInput, nextInput); + } else { + replaceNode(parentDom, mountVText(nextInput, null), lastInput.dom); + unmount(lastInput, null); + } + } else if (isVText(lastInput)) { + replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); + } else if (isVNode(nextInput)) { + if (isVNode(lastInput)) { + patchVNode(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG, false); + } else { + replaceNode(parentDom, mountVNode(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); + unmount(lastInput, null); + } + } else if (isVNode(lastInput)) { + replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); + unmount(lastInput, null); + } else { + return patch(lastInput, normalise(nextInput), parentDom, lifecycle, context, instance, isSVG); + } + } + } + return nextInput; } export function patchTextNode(dom, lastChildren, nextChildren) { - if (isStringOrNumber(lastChildren)) { - dom.firstChild.nodeValue = nextChildren; - } else { - dom.textContent = nextChildren; - } + if (isStringOrNumber(lastChildren)) { + dom.firstChild.nodeValue = nextChildren; + } else { + dom.textContent = nextChildren; + } } function patchRef(instance, lastValue, nextValue, dom) { - if (instance) { - if (isString(lastValue)) { - delete instance.refs[lastValue]; - } - if (isString(nextValue)) { - instance.refs[nextValue] = dom; - } - } + if (instance) { + if (isString(lastValue)) { + delete instance.refs[lastValue]; + } + if (isString(nextValue)) { + instance.refs[nextValue] = dom; + } + } } function patchChildren(lastNode, nextNode, dom, lifecycle, context, instance, isSVG) { - const nextChildren = nextNode.children; - const lastChildren = lastNode.children; - - if (lastChildren === nextChildren) { - return; - } - if (isInvalidNode(lastChildren)) { - if (isStringOrNumber(nextChildren)) { - patchTextNode(dom, lastChildren, nextChildren); - } else if (!isInvalidNode(nextChildren)) { - if (isArray(nextChildren)) { - mountArrayChildren(nextChildren, dom, lifecycle, context, instance, isSVG); - } else { - mount(nextChildren, dom, lifecycle, context, instance, isSVG); - } - } - } else { - if (isInvalidNode(nextChildren)) { - removeAllChildren(dom, lastChildren); - } else { - if (isArray(lastChildren)) { - if (isArray(nextChildren)) { - nextChildren.complex = lastChildren.complex; - if (isKeyed(lastChildren, nextChildren)) { - patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, null); - } else { - patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, null); - } - } else { - patchNonKeyedChildren(lastChildren, [nextChildren], dom, lifecycle, context, instance, isSVG, null); - } - } else { - if (isArray(nextChildren)) { - let lastChild = lastChildren; - - if (isStringOrNumber(lastChildren)) { - lastChild = createVText(lastChild); - lastChild.dom = dom.firstChild; - } - patchNonKeyedChildren([lastChild], nextChildren, dom, lifecycle, context, instance, isSVG, null); - } else if (isStringOrNumber(nextChildren)) { - patchTextNode(dom, lastChildren, nextChildren); - } else if (isStringOrNumber(lastChildren)) { - patch(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG); - } else { - patchVNode(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, false); - } - } - } - } + const nextChildren = nextNode.children; + const lastChildren = lastNode.children; + + if (lastChildren === nextChildren) { + return; + } + if (isInvalidNode(lastChildren)) { + if (isStringOrNumber(nextChildren)) { + patchTextNode(dom, lastChildren, nextChildren); + } else if (!isInvalidNode(nextChildren)) { + if (isArray(nextChildren)) { + mountArrayChildren(nextChildren, dom, lifecycle, context, instance, isSVG); + } else { + mount(nextChildren, dom, lifecycle, context, instance, isSVG); + } + } + } else { + if (isInvalidNode(nextChildren)) { + removeAllChildren(dom, lastChildren); + } else { + if (isArray(lastChildren)) { + if (isArray(nextChildren)) { + nextChildren.complex = lastChildren.complex; + if (isKeyed(lastChildren, nextChildren)) { + patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, null); + } else { + patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, null); + } + } else { + patchNonKeyedChildren(lastChildren, [nextChildren], dom, lifecycle, context, instance, isSVG, null); + } + } else { + if (isArray(nextChildren)) { + let lastChild = lastChildren; + + if (isStringOrNumber(lastChildren)) { + lastChild = createVText(lastChild); + lastChild.dom = dom.firstChild; + } + patchNonKeyedChildren([lastChild], nextChildren, dom, lifecycle, context, instance, isSVG, null); + } else if (isStringOrNumber(nextChildren)) { + patchTextNode(dom, lastChildren, nextChildren); + } else if (isStringOrNumber(lastChildren)) { + patch(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG); + } else { + patchVNode(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, false); + } + } + } + } } export function patchVNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, isSVG, skipLazyCheck) { - const lastBp = lastVNode.bp; - const nextBp = nextVNode.bp; - - if (lastBp === undefined || nextBp === undefined) { - patchVNodeWithoutBlueprint(lastVNode, nextVNode, parentDom, lifecycle, context, instance, isSVG); - } else { - patchVNodeWithBlueprint(lastVNode, nextVNode, lastBp, nextBp, parentDom, lifecycle, context, instance, skipLazyCheck); - } + const lastBp = lastVNode.bp; + const nextBp = nextVNode.bp; + + if (lastBp === undefined || nextBp === undefined) { + patchVNodeWithoutBlueprint(lastVNode, nextVNode, parentDom, lifecycle, context, instance, isSVG); + } else { + patchVNodeWithBlueprint(lastVNode, nextVNode, lastBp, nextBp, parentDom, lifecycle, context, instance, skipLazyCheck); + } } export function patchVNodeWithBlueprint(lastVNode, nextVNode, lastBp, nextBp, parentDom, lifecycle, context, instance, skipLazyCheck) { - let nextHooks; - - if (nextBp.hasHooks === true) { - nextHooks = nextVNode.hooks; - if (nextHooks && !isNullOrUndefined(nextHooks.willUpdate)) { - nextHooks.willUpdate(lastVNode.dom); - } - } - const nextTag = nextVNode.tag || nextBp.tag; - const lastTag = lastVNode.tag || lastBp.tag; - - if (lastTag !== nextTag) { - if (lastBp.isComponent === true) { - const lastNodeInstance = lastVNode.instance; - - if (nextBp.isComponent === true) { - replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, false); - } else if (isStatefulComponent(lastTag)) { - unmountVNode(lastVNode, null, true); - const lastNode = lastNodeInstance._lastNode; - patchVNodeWithBlueprint(lastNode, nextVNode, lastNode.bp, nextBp, parentDom, lifecycle, context, instance, nextBp.isSVG); - } else { - unmountVNode(lastVNode, null, true); - patchVNodeWithBlueprint(lastNodeInstance, nextVNode, lastNodeInstance.bp, nextBp, parentDom, lifecycle, context, instance, nextBp.isSVG); - } - } else { - replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, nextBp.isSVG); - } - } else if (isNullOrUndefined(lastTag)) { - nextVNode.dom = lastVNode.dom; - } else { - if (lastBp.isComponent === true) { - if (nextBp.isComponent === true) { - const instance = lastVNode.instance; - - if (!isNullOrUndefined(instance) && instance._unmounted) { - const newDom = mountComponent(nextVNode, lastTag, nextVNode.attrs || {}, nextVNode.hooks, nextVNode.children, instance, parentDom, lifecycle, context); - if (parentDom !== null) { - replaceNode(parentDom, newDom, lastVNode.dom); - } - } else { - nextVNode.instance = instance; - nextVNode.dom = lastVNode.dom; - patchComponent(true, nextVNode, nextVNode.tag, lastBp, nextBp, instance, lastVNode.attrs || {}, nextVNode.attrs || {}, nextVNode.hooks, lastVNode.children, nextVNode.children, parentDom, lifecycle, context); - } - } - } else { - const dom = lastVNode.dom; - const lastChildrenType = lastBp.childrenType; - const nextChildrenType = nextBp.childrenType; - nextVNode.dom = dom; - - if (nextBp.lazy === true && skipLazyCheck === false) { - const clipData = lastVNode.clipData; - - if (lifecycle.scrollY === null) { - lifecycle.refresh(); - } - - nextVNode.clipData = clipData; - if (clipData.pending === true || clipData.top - lifecycle.scrollY > lifecycle.screenHeight) { - if (setClipNode(clipData, dom, lastVNode, nextVNode, parentDom, lifecycle, context, instance, lastBp.isSVG)) { - return; - } - } - if (clipData.bottom < lifecycle.scrollY) { - if (setClipNode(clipData, dom, lastVNode, nextVNode, parentDom, lifecycle, context, instance, lastBp.isSVG)) { - return; - } - } - } - - if (lastChildrenType > 0 || nextChildrenType > 0) { - if (nextChildrenType === 5 || lastChildrenType === 5) { - patchChildren(lastVNode, nextVNode, dom, lifecycle, context, instance); - } else { - const lastChildren = lastVNode.children; - const nextChildren = nextVNode.children; - - if (lastChildrenType === 0 || isInvalidNode(lastChildren)) { - if (nextChildrenType > 2) { - mountArrayChildren(nextChildren, dom, lifecycle, context, instance); - } else { - mount(nextChildren, dom, lifecycle, context, instance); - } - } else if (nextChildrenType === 0 || isInvalidNode(nextChildren)) { - if (lastChildrenType > 2) { - removeAllChildren(dom, lastChildren); - } else { - remove(lastChildren, dom); - } - } else { - if (lastChildren !== nextChildren) { - if (lastChildrenType === 4 && nextChildrenType === 4) { - patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, nextBp.isSVG, null); - } else if (lastChildrenType === 2 && nextChildrenType === 2) { - patch(lastChildren, nextChildren, dom, lifecycle, context, instance, true, nextBp.isSVG); - } else if (lastChildrenType === 1 && nextChildrenType === 1) { - patchTextNode(dom, lastChildren, nextChildren); - } else { - patchChildren(lastVNode, nextVNode, dom, lifecycle, context, instance, nextBp.isSVG); - } - } - } - } - } - if (lastBp.hasAttrs === true || nextBp.hasAttrs === true) { - patchAttributes(lastVNode, nextVNode, lastBp.attrKeys, nextBp.attrKeys, dom, instance); - } - if (lastBp.hasEvents === true || nextBp.hasEvents === true) { - patchEvents(lastVNode.events, nextVNode.events, lastBp.eventKeys, nextBp.eventKeys, dom); - } - if (lastBp.hasClassName === true || nextBp.hasClassName === true) { - const nextClassName = nextVNode.className; - - if (lastVNode.className !== nextClassName) { - if (isNullOrUndefined(nextClassName)) { - dom.removeAttribute('class'); - } else { - dom.className = nextClassName; - } - } - } - if (lastBp.hasStyle === true || nextBp.hasStyle === true) { - const nextStyle = nextVNode.style; - const lastStyle = lastVNode.style; - - if (lastStyle !== nextStyle) { - patchStyle(lastStyle, nextStyle, dom); - } - } - if (nextBp.hasHooks === true && !isNullOrUndefined(nextHooks.didUpdate)) { - nextHooks.didUpdate(dom); - } - setFormElementProperties(nextTag, nextVNode); - } - } + let nextHooks; + + if (nextBp.hasHooks === true) { + nextHooks = nextVNode.hooks; + if (nextHooks && !isNullOrUndefined(nextHooks.willUpdate)) { + nextHooks.willUpdate(lastVNode.dom); + } + } + const nextTag = nextVNode.tag || nextBp.tag; + const lastTag = lastVNode.tag || lastBp.tag; + + if (lastTag !== nextTag) { + if (lastBp && lastBp.isComponent === true) { + const lastNodeInstance = lastVNode.instance; + + if (nextBp.isComponent === true) { + replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, false); + } else if (isStatefulComponent(lastTag)) { + unmountVNode(lastVNode, null, true); + const lastNode = lastNodeInstance._lastNode; + patchVNodeWithBlueprint(lastNode, nextVNode, lastNode.bp, nextBp, parentDom, lifecycle, context, instance, nextBp.isSVG); + } else { + unmountVNode(lastVNode, null, true); + patchVNodeWithBlueprint(lastNodeInstance, nextVNode, lastNodeInstance.bp, nextBp, parentDom, lifecycle, context, instance, nextBp.isSVG); + } + } else { + replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, nextBp.isSVG); + } + } else if (isNullOrUndefined(lastTag)) { + nextVNode.dom = lastVNode.dom; + } else { + if (lastBp && lastBp.isComponent === true) { + if (nextBp.isComponent === true) { + const instance = lastVNode.instance; + + if (!isNullOrUndefined(instance) && instance._unmounted) { + const newDom = mountComponent(nextVNode, lastTag, nextVNode.attrs || {}, nextVNode.hooks, nextVNode.children, instance, parentDom, lifecycle, context); + if (parentDom !== null) { + replaceNode(parentDom, newDom, lastVNode.dom); + } + } else { + nextVNode.instance = instance; + nextVNode.dom = lastVNode.dom; + patchComponent(true, nextVNode, nextVNode.tag, lastBp, nextBp, instance, lastVNode.attrs || {}, nextVNode.attrs || {}, nextVNode.hooks, lastVNode.children, nextVNode.children, parentDom, lifecycle, context); + } + } + } else { + const dom = lastVNode.dom; + const lastChildrenType = lastBp.childrenType; + const nextChildrenType = nextBp.childrenType; + nextVNode.dom = dom; + + if (nextBp.lazy === true && skipLazyCheck === false) { + const clipData = lastVNode.clipData; + + if (lifecycle.scrollY === null) { + lifecycle.refresh(); + } + + nextVNode.clipData = clipData; + if (clipData.pending === true || clipData.top - lifecycle.scrollY > lifecycle.screenHeight) { + if (setClipNode(clipData, dom, lastVNode, nextVNode, parentDom, lifecycle, context, instance, lastBp.isSVG)) { + return; + } + } + if (clipData.bottom < lifecycle.scrollY) { + if (setClipNode(clipData, dom, lastVNode, nextVNode, parentDom, lifecycle, context, instance, lastBp.isSVG)) { + return; + } + } + } + + if (lastChildrenType > 0 || nextChildrenType > 0) { + if (nextChildrenType === 5 || lastChildrenType === 5) { + patchChildren(lastVNode, nextVNode, dom, lifecycle, context, instance); + } else { + const lastChildren = lastVNode.children; + const nextChildren = nextVNode.children; + + if (lastChildrenType === 0 || isInvalidNode(lastChildren)) { + if (nextChildrenType > 2) { + mountArrayChildren(nextChildren, dom, lifecycle, context, instance); + } else { + mount(nextChildren, dom, lifecycle, context, instance); + } + } else if (nextChildrenType === 0 || isInvalidNode(nextChildren)) { + if (lastChildrenType > 2) { + removeAllChildren(dom, lastChildren); + } else { + remove(lastChildren, dom); + } + } else { + if (lastChildren !== nextChildren) { + if (lastChildrenType === 4 && nextChildrenType === 4) { + patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, nextBp.isSVG, null); + } else if (lastChildrenType === 2 && nextChildrenType === 2) { + patch(lastChildren, nextChildren, dom, lifecycle, context, instance, true, nextBp.isSVG); + } else if (lastChildrenType === 1 && nextChildrenType === 1) { + patchTextNode(dom, lastChildren, nextChildren); + } else { + patchChildren(lastVNode, nextVNode, dom, lifecycle, context, instance, nextBp.isSVG); + } + } + } + } + } + if (lastBp.hasAttrs === true || nextBp.hasAttrs === true) { + patchAttributes(lastVNode, nextVNode, lastBp.attrKeys, nextBp.attrKeys, dom, instance); + } + if (lastBp.hasEvents === true || nextBp.hasEvents === true) { + patchEvents(lastVNode.events, nextVNode.events, lastBp.eventKeys, nextBp.eventKeys, dom); + } + if (lastBp.hasClassName === true || nextBp.hasClassName === true) { + const nextClassName = nextVNode.className; + + if (lastVNode.className !== nextClassName) { + if (isNullOrUndefined(nextClassName)) { + dom.removeAttribute('class'); + } else { + dom.className = nextClassName; + } + } + } + if (lastBp.hasStyle === true || nextBp.hasStyle === true) { + const nextStyle = nextVNode.style; + const lastStyle = lastVNode.style; + + if (lastStyle !== nextStyle) { + patchStyle(lastStyle, nextStyle, dom); + } + } + if (nextBp.hasHooks === true && !isNullOrUndefined(nextHooks.didUpdate)) { + nextHooks.didUpdate(dom); + } + setFormElementProperties(nextTag, nextVNode); + } + } } export function patchVNodeWithoutBlueprint(lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG) { - const nextHooks = nextNode.hooks; - const nextHooksDefined = !isNullOrUndefined(nextHooks); - - if (nextHooksDefined && !isNullOrUndefined(nextHooks.willUpdate)) { - nextHooks.willUpdate(lastNode.dom); - } - const nextTag = nextNode.tag || ((isNullOrUndefined(nextNode.bp)) ? null : nextNode.bp.tag); - const lastTag = lastNode.tag || ((isNullOrUndefined(lastNode.bp)) ? null : lastNode.bp.tag); - - if (nextTag === 'svg') { - isSVG = true; - } - if (lastTag !== nextTag) { - const lastNodeInstance = lastNode.instance; - - if (isFunction(lastTag)) { - if (isFunction(nextTag)) { - replaceWithNewNode(lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); - } else if (isStatefulComponent(lastTag)) { - unmountVNode(lastNode, null, true); - patchVNodeWithoutBlueprint(lastNodeInstance._lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); - } else { - unmountVNode(lastNode, null, true); - patchVNodeWithoutBlueprint(lastNodeInstance, nextNode, parentDom, lifecycle, context, instance, isSVG); - } - } else { - replaceWithNewNode(lastNodeInstance || lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); - } - } else if (isNullOrUndefined(lastTag)) { - nextNode.dom = lastNode.dom; - } else { - if (isFunction(lastTag)) { - if (isFunction(nextTag)) { - const instance = lastNode._instance; - - if (!isNullOrUndefined(instance) && instance._unmounted) { - const newDom = mountComponent(nextNode, lastTag, nextNode.attrs || {}, nextNode.hooks, nextNode.children, instance, parentDom, lifecycle, context); - if (parentDom !== null) { - replaceNode(parentDom, newDom, lastNode.dom); - } - } else { - nextNode.instance = lastNode.instance; - nextNode.dom = lastNode.dom; - patchComponent(false, nextNode, nextNode.tag, null, null, nextNode.instance, lastNode.attrs || {}, nextNode.attrs || {}, nextNode.hooks, lastNode.children, nextNode.children, parentDom, lifecycle, context); - } - } - } else { - const dom = lastNode.dom; - const nextClassName = nextNode.className; - const nextStyle = nextNode.style; - - nextNode.dom = dom; - - patchChildren(lastNode, nextNode, dom, lifecycle, context, instance, isSVG); - patchAttributes(lastNode, nextNode, null, null, dom, instance); - patchEvents(lastNode.events, nextNode.events, null, null, dom); - - if (lastNode.className !== nextClassName) { - if (isNullOrUndefined(nextClassName)) { - dom.removeAttribute('class'); - } else { - dom.className = nextClassName; - } - } - if (lastNode.style !== nextStyle) { - patchStyle(lastNode.style, nextStyle, dom); - } - if (nextHooksDefined && !isNullOrUndefined(nextHooks.didUpdate)) { - nextHooks.didUpdate(dom); - } - setFormElementProperties(nextTag, nextNode); - } - } + const nextHooks = nextNode.hooks; + const nextHooksDefined = !isNullOrUndefined(nextHooks); + + if (nextHooksDefined && !isNullOrUndefined(nextHooks.willUpdate)) { + nextHooks.willUpdate(lastNode.dom); + } + const nextTag = nextNode.tag || ((isNullOrUndefined(nextNode.bp)) ? null : nextNode.bp.tag); + const lastTag = lastNode.tag || ((isNullOrUndefined(lastNode.bp)) ? null : lastNode.bp.tag); + + if (nextTag === 'svg') { + isSVG = true; + } + if (lastTag !== nextTag) { + const lastNodeInstance = lastNode.instance; + + if (isFunction(lastTag)) { + if (isFunction(nextTag)) { + replaceWithNewNode(lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); + } else if (isStatefulComponent(lastTag)) { + unmountVNode(lastNode, null, true); + patchVNodeWithoutBlueprint(lastNodeInstance._lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); + } else { + unmountVNode(lastNode, null, true); + patchVNodeWithoutBlueprint(lastNodeInstance, nextNode, parentDom, lifecycle, context, instance, isSVG); + } + } else { + replaceWithNewNode(lastNodeInstance || lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); + } + } else if (isNullOrUndefined(lastTag)) { + nextNode.dom = lastNode.dom; + } else { + if (isFunction(lastTag)) { + if (isFunction(nextTag)) { + const instance = lastNode._instance; + + if (!isNullOrUndefined(instance) && instance._unmounted) { + const newDom = mountComponent(nextNode, lastTag, nextNode.attrs || {}, nextNode.hooks, nextNode.children, instance, parentDom, lifecycle, context); + if (parentDom !== null) { + replaceNode(parentDom, newDom, lastNode.dom); + } + } else { + nextNode.instance = lastNode.instance; + nextNode.dom = lastNode.dom; + patchComponent(false, nextNode, nextNode.tag, null, null, nextNode.instance, lastNode.attrs || {}, nextNode.attrs || {}, nextNode.hooks, lastNode.children, nextNode.children, parentDom, lifecycle, context); + } + } + } else { + const dom = lastNode.dom; + const nextClassName = nextNode.className; + const nextStyle = nextNode.style; + + nextNode.dom = dom; + + patchChildren(lastNode, nextNode, dom, lifecycle, context, instance, isSVG); + patchAttributes(lastNode, nextNode, null, null, dom, instance); + patchEvents(lastNode.events, nextNode.events, null, null, dom); + + if (lastNode.className !== nextClassName) { + if (isNullOrUndefined(nextClassName)) { + dom.removeAttribute('class'); + } else { + dom.className = nextClassName; + } + } + if (lastNode.style !== nextStyle) { + patchStyle(lastNode.style, nextStyle, dom); + } + if (nextHooksDefined && !isNullOrUndefined(nextHooks.didUpdate)) { + nextHooks.didUpdate(dom); + } + setFormElementProperties(nextTag, nextNode); + } + } } function patchAttributes(lastNode, nextNode, lastAttrKeys, nextAttrKeys, dom, instance) { - if (lastNode.tag === 'select') { - selectValue(nextNode); - } - const nextAttrs = nextNode.attrs; - const lastAttrs = lastNode.attrs; - const nextAttrsIsUndef = isNullOrUndefined(nextAttrs); - const lastAttrsIsNotUndef = !isNullOrUndefined(lastAttrs); - - if (!nextAttrsIsUndef) { - const nextAttrsKeys = nextAttrKeys || Object.keys(nextAttrs); - const attrKeysLength = nextAttrsKeys.length; - - for (let i = 0; i < attrKeysLength; i++) { - const attr = nextAttrsKeys[i]; - const lastAttrVal = lastAttrsIsNotUndef && lastAttrs[attr]; - const nextAttrVal = nextAttrs[attr]; - - if (lastAttrVal !== nextAttrVal) { - if (attr === 'ref') { - patchRef(instance, lastAttrVal, nextAttrVal, dom); - } else { - patchAttribute(attr, lastAttrVal, nextAttrVal, dom); - } - } - } - } - if (lastAttrsIsNotUndef) { - const lastAttrsKeys = lastAttrKeys || Object.keys(lastAttrs); - const attrKeysLength = lastAttrsKeys.length; - - for (let i = 0; i < attrKeysLength; i++) { - const attr = lastAttrsKeys[i]; - - if (nextAttrsIsUndef || isNullOrUndefined(nextAttrs[attr])) { - if (attr === 'ref') { - patchRef(getRefInstance(node, instance), lastAttrs[attr], null, dom); - } else { - dom.removeAttribute(attr); - } - } - } - } + if (lastNode.tag === 'select') { + selectValue(nextNode); + } + const nextAttrs = nextNode.attrs; + const lastAttrs = lastNode.attrs; + const nextAttrsIsUndef = isNullOrUndefined(nextAttrs); + const lastAttrsIsNotUndef = !isNullOrUndefined(lastAttrs); + + if (!nextAttrsIsUndef) { + const nextAttrsKeys = nextAttrKeys || Object.keys(nextAttrs); + const attrKeysLength = nextAttrsKeys.length; + + for (let i = 0; i < attrKeysLength; i++) { + const attr = nextAttrsKeys[i]; + const lastAttrVal = lastAttrsIsNotUndef && lastAttrs[attr]; + const nextAttrVal = nextAttrs[attr]; + + if (lastAttrVal !== nextAttrVal) { + if (attr === 'ref') { + patchRef(instance, lastAttrVal, nextAttrVal, dom); + } else { + patchAttribute(attr, lastAttrVal, nextAttrVal, dom); + } + } + } + } + if (lastAttrsIsNotUndef) { + const lastAttrsKeys = lastAttrKeys || Object.keys(lastAttrs); + const attrKeysLength = lastAttrsKeys.length; + + for (let i = 0; i < attrKeysLength; i++) { + const attr = lastAttrsKeys[i]; + + if (nextAttrsIsUndef || isNullOrUndefined(nextAttrs[attr])) { + if (attr === 'ref') { + patchRef(getRefInstance(node, instance), lastAttrs[attr], null, dom); + } else { + dom.removeAttribute(attr); + } + } + } + } } export function patchStyle(lastAttrValue, nextAttrValue, dom) { - if (isString(nextAttrValue)) { - dom.style.cssText = nextAttrValue; - } else if (isNullOrUndefined(lastAttrValue)) { - if (!isNullOrUndefined(nextAttrValue)) { - const styleKeys = Object.keys(nextAttrValue); - - for (let i = 0; i < styleKeys.length; i++) { - const style = styleKeys[i]; - const value = nextAttrValue[style]; - - if (isNumber(value) && !isUnitlessNumber[style]) { - dom.style[style] = value + 'px'; - } else { - dom.style[style] = value; - } - } - } - } else if (isNullOrUndefined(nextAttrValue)) { - dom.removeAttribute('style'); - } else { - const styleKeys = Object.keys(nextAttrValue); - - for (let i = 0; i < styleKeys.length; i++) { - const style = styleKeys[i]; - const value = nextAttrValue[style]; - - if (isNumber(value) && !isUnitlessNumber[style]) { - dom.style[style] = value + 'px'; - } else { - dom.style[style] = value; - } - } - const lastStyleKeys = Object.keys(lastAttrValue); - - for (let i = 0; i < lastStyleKeys.length; i++) { - const style = lastStyleKeys[i]; - if (isNullOrUndefined(nextAttrValue[style])) { - dom.style[style] = ''; - } - } - } + if (isString(nextAttrValue)) { + dom.style.cssText = nextAttrValue; + } else if (isNullOrUndefined(lastAttrValue)) { + if (!isNullOrUndefined(nextAttrValue)) { + const styleKeys = Object.keys(nextAttrValue); + + for (let i = 0; i < styleKeys.length; i++) { + const style = styleKeys[i]; + const value = nextAttrValue[style]; + + if (isNumber(value) && !isUnitlessNumber[style]) { + dom.style[style] = value + 'px'; + } else { + dom.style[style] = value; + } + } + } + } else if (isNullOrUndefined(nextAttrValue)) { + dom.removeAttribute('style'); + } else { + const styleKeys = Object.keys(nextAttrValue); + + for (let i = 0; i < styleKeys.length; i++) { + const style = styleKeys[i]; + const value = nextAttrValue[style]; + + if (isNumber(value) && !isUnitlessNumber[style]) { + dom.style[style] = value + 'px'; + } else { + dom.style[style] = value; + } + } + const lastStyleKeys = Object.keys(lastAttrValue); + + for (let i = 0; i < lastStyleKeys.length; i++) { + const style = lastStyleKeys[i]; + if (isNullOrUndefined(nextAttrValue[style])) { + dom.style[style] = ''; + } + } + } } export function patchEvents(lastEvents, nextEvents, _lastEventKeys, _nextEventKeys, dom) { - const nextEventsDefined = !isNullOrUndefined(nextEvents); - const lastEventsDefined = !isNullOrUndefined(lastEvents); - let lastEventKeys; - - if (lastEventsDefined) { - lastEventKeys = _lastEventKeys || Object.keys(lastEvents); - } - if (nextEventsDefined) { - const nextEventKeys = _nextEventKeys || Object.keys(nextEvents); - - if (lastEventsDefined) { - for (let i = 0; i < nextEventKeys.length; i++) { - const event = nextEventKeys[i]; - const lastEvent = lastEvents[event]; - const nextEvent = nextEvents[event]; - - if (lastEvent !== nextEvent) { - dom[event] = nextEvent; - } - } - for (let i = 0; i < lastEventKeys.length; i++) { - const event = lastEventKeys[i]; - - if (isNullOrUndefined(nextEvents[event])) { - dom[event] = null; - } - } - } else { - mountEvents(nextEvents, nextEventKeys, dom); - } - } else if (lastEventsDefined) { - removeEvents(lastEvents, lastEventKeys, dom); - } + const nextEventsDefined = !isNullOrUndefined(nextEvents); + const lastEventsDefined = !isNullOrUndefined(lastEvents); + let lastEventKeys; + + if (lastEventsDefined) { + lastEventKeys = _lastEventKeys || Object.keys(lastEvents); + } + if (nextEventsDefined) { + const nextEventKeys = _nextEventKeys || Object.keys(nextEvents); + + if (lastEventsDefined) { + for (let i = 0; i < nextEventKeys.length; i++) { + const event = nextEventKeys[i]; + const lastEvent = lastEvents[event]; + const nextEvent = nextEvents[event]; + + if (lastEvent !== nextEvent) { + dom[event] = nextEvent; + } + } + for (let i = 0; i < lastEventKeys.length; i++) { + const event = lastEventKeys[i]; + + if (isNullOrUndefined(nextEvents[event])) { + dom[event] = null; + } + } + } else { + mountEvents(nextEvents, nextEventKeys, dom); + } + } else if (lastEventsDefined) { + removeEvents(lastEvents, lastEventKeys, dom); + } } export function patchAttribute(attrName, lastAttrValue, nextAttrValue, dom) { - if (attrName === 'dangerouslySetInnerHTML') { - const lastHtml = lastAttrValue && lastAttrValue.__html; - const nextHtml = nextAttrValue && nextAttrValue.__html; - - if (isNullOrUndefined(nextHtml)) { - throw new Error('Inferno Error: dangerouslySetInnerHTML requires an object with a __html propety containing the innerHTML content'); - } - if (lastHtml !== nextHtml) { - dom.innerHTML = nextHtml; - } - } else if (attrName === 'eventData') { - dom.eventData = nextAttrValue; - } else if (strictProps[attrName]) { - dom[attrName] = nextAttrValue === null ? '' : nextAttrValue; - } else { - if (booleanProps[attrName]) { - dom[attrName] = nextAttrValue ? true : false; - } else { - const ns = namespaces[attrName]; - - if (nextAttrValue === false || isNullOrUndefined(nextAttrValue)) { - if (ns !== undefined) { - dom.removeAttributeNS(ns, attrName); - } else { - dom.removeAttribute(attrName); - } - } else { - if (ns !== undefined) { - dom.setAttributeNS(ns, attrName, nextAttrValue === true ? attrName : nextAttrValue); - } else { - dom.setAttribute(attrName, nextAttrValue === true ? attrName : nextAttrValue); - } - } - } - } + if (attrName === 'dangerouslySetInnerHTML') { + const lastHtml = lastAttrValue && lastAttrValue.__html; + const nextHtml = nextAttrValue && nextAttrValue.__html; + + if (isNullOrUndefined(nextHtml)) { + throw new Error('Inferno Error: dangerouslySetInnerHTML requires an object with a __html propety containing the innerHTML content'); + } + if (lastHtml !== nextHtml) { + dom.innerHTML = nextHtml; + } + } else if (attrName === 'eventData') { + dom.eventData = nextAttrValue; + } else if (strictProps[attrName]) { + dom[attrName] = nextAttrValue === null ? '' : nextAttrValue; + } else { + if (booleanProps[attrName]) { + dom[attrName] = nextAttrValue ? true : false; + } else { + const ns = namespaces[attrName]; + + if (nextAttrValue === false || isNullOrUndefined(nextAttrValue)) { + if (ns !== undefined) { + dom.removeAttributeNS(ns, attrName); + } else { + dom.removeAttribute(attrName); + } + } else { + if (ns !== undefined) { + dom.setAttributeNS(ns, attrName, nextAttrValue === true ? attrName : nextAttrValue); + } else { + dom.setAttribute(attrName, nextAttrValue === true ? attrName : nextAttrValue); + } + } + } + } } export function patchComponent(hasBlueprint, lastNode, Component, lastBp, nextBp, instance, lastProps, nextProps, nextHooks, lastChildren, nextChildren, parentDom, lifecycle, context) { - nextProps = addChildrenToProps(nextChildren, nextProps); - - if (isStatefulComponent(Component)) { - const prevProps = instance.props; - const prevState = instance.state; - const nextState = instance.state; - - const childContext = instance.getChildContext(); - if (!isNullOrUndefined(childContext)) { - context = Object.assign({}, context, childContext); - } - instance.context = context; - let nextNode = instance._updateComponent(prevState, nextState, prevProps, nextProps); - - if (nextNode === NO_RENDER) { - nextNode = instance._lastNode; - } else if (isNullOrUndefined(nextNode)) { - nextNode = createVPlaceholder(); - } - patch(instance._lastNode, nextNode, parentDom, lifecycle, context, instance, null, false); - lastNode.dom = nextNode.dom; - instance._lastNode = nextNode; - instance.componentDidUpdate(prevProps, prevState); - componentToDOMNodeMap.set(instance, nextNode.dom); - } else { - let shouldUpdate = true; - const nextHooksDefined = (hasBlueprint && nextBp.hasHooks === true) || !isNullOrUndefined(nextHooks); - - lastProps = addChildrenToProps(lastChildren, lastProps); - if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentShouldUpdate)) { - shouldUpdate = nextHooks.componentShouldUpdate(lastNode.dom, lastProps, nextProps); - } - if (shouldUpdate !== false) { - if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentWillUpdate)) { - nextHooks.componentWillUpdate(lastNode.dom, lastProps, nextProps); - } - let nextNode = Component(nextProps, context); - - if (isInvalidNode(nextNode)) { - nextNode = createVPlaceholder(); - } - nextNode.dom = lastNode.dom; - patch(instance, nextNode, parentDom, lifecycle, context, null, null, false); - lastNode.instance = nextNode; - if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentDidUpdate)) { - nextHooks.componentDidUpdate(lastNode.dom, lastProps, nextProps); - } - } - } + nextProps = addChildrenToProps(nextChildren, nextProps); + + if (isStatefulComponent(Component)) { + const prevProps = instance.props; + const prevState = instance.state; + const nextState = instance.state; + + const childContext = instance.getChildContext(); + if (!isNullOrUndefined(childContext)) { + context = Object.assign({}, context, childContext); + } + instance.context = context; + let nextNode = instance._updateComponent(prevState, nextState, prevProps, nextProps); + + if (nextNode === NO_RENDER) { + nextNode = instance._lastNode; + } else if (isNullOrUndefined(nextNode)) { + nextNode = createVPlaceholder(); + } + patch(instance._lastNode, nextNode, parentDom, lifecycle, context, instance, null, false); + lastNode.dom = nextNode.dom; + instance._lastNode = nextNode; + instance.componentDidUpdate(prevProps, prevState); + componentToDOMNodeMap.set(instance, nextNode.dom); + } else { + let shouldUpdate = true; + const nextHooksDefined = (hasBlueprint && nextBp.hasHooks === true) || !isNullOrUndefined(nextHooks); + + lastProps = addChildrenToProps(lastChildren, lastProps); + if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentShouldUpdate)) { + shouldUpdate = nextHooks.componentShouldUpdate(lastNode.dom, lastProps, nextProps); + } + if (shouldUpdate !== false) { + if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentWillUpdate)) { + nextHooks.componentWillUpdate(lastNode.dom, lastProps, nextProps); + } + let nextNode = Component(nextProps, context); + + if (isInvalidNode(nextNode)) { + nextNode = createVPlaceholder(); + } + nextNode.dom = lastNode.dom; + patch(instance, nextNode, parentDom, lifecycle, context, null, null, false); + lastNode.instance = nextNode; + if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentDidUpdate)) { + nextHooks.componentDidUpdate(lastNode.dom, lastProps, nextProps); + } + } + } } function patchVList(lastVList, nextVList, parentDom, lifecycle, context, instance, isSVG) { - const lastItems = lastVList.items; - const nextItems = nextVList.items; - const pointer = lastVList.pointer; - - nextVList.dom = lastVList.dom; - nextVList.pointer = pointer; - if (!lastItems !== nextItems) { - if (isKeyed(lastItems, nextItems)) { - patchKeyedChildren(lastItems, nextItems, parentDom, lifecycle, context, instance, isSVG, nextVList); - } else { - patchNonKeyedChildren(lastItems, nextItems, parentDom, lifecycle, context, instance, isSVG, nextVList); - } - } + const lastItems = lastVList.items; + const nextItems = nextVList.items; + const pointer = lastVList.pointer; + + nextVList.dom = lastVList.dom; + nextVList.pointer = pointer; + if (!lastItems !== nextItems) { + if (isKeyed(lastItems, nextItems)) { + patchKeyedChildren(lastItems, nextItems, parentDom, lifecycle, context, instance, isSVG, nextVList); + } else { + patchNonKeyedChildren(lastItems, nextItems, parentDom, lifecycle, context, instance, isSVG, nextVList); + } + } } export function patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, parentVList) { - let lastChildrenLength = lastChildren.length; - let nextChildrenLength = nextChildren.length; - let commonLength = lastChildrenLength > nextChildrenLength ? nextChildrenLength : lastChildrenLength; - let i = 0; - - for (; i < commonLength; i++) { - const lastChild = lastChildren[i]; - const nextChild = normaliseChild(nextChildren, i); - - patch(lastChild, nextChild, dom, lifecycle, context, instance, isSVG); - } - if (lastChildrenLength < nextChildrenLength) { - for (i = commonLength; i < nextChildrenLength; i++) { - const child = normaliseChild(nextChildren, i); - - insertOrAppend(dom, mount(child, null, lifecycle, context, instance, isSVG), parentVList && parentVList.pointer); - } - } else if (lastChildrenLength > nextChildrenLength) { - for (i = commonLength; i < lastChildrenLength; i++) { - remove(lastChildren[i], dom); - } - } + let lastChildrenLength = lastChildren.length; + let nextChildrenLength = nextChildren.length; + let commonLength = lastChildrenLength > nextChildrenLength ? nextChildrenLength : lastChildrenLength; + let i = 0; + + for (; i < commonLength; i++) { + const lastChild = lastChildren[i]; + const nextChild = normaliseChild(nextChildren, i); + + patch(lastChild, nextChild, dom, lifecycle, context, instance, isSVG); + } + if (lastChildrenLength < nextChildrenLength) { + for (i = commonLength; i < nextChildrenLength; i++) { + const child = normaliseChild(nextChildren, i); + + insertOrAppend(dom, mount(child, null, lifecycle, context, instance, isSVG), parentVList && parentVList.pointer); + } + } else if (lastChildrenLength > nextChildrenLength) { + for (i = commonLength; i < lastChildrenLength; i++) { + remove(lastChildren[i], dom); + } + } } export function patchVFragment(lastVFragment, nextVFragment) { - nextVFragment.dom = lastVFragment.dom; + nextVFragment.dom = lastVFragment.dom; } export function patchVText(lastVText, nextVText) { - const nextText = nextVText.text; - const dom = lastVText.dom; + const nextText = nextVText.text; + const dom = lastVText.dom; - nextVText.dom = dom; - if (lastVText.text !== nextText) { - dom.nodeValue = nextText; - } + nextVText.dom = dom; + if (lastVText.text !== nextText) { + dom.nodeValue = nextText; + } } export function patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, parentVList) { - let lastChildrenLength = lastChildren.length; - let nextChildrenLength = nextChildren.length; - let lastEndIndex = lastChildrenLength - 1; - let nextEndIndex = nextChildrenLength - 1; - let lastStartIndex = 0; - let nextStartIndex = 0; - let lastStartNode = null; - let nextStartNode = null; - let nextEndNode = null; - let lastEndNode = null; - let nextNode; - - while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { - nextStartNode = nextChildren[nextStartIndex]; - lastStartNode = lastChildren[lastStartIndex]; - - if (nextStartNode.key !== lastStartNode.key) { - break; - } - patchVNode(lastStartNode, nextStartNode, dom, lifecycle, context, instance, isSVG, false); - nextStartIndex++; - lastStartIndex++; - } - while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { - nextEndNode = nextChildren[nextEndIndex]; - lastEndNode = lastChildren[lastEndIndex]; - - if (nextEndNode.key !== lastEndNode.key) { - break; - } - patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); - nextEndIndex--; - lastEndIndex--; - } - while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { - nextEndNode = nextChildren[nextEndIndex]; - lastStartNode = lastChildren[lastStartIndex]; - - if (nextEndNode.key !== lastStartNode.key) { - break; - } - nextNode = (nextEndIndex + 1 < nextChildrenLength) ? nextChildren[nextEndIndex + 1].dom : null; - patchVNode(lastStartNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); - insertOrAppend(dom, nextEndNode.dom, nextNode); - nextEndIndex--; - lastStartIndex++; - } - while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { - nextStartNode = nextChildren[nextStartIndex]; - lastEndNode = lastChildren[lastEndIndex]; - - if (nextStartNode.key !== lastEndNode.key) { - break; - } - nextNode = lastChildren[lastStartIndex].dom; - patchVNode(lastEndNode, nextStartNode, dom, lifecycle, context, instance, isSVG, false); - insertOrAppend(dom, nextStartNode.dom, nextNode); - nextStartIndex++; - lastEndIndex--; - } - - if (lastStartIndex > lastEndIndex) { - if (nextStartIndex <= nextEndIndex) { - nextNode = (nextEndIndex + 1 < nextChildrenLength) ? nextChildren[nextEndIndex + 1].dom : parentVList && parentVList.pointer; - for (; nextStartIndex <= nextEndIndex; nextStartIndex++) { - insertOrAppend(dom, mount(nextChildren[nextStartIndex], null, lifecycle, context, instance, isSVG), nextNode); - } - } - } else if (nextStartIndex > nextEndIndex) { - while (lastStartIndex <= lastEndIndex) { - remove(lastChildren[lastStartIndex++], dom); - } - } else { - let aLength = lastEndIndex - lastStartIndex + 1; - let bLength = nextEndIndex - nextStartIndex + 1; - const sources = new Array(bLength); - - // Mark all nodes as inserted. - let i; - for (i = 0; i < bLength; i++) { - sources[i] = -1; - } - let moved = false; - let removeOffset = 0; - let lastTarget = 0; - let index; - let removed = true; - let k = 0; - - if ((bLength <= 4) || (aLength * bLength <= 16)) { - for (i = lastStartIndex; i <= lastEndIndex; i++) { - removed = true; - lastEndNode = lastChildren[i]; - if (k < bLength) { - for (index = nextStartIndex; index <= nextEndIndex; index++) { - nextEndNode = nextChildren[index]; - if (lastEndNode.key === nextEndNode.key) { - sources[index - nextStartIndex] = i; - - if (lastTarget > index) { - moved = true; - } else { - lastTarget = index; - } - patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); - k++; - removed = false; - break; - } - } - } - if (removed) { - remove(lastEndNode, dom); - removeOffset++; - } - } - } else { - const prevItemsMap = new Map(); - - for (i = nextStartIndex; i <= nextEndIndex; i++) { - prevItemsMap.set(nextChildren[i].key, i); - } - for (i = lastStartIndex; i <= lastEndIndex; i++) { - removed = true; - lastEndNode = lastChildren[i]; - - if (k < nextChildrenLength) { - index = prevItemsMap.get(lastEndNode.key); - - if (index !== undefined) { - nextEndNode = nextChildren[index]; - sources[index - nextStartIndex] = i; - if (lastTarget > index) { - moved = true; - } else { - lastTarget = index; - } - patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); - k++; - removed = false; - } - } - if (removed) { - remove(lastEndNode, dom); - removeOffset++; - } - } - } - - let pos; - if (moved) { - let seq = lis_algorithm(sources); - index = seq.length - 1; - for (i = bLength - 1; i >= 0; i--) { - if (sources[i] === -1) { - pos = i + nextStartIndex; - nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; - insertOrAppend(dom, mount(nextChildren[pos], null, lifecycle, context, instance, isSVG), nextNode); - } else { - if (index < 0 || i !== seq[index]) { - pos = i + nextStartIndex; - nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; - insertOrAppend(dom, nextChildren[pos].dom, nextNode); - } else { - index--; - } - } - } - } else if (aLength - removeOffset !== bLength) { - for (i = bLength - 1; i >= 0; i--) { - if (sources[i] === -1) { - pos = i + nextStartIndex; - nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; - insertOrAppend(dom, mount(nextChildren[pos], null, lifecycle, context, instance, isSVG), nextNode); - } - } - } - } + let lastChildrenLength = lastChildren.length; + let nextChildrenLength = nextChildren.length; + let lastEndIndex = lastChildrenLength - 1; + let nextEndIndex = nextChildrenLength - 1; + let lastStartIndex = 0; + let nextStartIndex = 0; + let lastStartNode = null; + let nextStartNode = null; + let nextEndNode = null; + let lastEndNode = null; + let nextNode; + + while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { + nextStartNode = nextChildren[nextStartIndex]; + lastStartNode = lastChildren[lastStartIndex]; + + if (nextStartNode.key !== lastStartNode.key) { + break; + } + patchVNode(lastStartNode, nextStartNode, dom, lifecycle, context, instance, isSVG, false); + nextStartIndex++; + lastStartIndex++; + } + while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { + nextEndNode = nextChildren[nextEndIndex]; + lastEndNode = lastChildren[lastEndIndex]; + + if (nextEndNode.key !== lastEndNode.key) { + break; + } + patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); + nextEndIndex--; + lastEndIndex--; + } + while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { + nextEndNode = nextChildren[nextEndIndex]; + lastStartNode = lastChildren[lastStartIndex]; + + if (nextEndNode.key !== lastStartNode.key) { + break; + } + nextNode = (nextEndIndex + 1 < nextChildrenLength) ? nextChildren[nextEndIndex + 1].dom : null; + patchVNode(lastStartNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); + insertOrAppend(dom, nextEndNode.dom, nextNode); + nextEndIndex--; + lastStartIndex++; + } + while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { + nextStartNode = nextChildren[nextStartIndex]; + lastEndNode = lastChildren[lastEndIndex]; + + if (nextStartNode.key !== lastEndNode.key) { + break; + } + nextNode = lastChildren[lastStartIndex].dom; + patchVNode(lastEndNode, nextStartNode, dom, lifecycle, context, instance, isSVG, false); + insertOrAppend(dom, nextStartNode.dom, nextNode); + nextStartIndex++; + lastEndIndex--; + } + + if (lastStartIndex > lastEndIndex) { + if (nextStartIndex <= nextEndIndex) { + nextNode = (nextEndIndex + 1 < nextChildrenLength) ? nextChildren[nextEndIndex + 1].dom : parentVList && parentVList.pointer; + for (; nextStartIndex <= nextEndIndex; nextStartIndex++) { + insertOrAppend(dom, mount(nextChildren[nextStartIndex], null, lifecycle, context, instance, isSVG), nextNode); + } + } + } else if (nextStartIndex > nextEndIndex) { + while (lastStartIndex <= lastEndIndex) { + remove(lastChildren[lastStartIndex++], dom); + } + } else { + let aLength = lastEndIndex - lastStartIndex + 1; + let bLength = nextEndIndex - nextStartIndex + 1; + const sources = new Array(bLength); + + // Mark all nodes as inserted. + let i; + for (i = 0; i < bLength; i++) { + sources[i] = -1; + } + let moved = false; + let removeOffset = 0; + let lastTarget = 0; + let index; + let removed = true; + let k = 0; + + if ((bLength <= 4) || (aLength * bLength <= 16)) { + for (i = lastStartIndex; i <= lastEndIndex; i++) { + removed = true; + lastEndNode = lastChildren[i]; + if (k < bLength) { + for (index = nextStartIndex; index <= nextEndIndex; index++) { + nextEndNode = nextChildren[index]; + if (lastEndNode.key === nextEndNode.key) { + sources[index - nextStartIndex] = i; + + if (lastTarget > index) { + moved = true; + } else { + lastTarget = index; + } + patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); + k++; + removed = false; + break; + } + } + } + if (removed) { + remove(lastEndNode, dom); + removeOffset++; + } + } + } else { + const prevItemsMap = new Map(); + + for (i = nextStartIndex; i <= nextEndIndex; i++) { + prevItemsMap.set(nextChildren[i].key, i); + } + for (i = lastStartIndex; i <= lastEndIndex; i++) { + removed = true; + lastEndNode = lastChildren[i]; + + if (k < nextChildrenLength) { + index = prevItemsMap.get(lastEndNode.key); + + if (index !== undefined) { + nextEndNode = nextChildren[index]; + sources[index - nextStartIndex] = i; + if (lastTarget > index) { + moved = true; + } else { + lastTarget = index; + } + patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); + k++; + removed = false; + } + } + if (removed) { + remove(lastEndNode, dom); + removeOffset++; + } + } + } + + let pos; + if (moved) { + let seq = lis_algorithm(sources); + index = seq.length - 1; + for (i = bLength - 1; i >= 0; i--) { + if (sources[i] === -1) { + pos = i + nextStartIndex; + nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; + insertOrAppend(dom, mount(nextChildren[pos], null, lifecycle, context, instance, isSVG), nextNode); + } else { + if (index < 0 || i !== seq[index]) { + pos = i + nextStartIndex; + nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; + insertOrAppend(dom, nextChildren[pos].dom, nextNode); + } else { + index--; + } + } + } + } else if (aLength - removeOffset !== bLength) { + for (i = bLength - 1; i >= 0; i--) { + if (sources[i] === -1) { + pos = i + nextStartIndex; + nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; + insertOrAppend(dom, mount(nextChildren[pos], null, lifecycle, context, instance, isSVG), nextNode); + } + } + } + } } // https://en.wikipedia.org/wiki/Longest_increasing_subsequence function lis_algorithm(a) { - let p = a.slice(0); - let result = []; - result.push(0); - let i; - let j; - let u; - let v; - let c; - - for (i = 0; i < a.length; i++) { - if (a[i] === -1) { - continue; - } - - j = result[result.length - 1]; - if (a[j] < a[i]) { - p[i] = j; - result.push(i); - continue; - } - - u = 0; - v = result.length - 1; - - while (u < v) { - c = ((u + v) / 2) | 0; - if (a[result[c]] < a[i]) { - u = c + 1; - } else { - v = c; - } - } - - if (a[i] < a[result[u]]) { - if (u > 0) { - p[i] = result[u - 1]; - } - result[u] = i; - } - } - - u = result.length; - v = result[u - 1]; - - while (u-- > 0) { - result[u] = v; - v = p[v]; - } - - return result; + let p = a.slice(0); + let result = []; + result.push(0); + let i; + let j; + let u; + let v; + let c; + + for (i = 0; i < a.length; i++) { + if (a[i] === -1) { + continue; + } + + j = result[result.length - 1]; + if (a[j] < a[i]) { + p[i] = j; + result.push(i); + continue; + } + + u = 0; + v = result.length - 1; + + while (u < v) { + c = ((u + v) / 2) | 0; + if (a[result[c]] < a[i]) { + u = c + 1; + } else { + v = c; + } + } + + if (a[i] < a[result[u]]) { + if (u > 0) { + p[i] = result[u - 1]; + } + result[u] = i; + } + } + + u = result.length; + v = result[u - 1]; + + while (u-- > 0) { + result[u] = v; + v = p[v]; + } + + return result; } From 110ef96c88c8e774eee8ddac83f307a5e6b335b9 Mon Sep 17 00:00:00 2001 From: Fops Date: Thu, 18 Aug 2016 18:45:58 +0200 Subject: [PATCH 2/4] fixing formatting --- src/DOM/patching.js | 1668 ++++++++++++++++++++++--------------------- 1 file changed, 854 insertions(+), 814 deletions(-) diff --git a/src/DOM/patching.js b/src/DOM/patching.js index 16f4bb2cd..907c31ed8 100644 --- a/src/DOM/patching.js +++ b/src/DOM/patching.js @@ -1,874 +1,914 @@ -import { isNullOrUndefined, isString, addChildrenToProps, isStatefulComponent, isStringOrNumber, isInvalidNode, NO_RENDER, isNumber, isFunction, isArray } from './../core/utils'; -import { mount, mountVText, mountVPlaceholder, mountVList, mountArrayChildren, mountComponent, mountEvents } from './mounting'; -import { insertOrAppend, remove, isKeyed, replaceNode, isUnitlessNumber, booleanProps, strictProps, namespaces, isVText, isVPlaceholder, replaceVListWithNode, isVList, normaliseChild, setFormElementProperties, removeAllChildren, replaceWithNewNode, removeEvents, selectValue, isVNode, normalise } from './utils'; +import { + isNullOrUndefined, + isString, + addChildrenToProps, + isStatefulComponent, + isStringOrNumber, + isInvalidNode, + NO_RENDER, + isNumber, + isFunction, + isArray +} from './../core/utils'; +import { + mount, + mountVText, + mountVPlaceholder, + mountVList, + mountArrayChildren, + mountComponent, + mountEvents +} from './mounting'; +import { + insertOrAppend, + remove, + isKeyed, + replaceNode, + isUnitlessNumber, + booleanProps, + strictProps, + namespaces, + isVText, + isVPlaceholder, + replaceVListWithNode, + isVList, + normaliseChild, + setFormElementProperties, + removeAllChildren, + replaceWithNewNode, + removeEvents, + selectValue, + isVNode, + normalise +} from './utils'; import { componentToDOMNodeMap } from './rendering'; import { createVPlaceholder, createVText } from '../core/shapes'; import { unmount, unmountVNode } from './unmounting'; export function patch(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG) { - if (lastInput !== nextInput) { - if (isInvalidNode(lastInput)) { - mount(nextInput, parentDom, lifecycle, context, instance, isSVG); - } else if (isInvalidNode(nextInput)) { - remove(lastInput, parentDom); - } else if (isStringOrNumber(lastInput)) { - if (isStringOrNumber(nextInput)) { - parentDom.firstChild.nodeValue = nextInput; - } else { - const dom = mount(nextInput, null, lifecycle, context, instance, isSVG); - - nextInput.dom = dom; - replaceNode(parentDom, dom, parentDom.firstChild); - } - } else if (isStringOrNumber(nextInput)) { - replaceNode(parentDom, document.createTextNode(nextInput), lastInput.dom); - } else { - if (isVList(nextInput)) { - if (isVList(lastInput)) { - patchVList(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG); - } else { - replaceNode(parentDom, mountVList(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); - unmount(lastInput, null); - } - } else if (isVList(lastInput)) { - replaceVListWithNode(parentDom, lastInput, mount(nextInput, null, lifecycle, context, instance, isSVG)); - } else if (isVPlaceholder(nextInput)) { - if (isVPlaceholder(lastInput)) { - patchVFragment(lastInput, nextInput); - } else { - replaceNode(parentDom, mountVPlaceholder(nextInput, null), lastInput.dom); - unmount(lastInput, null); - } - } else if (isVPlaceholder(lastInput)) { - replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); - } else if (isVText(nextInput)) { - if (isVText(lastInput)) { - patchVText(lastInput, nextInput); - } else { - replaceNode(parentDom, mountVText(nextInput, null), lastInput.dom); - unmount(lastInput, null); - } - } else if (isVText(lastInput)) { - replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); - } else if (isVNode(nextInput)) { - if (isVNode(lastInput)) { - patchVNode(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG, false); - } else { - replaceNode(parentDom, mountVNode(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); - unmount(lastInput, null); - } - } else if (isVNode(lastInput)) { - replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); - unmount(lastInput, null); - } else { - return patch(lastInput, normalise(nextInput), parentDom, lifecycle, context, instance, isSVG); - } - } - } - return nextInput; + if (lastInput !== nextInput) { + if (isInvalidNode(lastInput)) { + mount(nextInput, parentDom, lifecycle, context, instance, isSVG); + } else if (isInvalidNode(nextInput)) { + remove(lastInput, parentDom); + } else if (isStringOrNumber(lastInput)) { + if (isStringOrNumber(nextInput)) { + parentDom.firstChild.nodeValue = nextInput; + } else { + const dom = mount(nextInput, null, lifecycle, context, instance, isSVG); + + nextInput.dom = dom; + replaceNode(parentDom, dom, parentDom.firstChild); + } + } else if (isStringOrNumber(nextInput)) { + replaceNode(parentDom, document.createTextNode(nextInput), lastInput.dom); + } else { + if (isVList(nextInput)) { + if (isVList(lastInput)) { + patchVList(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG); + } else { + replaceNode(parentDom, mountVList(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); + unmount(lastInput, null); + } + } else if (isVList(lastInput)) { + replaceVListWithNode(parentDom, lastInput, mount(nextInput, null, lifecycle, context, instance, isSVG)); + } else if (isVPlaceholder(nextInput)) { + if (isVPlaceholder(lastInput)) { + patchVFragment(lastInput, nextInput); + } else { + replaceNode(parentDom, mountVPlaceholder(nextInput, null), lastInput.dom); + unmount(lastInput, null); + } + } else if (isVPlaceholder(lastInput)) { + replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); + } else if (isVText(nextInput)) { + if (isVText(lastInput)) { + patchVText(lastInput, nextInput); + } else { + replaceNode(parentDom, mountVText(nextInput, null), lastInput.dom); + unmount(lastInput, null); + } + } else if (isVText(lastInput)) { + replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); + } else if (isVNode(nextInput)) { + if (isVNode(lastInput)) { + patchVNode(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG, false); + } else { + replaceNode(parentDom, mountVNode(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); + unmount(lastInput, null); + } + } else if (isVNode(lastInput)) { + replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); + unmount(lastInput, null); + } else { + return patch(lastInput, normalise(nextInput), parentDom, lifecycle, context, instance, isSVG); + } + } + } + return nextInput; } export function patchTextNode(dom, lastChildren, nextChildren) { - if (isStringOrNumber(lastChildren)) { - dom.firstChild.nodeValue = nextChildren; - } else { - dom.textContent = nextChildren; - } + if (isStringOrNumber(lastChildren)) { + dom.firstChild.nodeValue = nextChildren; + } else { + dom.textContent = nextChildren; + } } function patchRef(instance, lastValue, nextValue, dom) { - if (instance) { - if (isString(lastValue)) { - delete instance.refs[lastValue]; - } - if (isString(nextValue)) { - instance.refs[nextValue] = dom; - } - } + if (instance) { + if (isString(lastValue)) { + delete instance.refs[lastValue]; + } + if (isString(nextValue)) { + instance.refs[nextValue] = dom; + } + } } function patchChildren(lastNode, nextNode, dom, lifecycle, context, instance, isSVG) { - const nextChildren = nextNode.children; - const lastChildren = lastNode.children; - - if (lastChildren === nextChildren) { - return; - } - if (isInvalidNode(lastChildren)) { - if (isStringOrNumber(nextChildren)) { - patchTextNode(dom, lastChildren, nextChildren); - } else if (!isInvalidNode(nextChildren)) { - if (isArray(nextChildren)) { - mountArrayChildren(nextChildren, dom, lifecycle, context, instance, isSVG); - } else { - mount(nextChildren, dom, lifecycle, context, instance, isSVG); - } - } - } else { - if (isInvalidNode(nextChildren)) { - removeAllChildren(dom, lastChildren); - } else { - if (isArray(lastChildren)) { - if (isArray(nextChildren)) { - nextChildren.complex = lastChildren.complex; - if (isKeyed(lastChildren, nextChildren)) { - patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, null); - } else { - patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, null); - } - } else { - patchNonKeyedChildren(lastChildren, [nextChildren], dom, lifecycle, context, instance, isSVG, null); - } - } else { - if (isArray(nextChildren)) { - let lastChild = lastChildren; - - if (isStringOrNumber(lastChildren)) { - lastChild = createVText(lastChild); - lastChild.dom = dom.firstChild; - } - patchNonKeyedChildren([lastChild], nextChildren, dom, lifecycle, context, instance, isSVG, null); - } else if (isStringOrNumber(nextChildren)) { - patchTextNode(dom, lastChildren, nextChildren); - } else if (isStringOrNumber(lastChildren)) { - patch(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG); - } else { - patchVNode(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, false); - } - } - } - } + const nextChildren = nextNode.children; + const lastChildren = lastNode.children; + + if (lastChildren === nextChildren) { + return; + } + if (isInvalidNode(lastChildren)) { + if (isStringOrNumber(nextChildren)) { + patchTextNode(dom, lastChildren, nextChildren); + } else if (!isInvalidNode(nextChildren)) { + if (isArray(nextChildren)) { + mountArrayChildren(nextChildren, dom, lifecycle, context, instance, isSVG); + } else { + mount(nextChildren, dom, lifecycle, context, instance, isSVG); + } + } + } else { + if (isInvalidNode(nextChildren)) { + removeAllChildren(dom, lastChildren); + } else { + if (isArray(lastChildren)) { + if (isArray(nextChildren)) { + nextChildren.complex = lastChildren.complex; + if (isKeyed(lastChildren, nextChildren)) { + patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, null); + } else { + patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, null); + } + } else { + patchNonKeyedChildren(lastChildren, [nextChildren], dom, lifecycle, context, instance, isSVG, null); + } + } else { + if (isArray(nextChildren)) { + let lastChild = lastChildren; + + if (isStringOrNumber(lastChildren)) { + lastChild = createVText(lastChild); + lastChild.dom = dom.firstChild; + } + patchNonKeyedChildren([lastChild], nextChildren, dom, lifecycle, context, instance, isSVG, null); + } else if (isStringOrNumber(nextChildren)) { + patchTextNode(dom, lastChildren, nextChildren); + } else if (isStringOrNumber(lastChildren)) { + patch(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG); + } else { + patchVNode(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, false); + } + } + } + } } export function patchVNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, isSVG, skipLazyCheck) { - const lastBp = lastVNode.bp; - const nextBp = nextVNode.bp; - - if (lastBp === undefined || nextBp === undefined) { - patchVNodeWithoutBlueprint(lastVNode, nextVNode, parentDom, lifecycle, context, instance, isSVG); - } else { - patchVNodeWithBlueprint(lastVNode, nextVNode, lastBp, nextBp, parentDom, lifecycle, context, instance, skipLazyCheck); - } + const lastBp = lastVNode.bp; + const nextBp = nextVNode.bp; + + if (lastBp === undefined || nextBp === undefined) { + patchVNodeWithoutBlueprint(lastVNode, nextVNode, parentDom, lifecycle, context, instance, isSVG); + } else { + patchVNodeWithBlueprint(lastVNode, nextVNode, lastBp, nextBp, parentDom, lifecycle, context, instance, skipLazyCheck); + } } export function patchVNodeWithBlueprint(lastVNode, nextVNode, lastBp, nextBp, parentDom, lifecycle, context, instance, skipLazyCheck) { - let nextHooks; - - if (nextBp.hasHooks === true) { - nextHooks = nextVNode.hooks; - if (nextHooks && !isNullOrUndefined(nextHooks.willUpdate)) { - nextHooks.willUpdate(lastVNode.dom); - } - } - const nextTag = nextVNode.tag || nextBp.tag; - const lastTag = lastVNode.tag || lastBp.tag; - - if (lastTag !== nextTag) { - if (lastBp && lastBp.isComponent === true) { - const lastNodeInstance = lastVNode.instance; - - if (nextBp.isComponent === true) { - replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, false); - } else if (isStatefulComponent(lastTag)) { - unmountVNode(lastVNode, null, true); - const lastNode = lastNodeInstance._lastNode; - patchVNodeWithBlueprint(lastNode, nextVNode, lastNode.bp, nextBp, parentDom, lifecycle, context, instance, nextBp.isSVG); - } else { - unmountVNode(lastVNode, null, true); - patchVNodeWithBlueprint(lastNodeInstance, nextVNode, lastNodeInstance.bp, nextBp, parentDom, lifecycle, context, instance, nextBp.isSVG); - } - } else { - replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, nextBp.isSVG); - } - } else if (isNullOrUndefined(lastTag)) { - nextVNode.dom = lastVNode.dom; - } else { - if (lastBp && lastBp.isComponent === true) { - if (nextBp.isComponent === true) { - const instance = lastVNode.instance; - - if (!isNullOrUndefined(instance) && instance._unmounted) { - const newDom = mountComponent(nextVNode, lastTag, nextVNode.attrs || {}, nextVNode.hooks, nextVNode.children, instance, parentDom, lifecycle, context); - if (parentDom !== null) { - replaceNode(parentDom, newDom, lastVNode.dom); - } - } else { - nextVNode.instance = instance; - nextVNode.dom = lastVNode.dom; - patchComponent(true, nextVNode, nextVNode.tag, lastBp, nextBp, instance, lastVNode.attrs || {}, nextVNode.attrs || {}, nextVNode.hooks, lastVNode.children, nextVNode.children, parentDom, lifecycle, context); - } - } - } else { - const dom = lastVNode.dom; - const lastChildrenType = lastBp.childrenType; - const nextChildrenType = nextBp.childrenType; - nextVNode.dom = dom; - - if (nextBp.lazy === true && skipLazyCheck === false) { - const clipData = lastVNode.clipData; - - if (lifecycle.scrollY === null) { - lifecycle.refresh(); - } - - nextVNode.clipData = clipData; - if (clipData.pending === true || clipData.top - lifecycle.scrollY > lifecycle.screenHeight) { - if (setClipNode(clipData, dom, lastVNode, nextVNode, parentDom, lifecycle, context, instance, lastBp.isSVG)) { - return; - } - } - if (clipData.bottom < lifecycle.scrollY) { - if (setClipNode(clipData, dom, lastVNode, nextVNode, parentDom, lifecycle, context, instance, lastBp.isSVG)) { - return; - } - } - } - - if (lastChildrenType > 0 || nextChildrenType > 0) { - if (nextChildrenType === 5 || lastChildrenType === 5) { - patchChildren(lastVNode, nextVNode, dom, lifecycle, context, instance); - } else { - const lastChildren = lastVNode.children; - const nextChildren = nextVNode.children; - - if (lastChildrenType === 0 || isInvalidNode(lastChildren)) { - if (nextChildrenType > 2) { - mountArrayChildren(nextChildren, dom, lifecycle, context, instance); - } else { - mount(nextChildren, dom, lifecycle, context, instance); - } - } else if (nextChildrenType === 0 || isInvalidNode(nextChildren)) { - if (lastChildrenType > 2) { - removeAllChildren(dom, lastChildren); - } else { - remove(lastChildren, dom); - } - } else { - if (lastChildren !== nextChildren) { - if (lastChildrenType === 4 && nextChildrenType === 4) { - patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, nextBp.isSVG, null); - } else if (lastChildrenType === 2 && nextChildrenType === 2) { - patch(lastChildren, nextChildren, dom, lifecycle, context, instance, true, nextBp.isSVG); - } else if (lastChildrenType === 1 && nextChildrenType === 1) { - patchTextNode(dom, lastChildren, nextChildren); - } else { - patchChildren(lastVNode, nextVNode, dom, lifecycle, context, instance, nextBp.isSVG); - } - } - } - } - } - if (lastBp.hasAttrs === true || nextBp.hasAttrs === true) { - patchAttributes(lastVNode, nextVNode, lastBp.attrKeys, nextBp.attrKeys, dom, instance); - } - if (lastBp.hasEvents === true || nextBp.hasEvents === true) { - patchEvents(lastVNode.events, nextVNode.events, lastBp.eventKeys, nextBp.eventKeys, dom); - } - if (lastBp.hasClassName === true || nextBp.hasClassName === true) { - const nextClassName = nextVNode.className; - - if (lastVNode.className !== nextClassName) { - if (isNullOrUndefined(nextClassName)) { - dom.removeAttribute('class'); - } else { - dom.className = nextClassName; - } - } - } - if (lastBp.hasStyle === true || nextBp.hasStyle === true) { - const nextStyle = nextVNode.style; - const lastStyle = lastVNode.style; - - if (lastStyle !== nextStyle) { - patchStyle(lastStyle, nextStyle, dom); - } - } - if (nextBp.hasHooks === true && !isNullOrUndefined(nextHooks.didUpdate)) { - nextHooks.didUpdate(dom); - } - setFormElementProperties(nextTag, nextVNode); - } - } + let nextHooks; + + if (nextBp.hasHooks === true) { + nextHooks = nextVNode.hooks; + if (nextHooks && !isNullOrUndefined(nextHooks.willUpdate)) { + nextHooks.willUpdate(lastVNode.dom); + } + } + const nextTag = nextVNode.tag || nextBp.tag; + const lastTag = lastVNode.tag || lastBp.tag; + + if (lastTag !== nextTag) { + if (lastBp && lastBp.isComponent === true) { + const lastNodeInstance = lastVNode.instance; + + if (nextBp.isComponent === true) { + replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, false); + } else if (isStatefulComponent(lastTag)) { + unmountVNode(lastVNode, null, true); + const lastNode = lastNodeInstance._lastNode; + patchVNodeWithBlueprint(lastNode, nextVNode, lastNode.bp, nextBp, parentDom, lifecycle, context, instance, nextBp.isSVG); + } else { + unmountVNode(lastVNode, null, true); + patchVNodeWithBlueprint(lastNodeInstance, nextVNode, lastNodeInstance.bp, nextBp, parentDom, lifecycle, context, instance, nextBp.isSVG); + } + } else { + replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, nextBp.isSVG); + } + } else if (isNullOrUndefined(lastTag)) { + nextVNode.dom = lastVNode.dom; + } else { + if (lastBp && lastBp.isComponent === true) { + if (nextBp.isComponent === true) { + const instance = lastVNode.instance; + + if (!isNullOrUndefined(instance) && instance._unmounted) { + const newDom = mountComponent(nextVNode, lastTag, nextVNode.attrs || {}, nextVNode.hooks, nextVNode.children, instance, parentDom, lifecycle, context); + if (parentDom !== null) { + replaceNode(parentDom, newDom, lastVNode.dom); + } + } else { + nextVNode.instance = instance; + nextVNode.dom = lastVNode.dom; + patchComponent(true, nextVNode, nextVNode.tag, lastBp, nextBp, instance, lastVNode.attrs || {}, nextVNode.attrs || {}, nextVNode.hooks, lastVNode.children, nextVNode.children, parentDom, lifecycle, context); + } + } + } else { + const dom = lastVNode.dom; + const lastChildrenType = lastBp.childrenType; + const nextChildrenType = nextBp.childrenType; + nextVNode.dom = dom; + + if (nextBp.lazy === true && skipLazyCheck === false) { + const clipData = lastVNode.clipData; + + if (lifecycle.scrollY === null) { + lifecycle.refresh(); + } + + nextVNode.clipData = clipData; + if (clipData.pending === true || clipData.top - lifecycle.scrollY > lifecycle.screenHeight) { + if (setClipNode(clipData, dom, lastVNode, nextVNode, parentDom, lifecycle, context, instance, lastBp.isSVG)) { + return; + } + } + if (clipData.bottom < lifecycle.scrollY) { + if (setClipNode(clipData, dom, lastVNode, nextVNode, parentDom, lifecycle, context, instance, lastBp.isSVG)) { + return; + } + } + } + + if (lastChildrenType > 0 || nextChildrenType > 0) { + if (nextChildrenType === 5 || lastChildrenType === 5) { + patchChildren(lastVNode, nextVNode, dom, lifecycle, context, instance); + } else { + const lastChildren = lastVNode.children; + const nextChildren = nextVNode.children; + + if (lastChildrenType === 0 || isInvalidNode(lastChildren)) { + if (nextChildrenType > 2) { + mountArrayChildren(nextChildren, dom, lifecycle, context, instance); + } else { + mount(nextChildren, dom, lifecycle, context, instance); + } + } else if (nextChildrenType === 0 || isInvalidNode(nextChildren)) { + if (lastChildrenType > 2) { + removeAllChildren(dom, lastChildren); + } else { + remove(lastChildren, dom); + } + } else { + if (lastChildren !== nextChildren) { + if (lastChildrenType === 4 && nextChildrenType === 4) { + patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, nextBp.isSVG, null); + } else if (lastChildrenType === 2 && nextChildrenType === 2) { + patch(lastChildren, nextChildren, dom, lifecycle, context, instance, true, nextBp.isSVG); + } else if (lastChildrenType === 1 && nextChildrenType === 1) { + patchTextNode(dom, lastChildren, nextChildren); + } else { + patchChildren(lastVNode, nextVNode, dom, lifecycle, context, instance, nextBp.isSVG); + } + } + } + } + } + if (lastBp.hasAttrs === true || nextBp.hasAttrs === true) { + patchAttributes(lastVNode, nextVNode, lastBp.attrKeys, nextBp.attrKeys, dom, instance); + } + if (lastBp.hasEvents === true || nextBp.hasEvents === true) { + patchEvents(lastVNode.events, nextVNode.events, lastBp.eventKeys, nextBp.eventKeys, dom); + } + if (lastBp.hasClassName === true || nextBp.hasClassName === true) { + const nextClassName = nextVNode.className; + + if (lastVNode.className !== nextClassName) { + if (isNullOrUndefined(nextClassName)) { + dom.removeAttribute('class'); + } else { + dom.className = nextClassName; + } + } + } + if (lastBp.hasStyle === true || nextBp.hasStyle === true) { + const nextStyle = nextVNode.style; + const lastStyle = lastVNode.style; + + if (lastStyle !== nextStyle) { + patchStyle(lastStyle, nextStyle, dom); + } + } + if (nextBp.hasHooks === true && !isNullOrUndefined(nextHooks.didUpdate)) { + nextHooks.didUpdate(dom); + } + setFormElementProperties(nextTag, nextVNode); + } + } } export function patchVNodeWithoutBlueprint(lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG) { - const nextHooks = nextNode.hooks; - const nextHooksDefined = !isNullOrUndefined(nextHooks); - - if (nextHooksDefined && !isNullOrUndefined(nextHooks.willUpdate)) { - nextHooks.willUpdate(lastNode.dom); - } - const nextTag = nextNode.tag || ((isNullOrUndefined(nextNode.bp)) ? null : nextNode.bp.tag); - const lastTag = lastNode.tag || ((isNullOrUndefined(lastNode.bp)) ? null : lastNode.bp.tag); - - if (nextTag === 'svg') { - isSVG = true; - } - if (lastTag !== nextTag) { - const lastNodeInstance = lastNode.instance; - - if (isFunction(lastTag)) { - if (isFunction(nextTag)) { - replaceWithNewNode(lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); - } else if (isStatefulComponent(lastTag)) { - unmountVNode(lastNode, null, true); - patchVNodeWithoutBlueprint(lastNodeInstance._lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); - } else { - unmountVNode(lastNode, null, true); - patchVNodeWithoutBlueprint(lastNodeInstance, nextNode, parentDom, lifecycle, context, instance, isSVG); - } - } else { - replaceWithNewNode(lastNodeInstance || lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); - } - } else if (isNullOrUndefined(lastTag)) { - nextNode.dom = lastNode.dom; - } else { - if (isFunction(lastTag)) { - if (isFunction(nextTag)) { - const instance = lastNode._instance; - - if (!isNullOrUndefined(instance) && instance._unmounted) { - const newDom = mountComponent(nextNode, lastTag, nextNode.attrs || {}, nextNode.hooks, nextNode.children, instance, parentDom, lifecycle, context); - if (parentDom !== null) { - replaceNode(parentDom, newDom, lastNode.dom); - } - } else { - nextNode.instance = lastNode.instance; - nextNode.dom = lastNode.dom; - patchComponent(false, nextNode, nextNode.tag, null, null, nextNode.instance, lastNode.attrs || {}, nextNode.attrs || {}, nextNode.hooks, lastNode.children, nextNode.children, parentDom, lifecycle, context); - } - } - } else { - const dom = lastNode.dom; - const nextClassName = nextNode.className; - const nextStyle = nextNode.style; - - nextNode.dom = dom; - - patchChildren(lastNode, nextNode, dom, lifecycle, context, instance, isSVG); - patchAttributes(lastNode, nextNode, null, null, dom, instance); - patchEvents(lastNode.events, nextNode.events, null, null, dom); - - if (lastNode.className !== nextClassName) { - if (isNullOrUndefined(nextClassName)) { - dom.removeAttribute('class'); - } else { - dom.className = nextClassName; - } - } - if (lastNode.style !== nextStyle) { - patchStyle(lastNode.style, nextStyle, dom); - } - if (nextHooksDefined && !isNullOrUndefined(nextHooks.didUpdate)) { - nextHooks.didUpdate(dom); - } - setFormElementProperties(nextTag, nextNode); - } - } + const nextHooks = nextNode.hooks; + const nextHooksDefined = !isNullOrUndefined(nextHooks); + + if (nextHooksDefined && !isNullOrUndefined(nextHooks.willUpdate)) { + nextHooks.willUpdate(lastNode.dom); + } + const nextTag = nextNode.tag || ((isNullOrUndefined(nextNode.bp)) ? null : nextNode.bp.tag); + const lastTag = lastNode.tag || ((isNullOrUndefined(lastNode.bp)) ? null : lastNode.bp.tag); + + if (nextTag === 'svg') { + isSVG = true; + } + if (lastTag !== nextTag) { + const lastNodeInstance = lastNode.instance; + + if (isFunction(lastTag)) { + if (isFunction(nextTag)) { + replaceWithNewNode(lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); + } else if (isStatefulComponent(lastTag)) { + unmountVNode(lastNode, null, true); + patchVNodeWithoutBlueprint(lastNodeInstance._lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); + } else { + unmountVNode(lastNode, null, true); + patchVNodeWithoutBlueprint(lastNodeInstance, nextNode, parentDom, lifecycle, context, instance, isSVG); + } + } else { + replaceWithNewNode(lastNodeInstance || lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); + } + } else if (isNullOrUndefined(lastTag)) { + nextNode.dom = lastNode.dom; + } else { + if (isFunction(lastTag)) { + if (isFunction(nextTag)) { + const instance = lastNode._instance; + + if (!isNullOrUndefined(instance) && instance._unmounted) { + const newDom = mountComponent(nextNode, lastTag, nextNode.attrs || {}, nextNode.hooks, nextNode.children, instance, parentDom, lifecycle, context); + if (parentDom !== null) { + replaceNode(parentDom, newDom, lastNode.dom); + } + } else { + nextNode.instance = lastNode.instance; + nextNode.dom = lastNode.dom; + patchComponent(false, nextNode, nextNode.tag, null, null, nextNode.instance, lastNode.attrs || {}, nextNode.attrs || {}, nextNode.hooks, lastNode.children, nextNode.children, parentDom, lifecycle, context); + } + } + } else { + const dom = lastNode.dom; + const nextClassName = nextNode.className; + const nextStyle = nextNode.style; + + nextNode.dom = dom; + + patchChildren(lastNode, nextNode, dom, lifecycle, context, instance, isSVG); + patchAttributes(lastNode, nextNode, null, null, dom, instance); + patchEvents(lastNode.events, nextNode.events, null, null, dom); + + if (lastNode.className !== nextClassName) { + if (isNullOrUndefined(nextClassName)) { + dom.removeAttribute('class'); + } else { + dom.className = nextClassName; + } + } + if (lastNode.style !== nextStyle) { + patchStyle(lastNode.style, nextStyle, dom); + } + if (nextHooksDefined && !isNullOrUndefined(nextHooks.didUpdate)) { + nextHooks.didUpdate(dom); + } + setFormElementProperties(nextTag, nextNode); + } + } } function patchAttributes(lastNode, nextNode, lastAttrKeys, nextAttrKeys, dom, instance) { - if (lastNode.tag === 'select') { - selectValue(nextNode); - } - const nextAttrs = nextNode.attrs; - const lastAttrs = lastNode.attrs; - const nextAttrsIsUndef = isNullOrUndefined(nextAttrs); - const lastAttrsIsNotUndef = !isNullOrUndefined(lastAttrs); - - if (!nextAttrsIsUndef) { - const nextAttrsKeys = nextAttrKeys || Object.keys(nextAttrs); - const attrKeysLength = nextAttrsKeys.length; - - for (let i = 0; i < attrKeysLength; i++) { - const attr = nextAttrsKeys[i]; - const lastAttrVal = lastAttrsIsNotUndef && lastAttrs[attr]; - const nextAttrVal = nextAttrs[attr]; - - if (lastAttrVal !== nextAttrVal) { - if (attr === 'ref') { - patchRef(instance, lastAttrVal, nextAttrVal, dom); - } else { - patchAttribute(attr, lastAttrVal, nextAttrVal, dom); - } - } - } - } - if (lastAttrsIsNotUndef) { - const lastAttrsKeys = lastAttrKeys || Object.keys(lastAttrs); - const attrKeysLength = lastAttrsKeys.length; - - for (let i = 0; i < attrKeysLength; i++) { - const attr = lastAttrsKeys[i]; - - if (nextAttrsIsUndef || isNullOrUndefined(nextAttrs[attr])) { - if (attr === 'ref') { - patchRef(getRefInstance(node, instance), lastAttrs[attr], null, dom); - } else { - dom.removeAttribute(attr); - } - } - } - } + if (lastNode.tag === 'select') { + selectValue(nextNode); + } + const nextAttrs = nextNode.attrs; + const lastAttrs = lastNode.attrs; + const nextAttrsIsUndef = isNullOrUndefined(nextAttrs); + const lastAttrsIsNotUndef = !isNullOrUndefined(lastAttrs); + + if (!nextAttrsIsUndef) { + const nextAttrsKeys = nextAttrKeys || Object.keys(nextAttrs); + const attrKeysLength = nextAttrsKeys.length; + + for (let i = 0; i < attrKeysLength; i++) { + const attr = nextAttrsKeys[i]; + const lastAttrVal = lastAttrsIsNotUndef && lastAttrs[attr]; + const nextAttrVal = nextAttrs[attr]; + + if (lastAttrVal !== nextAttrVal) { + if (attr === 'ref') { + patchRef(instance, lastAttrVal, nextAttrVal, dom); + } else { + patchAttribute(attr, lastAttrVal, nextAttrVal, dom); + } + } + } + } + if (lastAttrsIsNotUndef) { + const lastAttrsKeys = lastAttrKeys || Object.keys(lastAttrs); + const attrKeysLength = lastAttrsKeys.length; + + for (let i = 0; i < attrKeysLength; i++) { + const attr = lastAttrsKeys[i]; + + if (nextAttrsIsUndef || isNullOrUndefined(nextAttrs[attr])) { + if (attr === 'ref') { + patchRef(getRefInstance(node, instance), lastAttrs[attr], null, dom); + } else { + dom.removeAttribute(attr); + } + } + } + } } export function patchStyle(lastAttrValue, nextAttrValue, dom) { - if (isString(nextAttrValue)) { - dom.style.cssText = nextAttrValue; - } else if (isNullOrUndefined(lastAttrValue)) { - if (!isNullOrUndefined(nextAttrValue)) { - const styleKeys = Object.keys(nextAttrValue); - - for (let i = 0; i < styleKeys.length; i++) { - const style = styleKeys[i]; - const value = nextAttrValue[style]; - - if (isNumber(value) && !isUnitlessNumber[style]) { - dom.style[style] = value + 'px'; - } else { - dom.style[style] = value; - } - } - } - } else if (isNullOrUndefined(nextAttrValue)) { - dom.removeAttribute('style'); - } else { - const styleKeys = Object.keys(nextAttrValue); - - for (let i = 0; i < styleKeys.length; i++) { - const style = styleKeys[i]; - const value = nextAttrValue[style]; - - if (isNumber(value) && !isUnitlessNumber[style]) { - dom.style[style] = value + 'px'; - } else { - dom.style[style] = value; - } - } - const lastStyleKeys = Object.keys(lastAttrValue); - - for (let i = 0; i < lastStyleKeys.length; i++) { - const style = lastStyleKeys[i]; - if (isNullOrUndefined(nextAttrValue[style])) { - dom.style[style] = ''; - } - } - } + if (isString(nextAttrValue)) { + dom.style.cssText = nextAttrValue; + } else if (isNullOrUndefined(lastAttrValue)) { + if (!isNullOrUndefined(nextAttrValue)) { + const styleKeys = Object.keys(nextAttrValue); + + for (let i = 0; i < styleKeys.length; i++) { + const style = styleKeys[i]; + const value = nextAttrValue[style]; + + if (isNumber(value) && !isUnitlessNumber[style]) { + dom.style[style] = value + 'px'; + } else { + dom.style[style] = value; + } + } + } + } else if (isNullOrUndefined(nextAttrValue)) { + dom.removeAttribute('style'); + } else { + const styleKeys = Object.keys(nextAttrValue); + + for (let i = 0; i < styleKeys.length; i++) { + const style = styleKeys[i]; + const value = nextAttrValue[style]; + + if (isNumber(value) && !isUnitlessNumber[style]) { + dom.style[style] = value + 'px'; + } else { + dom.style[style] = value; + } + } + const lastStyleKeys = Object.keys(lastAttrValue); + + for (let i = 0; i < lastStyleKeys.length; i++) { + const style = lastStyleKeys[i]; + if (isNullOrUndefined(nextAttrValue[style])) { + dom.style[style] = ''; + } + } + } } export function patchEvents(lastEvents, nextEvents, _lastEventKeys, _nextEventKeys, dom) { - const nextEventsDefined = !isNullOrUndefined(nextEvents); - const lastEventsDefined = !isNullOrUndefined(lastEvents); - let lastEventKeys; - - if (lastEventsDefined) { - lastEventKeys = _lastEventKeys || Object.keys(lastEvents); - } - if (nextEventsDefined) { - const nextEventKeys = _nextEventKeys || Object.keys(nextEvents); - - if (lastEventsDefined) { - for (let i = 0; i < nextEventKeys.length; i++) { - const event = nextEventKeys[i]; - const lastEvent = lastEvents[event]; - const nextEvent = nextEvents[event]; - - if (lastEvent !== nextEvent) { - dom[event] = nextEvent; - } - } - for (let i = 0; i < lastEventKeys.length; i++) { - const event = lastEventKeys[i]; - - if (isNullOrUndefined(nextEvents[event])) { - dom[event] = null; - } - } - } else { - mountEvents(nextEvents, nextEventKeys, dom); - } - } else if (lastEventsDefined) { - removeEvents(lastEvents, lastEventKeys, dom); - } + const nextEventsDefined = !isNullOrUndefined(nextEvents); + const lastEventsDefined = !isNullOrUndefined(lastEvents); + let lastEventKeys; + + if (lastEventsDefined) { + lastEventKeys = _lastEventKeys || Object.keys(lastEvents); + } + if (nextEventsDefined) { + const nextEventKeys = _nextEventKeys || Object.keys(nextEvents); + + if (lastEventsDefined) { + for (let i = 0; i < nextEventKeys.length; i++) { + const event = nextEventKeys[i]; + const lastEvent = lastEvents[event]; + const nextEvent = nextEvents[event]; + + if (lastEvent !== nextEvent) { + dom[event] = nextEvent; + } + } + for (let i = 0; i < lastEventKeys.length; i++) { + const event = lastEventKeys[i]; + + if (isNullOrUndefined(nextEvents[event])) { + dom[event] = null; + } + } + } else { + mountEvents(nextEvents, nextEventKeys, dom); + } + } else if (lastEventsDefined) { + removeEvents(lastEvents, lastEventKeys, dom); + } } export function patchAttribute(attrName, lastAttrValue, nextAttrValue, dom) { - if (attrName === 'dangerouslySetInnerHTML') { - const lastHtml = lastAttrValue && lastAttrValue.__html; - const nextHtml = nextAttrValue && nextAttrValue.__html; - - if (isNullOrUndefined(nextHtml)) { - throw new Error('Inferno Error: dangerouslySetInnerHTML requires an object with a __html propety containing the innerHTML content'); - } - if (lastHtml !== nextHtml) { - dom.innerHTML = nextHtml; - } - } else if (attrName === 'eventData') { - dom.eventData = nextAttrValue; - } else if (strictProps[attrName]) { - dom[attrName] = nextAttrValue === null ? '' : nextAttrValue; - } else { - if (booleanProps[attrName]) { - dom[attrName] = nextAttrValue ? true : false; - } else { - const ns = namespaces[attrName]; - - if (nextAttrValue === false || isNullOrUndefined(nextAttrValue)) { - if (ns !== undefined) { - dom.removeAttributeNS(ns, attrName); - } else { - dom.removeAttribute(attrName); - } - } else { - if (ns !== undefined) { - dom.setAttributeNS(ns, attrName, nextAttrValue === true ? attrName : nextAttrValue); - } else { - dom.setAttribute(attrName, nextAttrValue === true ? attrName : nextAttrValue); - } - } - } - } + if (attrName === 'dangerouslySetInnerHTML') { + const lastHtml = lastAttrValue && lastAttrValue.__html; + const nextHtml = nextAttrValue && nextAttrValue.__html; + + if (isNullOrUndefined(nextHtml)) { + throw new Error('Inferno Error: dangerouslySetInnerHTML requires an object with a __html propety containing the innerHTML content'); + } + if (lastHtml !== nextHtml) { + dom.innerHTML = nextHtml; + } + } else if (attrName === 'eventData') { + dom.eventData = nextAttrValue; + } else if (strictProps[attrName]) { + dom[attrName] = nextAttrValue === null ? '' : nextAttrValue; + } else { + if (booleanProps[attrName]) { + dom[attrName] = nextAttrValue ? true : false; + } else { + const ns = namespaces[attrName]; + + if (nextAttrValue === false || isNullOrUndefined(nextAttrValue)) { + if (ns !== undefined) { + dom.removeAttributeNS(ns, attrName); + } else { + dom.removeAttribute(attrName); + } + } else { + if (ns !== undefined) { + dom.setAttributeNS(ns, attrName, nextAttrValue === true ? attrName : nextAttrValue); + } else { + dom.setAttribute(attrName, nextAttrValue === true ? attrName : nextAttrValue); + } + } + } + } } export function patchComponent(hasBlueprint, lastNode, Component, lastBp, nextBp, instance, lastProps, nextProps, nextHooks, lastChildren, nextChildren, parentDom, lifecycle, context) { - nextProps = addChildrenToProps(nextChildren, nextProps); - - if (isStatefulComponent(Component)) { - const prevProps = instance.props; - const prevState = instance.state; - const nextState = instance.state; - - const childContext = instance.getChildContext(); - if (!isNullOrUndefined(childContext)) { - context = Object.assign({}, context, childContext); - } - instance.context = context; - let nextNode = instance._updateComponent(prevState, nextState, prevProps, nextProps); - - if (nextNode === NO_RENDER) { - nextNode = instance._lastNode; - } else if (isNullOrUndefined(nextNode)) { - nextNode = createVPlaceholder(); - } - patch(instance._lastNode, nextNode, parentDom, lifecycle, context, instance, null, false); - lastNode.dom = nextNode.dom; - instance._lastNode = nextNode; - instance.componentDidUpdate(prevProps, prevState); - componentToDOMNodeMap.set(instance, nextNode.dom); - } else { - let shouldUpdate = true; - const nextHooksDefined = (hasBlueprint && nextBp.hasHooks === true) || !isNullOrUndefined(nextHooks); - - lastProps = addChildrenToProps(lastChildren, lastProps); - if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentShouldUpdate)) { - shouldUpdate = nextHooks.componentShouldUpdate(lastNode.dom, lastProps, nextProps); - } - if (shouldUpdate !== false) { - if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentWillUpdate)) { - nextHooks.componentWillUpdate(lastNode.dom, lastProps, nextProps); - } - let nextNode = Component(nextProps, context); - - if (isInvalidNode(nextNode)) { - nextNode = createVPlaceholder(); - } - nextNode.dom = lastNode.dom; - patch(instance, nextNode, parentDom, lifecycle, context, null, null, false); - lastNode.instance = nextNode; - if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentDidUpdate)) { - nextHooks.componentDidUpdate(lastNode.dom, lastProps, nextProps); - } - } - } + nextProps = addChildrenToProps(nextChildren, nextProps); + + if (isStatefulComponent(Component)) { + const prevProps = instance.props; + const prevState = instance.state; + const nextState = instance.state; + + const childContext = instance.getChildContext(); + if (!isNullOrUndefined(childContext)) { + context = Object.assign({}, context, childContext); + } + instance.context = context; + let nextNode = instance._updateComponent(prevState, nextState, prevProps, nextProps); + + if (nextNode === NO_RENDER) { + nextNode = instance._lastNode; + } else if (isNullOrUndefined(nextNode)) { + nextNode = createVPlaceholder(); + } + patch(instance._lastNode, nextNode, parentDom, lifecycle, context, instance, null, false); + lastNode.dom = nextNode.dom; + instance._lastNode = nextNode; + instance.componentDidUpdate(prevProps, prevState); + componentToDOMNodeMap.set(instance, nextNode.dom); + } else { + let shouldUpdate = true; + const nextHooksDefined = (hasBlueprint && nextBp.hasHooks === true) || !isNullOrUndefined(nextHooks); + + lastProps = addChildrenToProps(lastChildren, lastProps); + if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentShouldUpdate)) { + shouldUpdate = nextHooks.componentShouldUpdate(lastNode.dom, lastProps, nextProps); + } + if (shouldUpdate !== false) { + if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentWillUpdate)) { + nextHooks.componentWillUpdate(lastNode.dom, lastProps, nextProps); + } + let nextNode = Component(nextProps, context); + + if (isInvalidNode(nextNode)) { + nextNode = createVPlaceholder(); + } + nextNode.dom = lastNode.dom; + patch(instance, nextNode, parentDom, lifecycle, context, null, null, false); + lastNode.instance = nextNode; + if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentDidUpdate)) { + nextHooks.componentDidUpdate(lastNode.dom, lastProps, nextProps); + } + } + } } function patchVList(lastVList, nextVList, parentDom, lifecycle, context, instance, isSVG) { - const lastItems = lastVList.items; - const nextItems = nextVList.items; - const pointer = lastVList.pointer; - - nextVList.dom = lastVList.dom; - nextVList.pointer = pointer; - if (!lastItems !== nextItems) { - if (isKeyed(lastItems, nextItems)) { - patchKeyedChildren(lastItems, nextItems, parentDom, lifecycle, context, instance, isSVG, nextVList); - } else { - patchNonKeyedChildren(lastItems, nextItems, parentDom, lifecycle, context, instance, isSVG, nextVList); - } - } + const lastItems = lastVList.items; + const nextItems = nextVList.items; + const pointer = lastVList.pointer; + + nextVList.dom = lastVList.dom; + nextVList.pointer = pointer; + if (!lastItems !== nextItems) { + if (isKeyed(lastItems, nextItems)) { + patchKeyedChildren(lastItems, nextItems, parentDom, lifecycle, context, instance, isSVG, nextVList); + } else { + patchNonKeyedChildren(lastItems, nextItems, parentDom, lifecycle, context, instance, isSVG, nextVList); + } + } } export function patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, parentVList) { - let lastChildrenLength = lastChildren.length; - let nextChildrenLength = nextChildren.length; - let commonLength = lastChildrenLength > nextChildrenLength ? nextChildrenLength : lastChildrenLength; - let i = 0; - - for (; i < commonLength; i++) { - const lastChild = lastChildren[i]; - const nextChild = normaliseChild(nextChildren, i); - - patch(lastChild, nextChild, dom, lifecycle, context, instance, isSVG); - } - if (lastChildrenLength < nextChildrenLength) { - for (i = commonLength; i < nextChildrenLength; i++) { - const child = normaliseChild(nextChildren, i); - - insertOrAppend(dom, mount(child, null, lifecycle, context, instance, isSVG), parentVList && parentVList.pointer); - } - } else if (lastChildrenLength > nextChildrenLength) { - for (i = commonLength; i < lastChildrenLength; i++) { - remove(lastChildren[i], dom); - } - } + let lastChildrenLength = lastChildren.length; + let nextChildrenLength = nextChildren.length; + let commonLength = lastChildrenLength > nextChildrenLength ? nextChildrenLength : lastChildrenLength; + let i = 0; + + for (; i < commonLength; i++) { + const lastChild = lastChildren[i]; + const nextChild = normaliseChild(nextChildren, i); + + patch(lastChild, nextChild, dom, lifecycle, context, instance, isSVG); + } + if (lastChildrenLength < nextChildrenLength) { + for (i = commonLength; i < nextChildrenLength; i++) { + const child = normaliseChild(nextChildren, i); + + insertOrAppend(dom, mount(child, null, lifecycle, context, instance, isSVG), parentVList && parentVList.pointer); + } + } else if (lastChildrenLength > nextChildrenLength) { + for (i = commonLength; i < lastChildrenLength; i++) { + remove(lastChildren[i], dom); + } + } } export function patchVFragment(lastVFragment, nextVFragment) { - nextVFragment.dom = lastVFragment.dom; + nextVFragment.dom = lastVFragment.dom; } export function patchVText(lastVText, nextVText) { - const nextText = nextVText.text; - const dom = lastVText.dom; + const nextText = nextVText.text; + const dom = lastVText.dom; - nextVText.dom = dom; - if (lastVText.text !== nextText) { - dom.nodeValue = nextText; - } + nextVText.dom = dom; + if (lastVText.text !== nextText) { + dom.nodeValue = nextText; + } } export function patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, parentVList) { - let lastChildrenLength = lastChildren.length; - let nextChildrenLength = nextChildren.length; - let lastEndIndex = lastChildrenLength - 1; - let nextEndIndex = nextChildrenLength - 1; - let lastStartIndex = 0; - let nextStartIndex = 0; - let lastStartNode = null; - let nextStartNode = null; - let nextEndNode = null; - let lastEndNode = null; - let nextNode; - - while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { - nextStartNode = nextChildren[nextStartIndex]; - lastStartNode = lastChildren[lastStartIndex]; - - if (nextStartNode.key !== lastStartNode.key) { - break; - } - patchVNode(lastStartNode, nextStartNode, dom, lifecycle, context, instance, isSVG, false); - nextStartIndex++; - lastStartIndex++; - } - while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { - nextEndNode = nextChildren[nextEndIndex]; - lastEndNode = lastChildren[lastEndIndex]; - - if (nextEndNode.key !== lastEndNode.key) { - break; - } - patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); - nextEndIndex--; - lastEndIndex--; - } - while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { - nextEndNode = nextChildren[nextEndIndex]; - lastStartNode = lastChildren[lastStartIndex]; - - if (nextEndNode.key !== lastStartNode.key) { - break; - } - nextNode = (nextEndIndex + 1 < nextChildrenLength) ? nextChildren[nextEndIndex + 1].dom : null; - patchVNode(lastStartNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); - insertOrAppend(dom, nextEndNode.dom, nextNode); - nextEndIndex--; - lastStartIndex++; - } - while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { - nextStartNode = nextChildren[nextStartIndex]; - lastEndNode = lastChildren[lastEndIndex]; - - if (nextStartNode.key !== lastEndNode.key) { - break; - } - nextNode = lastChildren[lastStartIndex].dom; - patchVNode(lastEndNode, nextStartNode, dom, lifecycle, context, instance, isSVG, false); - insertOrAppend(dom, nextStartNode.dom, nextNode); - nextStartIndex++; - lastEndIndex--; - } - - if (lastStartIndex > lastEndIndex) { - if (nextStartIndex <= nextEndIndex) { - nextNode = (nextEndIndex + 1 < nextChildrenLength) ? nextChildren[nextEndIndex + 1].dom : parentVList && parentVList.pointer; - for (; nextStartIndex <= nextEndIndex; nextStartIndex++) { - insertOrAppend(dom, mount(nextChildren[nextStartIndex], null, lifecycle, context, instance, isSVG), nextNode); - } - } - } else if (nextStartIndex > nextEndIndex) { - while (lastStartIndex <= lastEndIndex) { - remove(lastChildren[lastStartIndex++], dom); - } - } else { - let aLength = lastEndIndex - lastStartIndex + 1; - let bLength = nextEndIndex - nextStartIndex + 1; - const sources = new Array(bLength); - - // Mark all nodes as inserted. - let i; - for (i = 0; i < bLength; i++) { - sources[i] = -1; - } - let moved = false; - let removeOffset = 0; - let lastTarget = 0; - let index; - let removed = true; - let k = 0; - - if ((bLength <= 4) || (aLength * bLength <= 16)) { - for (i = lastStartIndex; i <= lastEndIndex; i++) { - removed = true; - lastEndNode = lastChildren[i]; - if (k < bLength) { - for (index = nextStartIndex; index <= nextEndIndex; index++) { - nextEndNode = nextChildren[index]; - if (lastEndNode.key === nextEndNode.key) { - sources[index - nextStartIndex] = i; - - if (lastTarget > index) { - moved = true; - } else { - lastTarget = index; - } - patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); - k++; - removed = false; - break; - } - } - } - if (removed) { - remove(lastEndNode, dom); - removeOffset++; - } - } - } else { - const prevItemsMap = new Map(); - - for (i = nextStartIndex; i <= nextEndIndex; i++) { - prevItemsMap.set(nextChildren[i].key, i); - } - for (i = lastStartIndex; i <= lastEndIndex; i++) { - removed = true; - lastEndNode = lastChildren[i]; - - if (k < nextChildrenLength) { - index = prevItemsMap.get(lastEndNode.key); - - if (index !== undefined) { - nextEndNode = nextChildren[index]; - sources[index - nextStartIndex] = i; - if (lastTarget > index) { - moved = true; - } else { - lastTarget = index; - } - patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); - k++; - removed = false; - } - } - if (removed) { - remove(lastEndNode, dom); - removeOffset++; - } - } - } - - let pos; - if (moved) { - let seq = lis_algorithm(sources); - index = seq.length - 1; - for (i = bLength - 1; i >= 0; i--) { - if (sources[i] === -1) { - pos = i + nextStartIndex; - nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; - insertOrAppend(dom, mount(nextChildren[pos], null, lifecycle, context, instance, isSVG), nextNode); - } else { - if (index < 0 || i !== seq[index]) { - pos = i + nextStartIndex; - nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; - insertOrAppend(dom, nextChildren[pos].dom, nextNode); - } else { - index--; - } - } - } - } else if (aLength - removeOffset !== bLength) { - for (i = bLength - 1; i >= 0; i--) { - if (sources[i] === -1) { - pos = i + nextStartIndex; - nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; - insertOrAppend(dom, mount(nextChildren[pos], null, lifecycle, context, instance, isSVG), nextNode); - } - } - } - } + let lastChildrenLength = lastChildren.length; + let nextChildrenLength = nextChildren.length; + let lastEndIndex = lastChildrenLength - 1; + let nextEndIndex = nextChildrenLength - 1; + let lastStartIndex = 0; + let nextStartIndex = 0; + let lastStartNode = null; + let nextStartNode = null; + let nextEndNode = null; + let lastEndNode = null; + let nextNode; + + while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { + nextStartNode = nextChildren[nextStartIndex]; + lastStartNode = lastChildren[lastStartIndex]; + + if (nextStartNode.key !== lastStartNode.key) { + break; + } + patchVNode(lastStartNode, nextStartNode, dom, lifecycle, context, instance, isSVG, false); + nextStartIndex++; + lastStartIndex++; + } + while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { + nextEndNode = nextChildren[nextEndIndex]; + lastEndNode = lastChildren[lastEndIndex]; + + if (nextEndNode.key !== lastEndNode.key) { + break; + } + patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); + nextEndIndex--; + lastEndIndex--; + } + while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { + nextEndNode = nextChildren[nextEndIndex]; + lastStartNode = lastChildren[lastStartIndex]; + + if (nextEndNode.key !== lastStartNode.key) { + break; + } + nextNode = (nextEndIndex + 1 < nextChildrenLength) ? nextChildren[nextEndIndex + 1].dom : null; + patchVNode(lastStartNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); + insertOrAppend(dom, nextEndNode.dom, nextNode); + nextEndIndex--; + lastStartIndex++; + } + while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { + nextStartNode = nextChildren[nextStartIndex]; + lastEndNode = lastChildren[lastEndIndex]; + + if (nextStartNode.key !== lastEndNode.key) { + break; + } + nextNode = lastChildren[lastStartIndex].dom; + patchVNode(lastEndNode, nextStartNode, dom, lifecycle, context, instance, isSVG, false); + insertOrAppend(dom, nextStartNode.dom, nextNode); + nextStartIndex++; + lastEndIndex--; + } + + if (lastStartIndex > lastEndIndex) { + if (nextStartIndex <= nextEndIndex) { + nextNode = (nextEndIndex + 1 < nextChildrenLength) ? nextChildren[nextEndIndex + 1].dom : parentVList && parentVList.pointer; + for (; nextStartIndex <= nextEndIndex; nextStartIndex++) { + insertOrAppend(dom, mount(nextChildren[nextStartIndex], null, lifecycle, context, instance, isSVG), nextNode); + } + } + } else if (nextStartIndex > nextEndIndex) { + while (lastStartIndex <= lastEndIndex) { + remove(lastChildren[lastStartIndex++], dom); + } + } else { + let aLength = lastEndIndex - lastStartIndex + 1; + let bLength = nextEndIndex - nextStartIndex + 1; + const sources = new Array(bLength); + + // Mark all nodes as inserted. + let i; + for (i = 0; i < bLength; i++) { + sources[i] = -1; + } + let moved = false; + let removeOffset = 0; + let lastTarget = 0; + let index; + let removed = true; + let k = 0; + + if ((bLength <= 4) || (aLength * bLength <= 16)) { + for (i = lastStartIndex; i <= lastEndIndex; i++) { + removed = true; + lastEndNode = lastChildren[i]; + if (k < bLength) { + for (index = nextStartIndex; index <= nextEndIndex; index++) { + nextEndNode = nextChildren[index]; + if (lastEndNode.key === nextEndNode.key) { + sources[index - nextStartIndex] = i; + + if (lastTarget > index) { + moved = true; + } else { + lastTarget = index; + } + patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); + k++; + removed = false; + break; + } + } + } + if (removed) { + remove(lastEndNode, dom); + removeOffset++; + } + } + } else { + const prevItemsMap = new Map(); + + for (i = nextStartIndex; i <= nextEndIndex; i++) { + prevItemsMap.set(nextChildren[i].key, i); + } + for (i = lastStartIndex; i <= lastEndIndex; i++) { + removed = true; + lastEndNode = lastChildren[i]; + + if (k < nextChildrenLength) { + index = prevItemsMap.get(lastEndNode.key); + + if (index !== undefined) { + nextEndNode = nextChildren[index]; + sources[index - nextStartIndex] = i; + if (lastTarget > index) { + moved = true; + } else { + lastTarget = index; + } + patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); + k++; + removed = false; + } + } + if (removed) { + remove(lastEndNode, dom); + removeOffset++; + } + } + } + + let pos; + if (moved) { + let seq = lis_algorithm(sources); + index = seq.length - 1; + for (i = bLength - 1; i >= 0; i--) { + if (sources[i] === -1) { + pos = i + nextStartIndex; + nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; + insertOrAppend(dom, mount(nextChildren[pos], null, lifecycle, context, instance, isSVG), nextNode); + } else { + if (index < 0 || i !== seq[index]) { + pos = i + nextStartIndex; + nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; + insertOrAppend(dom, nextChildren[pos].dom, nextNode); + } else { + index--; + } + } + } + } else if (aLength - removeOffset !== bLength) { + for (i = bLength - 1; i >= 0; i--) { + if (sources[i] === -1) { + pos = i + nextStartIndex; + nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; + insertOrAppend(dom, mount(nextChildren[pos], null, lifecycle, context, instance, isSVG), nextNode); + } + } + } + } } // https://en.wikipedia.org/wiki/Longest_increasing_subsequence function lis_algorithm(a) { - let p = a.slice(0); - let result = []; - result.push(0); - let i; - let j; - let u; - let v; - let c; - - for (i = 0; i < a.length; i++) { - if (a[i] === -1) { - continue; - } - - j = result[result.length - 1]; - if (a[j] < a[i]) { - p[i] = j; - result.push(i); - continue; - } - - u = 0; - v = result.length - 1; - - while (u < v) { - c = ((u + v) / 2) | 0; - if (a[result[c]] < a[i]) { - u = c + 1; - } else { - v = c; - } - } - - if (a[i] < a[result[u]]) { - if (u > 0) { - p[i] = result[u - 1]; - } - result[u] = i; - } - } - - u = result.length; - v = result[u - 1]; - - while (u-- > 0) { - result[u] = v; - v = p[v]; - } - - return result; + let p = a.slice(0); + let result = []; + result.push(0); + let i; + let j; + let u; + let v; + let c; + + for (i = 0; i < a.length; i++) { + if (a[i] === -1) { + continue; + } + + j = result[result.length - 1]; + if (a[j] < a[i]) { + p[i] = j; + result.push(i); + continue; + } + + u = 0; + v = result.length - 1; + + while (u < v) { + c = ((u + v) / 2) | 0; + if (a[result[c]] < a[i]) { + u = c + 1; + } else { + v = c; + } + } + + if (a[i] < a[result[u]]) { + if (u > 0) { + p[i] = result[u - 1]; + } + result[u] = i; + } + } + + u = result.length; + v = result[u - 1]; + + while (u-- > 0) { + result[u] = v; + v = p[v]; + } + + return result; } From 39f15cfbfa37b987de85f9daca5b39f67cb9f2a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sampo=20Kivist=C3=B6?= Date: Wed, 31 Aug 2016 16:31:16 +0300 Subject: [PATCH 3/4] Updated dependencies, new build, fixed issue with patchText --- config/rollup.config.js | 4 +- package.json | 42 +- packages/inferno/dist/inferno-compat.js | 6278 ++++++++--------- packages/inferno/dist/inferno-compat.min.js | 4 +- packages/inferno/dist/inferno-component.js | 472 +- packages/inferno/dist/inferno-create-class.js | 562 +- .../inferno/dist/inferno-create-element.js | 416 +- packages/inferno/dist/inferno-dom.js | 3200 ++++----- packages/inferno/dist/inferno-dom.min.js | 2 +- packages/inferno/dist/inferno-redux.js | 1807 ++--- packages/inferno/dist/inferno-redux.min.js | 2 +- packages/inferno/dist/inferno-router.js | 1130 +-- packages/inferno/dist/inferno-server.js | 902 +-- packages/inferno/dist/inferno-server.min.js | 2 +- packages/inferno/dist/inferno-test-utils.js | 32 +- packages/inferno/dist/inferno.js | 562 +- src/DOM/patching.js | 2 +- 17 files changed, 7711 insertions(+), 7708 deletions(-) diff --git a/config/rollup.config.js b/config/rollup.config.js index 4433d2609..84535a044 100644 --- a/config/rollup.config.js +++ b/config/rollup.config.js @@ -14,7 +14,9 @@ const pkg = JSON.parse(fs.readFileSync('./package.json')); const external = Object.keys(pkg.peerDependencies || {}).concat(Object.keys(pkg.dependencies || {})); const plugins = [ - buble(), + buble({ + objectAssign: 'Object.assign' + }), nodeResolve({ jsnext: true, main: true, diff --git a/package.json b/package.json index 7510a21ba..0e1ff891c 100644 --- a/package.json +++ b/package.json @@ -10,52 +10,52 @@ "url": "https://github.com/trueadm/inferno/issues" }, "devDependencies": { - "babel-cli": "^6.11.4", - "babel-core": "^6.11.4", + "babel-cli": "^6.14.0", + "babel-core": "^6.14.0", "babel-eslint": "^6.1.2", - "babel-loader": "^6.2.4", + "babel-loader": "^6.2.5", "babel-plugin-inferno": "^0.7.7", - "babel-plugin-syntax-jsx": "^6.8.0", - "babel-plugin-syntax-object-rest-spread": "^6.8.0", + "babel-plugin-syntax-jsx": "^6.13.0", + "babel-plugin-syntax-object-rest-spread": "^6.13.0", "babel-plugin-transform-es2015-modules-umd": "^6.12.0", "babel-plugin-transform-inline-environment-variables": "^6.8.0", "babel-plugin-transform-object-assign": "^6.8.0", "babel-plugin-transform-object-rest-spread": "^6.8.0", "babel-plugin-transform-undefined-to-void": "^6.8.0", - "babel-polyfill": "^6.9.1", - "babel-preset-es2015": "^6.9.0", - "babel-preset-es2015-rollup": "^1.1.1", + "babel-polyfill": "^6.13.0", + "babel-preset-es2015": "^6.14.0", + "babel-preset-es2015-rollup": "^1.2.0", "babel-preset-stage-0": "^6.5.0", - "babel-register": "^6.11.6", + "babel-register": "^6.14.0", "chai": "^3.5.0", "concat-stream": "^1.5.1", "coveralls": "^2.11.12", - "cross-env": "^2.0.0", - "eslint": "^3.2.2", + "cross-env": "^2.0.1", + "eslint": "^3.4.0", "eslint-plugin-babel": "^3.3.0", - "glob": "^7.0.5", + "glob": "^7.0.6", "hoist-non-inferno-statics": "^1.1.1", "invariant": "^2.2.1", "isparta": "^4.0.0", - "jsdom": "^9.4.1", - "karma": "^1.1.2", + "jsdom": "^9.4.5", + "karma": "^1.2.0", "karma-chai": "^0.1.0", "karma-chrome-launcher": "^2.0.0", "karma-firefox-launcher": "^1.0.0", "karma-ie-launcher": "^1.0.0", "karma-mocha": "^1.1.1", "karma-mocha-reporter": "^2.1.0", - "karma-phantomjs-launcher": "^1.0.1", - "karma-webpack": "^1.7.0", + "karma-phantomjs-launcher": "^1.0.2", + "karma-webpack": "^1.8.0", "mkdirp": "^0.5.1", - "mocha": "^3.0.0", + "mocha": "^3.0.2", "mocha-lcov-reporter": "^1.2.0", - "phantomjs-prebuilt": "^2.1.9", + "phantomjs-prebuilt": "^2.1.12", "pre-commit": "^1.1.3", "proptypes": "^0.14.3", "redux": "^3.5.2", "rimraf": "^2.5.4", - "rollup": "^0.34.3", + "rollup": "^0.34.11", "rollup-plugin-babel": "^2.6.1", "rollup-plugin-buble": "^0.13.0", "rollup-plugin-commonjs": "^3.3.1", @@ -64,8 +64,8 @@ "rollup-plugin-replace": "^1.1.1", "rollup-plugin-uglify": "^1.0.1", "sinon": "2.0.0-pre", - "webpack": "^1.13.1", - "webpack-dev-server": "^1.14.1" + "webpack": "^1.13.2", + "webpack-dev-server": "^1.15.0" }, "files": [ "src" diff --git a/packages/inferno/dist/inferno-compat.js b/packages/inferno/dist/inferno-compat.js index ecbf6f6ec..a6cde0888 100644 --- a/packages/inferno/dist/inferno-compat.js +++ b/packages/inferno/dist/inferno-compat.js @@ -1,5 +1,5 @@ /*! - * inferno-compat v0.7.25 + * inferno-compat v0.7.26 * (c) 2016 Dominic Gannaway * Released under the MIT License. */ @@ -7,3221 +7,3221 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (factory((global.InfernoCompat = global.InfernoCompat || {}))); -}(this, function (exports) { 'use strict'; - - function addChildrenToProps(children, props) { - if (!isNullOrUndefined(children)) { - var isChildrenArray = isArray(children); - if (isChildrenArray && children.length > 0 || !isChildrenArray) { - if (props) { - props = Object.assign({}, props, { children: children }); - } else { - props = { - children: children - }; - } - } - } - return props; - } - - var NO_RENDER = 'NO_RENDER'; - - // Runs only once in applications lifetime - var isBrowser = typeof window !== 'undefined' && window.document; - - function isArray(obj) { - return obj instanceof Array; - } - - function isStatefulComponent(obj) { - return obj.prototype && obj.prototype.render !== undefined; - } - - function isStringOrNumber(obj) { - return isString(obj) || isNumber(obj); - } - - function isNullOrUndefined(obj) { - return isUndefined(obj) || isNull(obj); - } - - function isInvalidNode(obj) { - return isNull(obj) || obj === false || obj === true || isUndefined(obj); - } - - function isFunction(obj) { - return typeof obj === 'function'; - } - - function isAttrAnEvent(attr) { - return attr[0] === 'o' && attr[1] === 'n' && attr.length > 3; - } - - function isString(obj) { - return typeof obj === 'string'; - } - - function isNumber(obj) { - return typeof obj === 'number'; - } - - function isNull(obj) { - return obj === null; - } - - function isTrue(obj) { - return obj === true; - } - - function isUndefined(obj) { - return obj === undefined; - } - - function isAttrAHook(hook) { - return hook === 'onCreated' - || hook === 'onAttached' - || hook === 'onWillDetach' - || hook === 'onWillUpdate' - || hook === 'onDidUpdate'; - } - - function isAttrAComponentHook(hook) { - return hook === 'onComponentWillMount' - || hook === 'onComponentDidMount' - || hook === 'onComponentWillUnmount' - || hook === 'onComponentShouldUpdate' - || hook === 'onComponentWillUpdate' - || hook === 'onComponentDidUpdate'; - } - - function deepScanChildrenForNode(children, node) { - if (!isInvalidNode(children)) { - if (isArray(children)) { - for (var i = 0; i < children.length; i++) { - var child = children[i]; - - if (!isInvalidNode(child)) { - if (child === node) { - return true; - } else if (child.children) { - return deepScanChildrenForNode(child.children, node); - } - } - } - } else { - if (children === node) { - return true; - } else if (children.children) { - return deepScanChildrenForNode(children.children, node); - } - } - } - return false; - } - - function getRefInstance$1(node, instance) { - var children = instance.props.children; - - if (deepScanChildrenForNode(children, node)) { - return getRefInstance$1(node, instance._parentComponent); - } - return instance; - } - - var recyclingEnabled = true; - - function recycle(node, bp, lifecycle, context, instance) { - if (bp !== undefined) { - var pool = bp.pool; - var recycledNode = pool.pop(); - - if (!isNullOrUndefined(recycledNode)) { - patch(recycledNode, node, null, lifecycle, context, instance, bp.isSVG); - return node.dom; - } - } - return null; - } - - function pool(node) { - var bp = node.bp; - - if (!isNullOrUndefined(bp)) { - bp.pool.push(node); - return true; - } - return false; - } - - function unmount(input, parentDom) { - if (isVList(input)) { - unmountVList(input, parentDom, true); - } else if (isVNode(input)) { - unmountVNode(input, parentDom, false); - } - } - - function unmountVList(vList, parentDom, removePointer) { - var items = vList.items; - var itemsLength = items.length; - var pointer = vList.pointer; - - if (itemsLength > 0) { - for (var i = 0; i < itemsLength; i++) { - var item = items[i]; - - if (isVList(item)) { - unmountVList(item, parentDom, true); - } else { - if (parentDom) { - removeChild(parentDom, item.dom); - } - unmount(item, null); - } - } - } - if (parentDom && removePointer) { - removeChild(parentDom, pointer); - } - } - - function unmountVNode(node, parentDom, shallow) { - var instance = node.instance; - var instanceHooks = null; - var instanceChildren = null; - - if (!isNullOrUndefined(instance)) { - instanceHooks = instance.hooks; - instanceChildren = instance.children; - - if (instance.render !== undefined) { - instance.componentWillUnmount(); - instance._unmounted = true; - componentToDOMNodeMap.delete(instance); - !shallow && unmount(instance._lastNode, null); - } - } - var hooks = node.hooks || instanceHooks; - - if (!isNullOrUndefined(hooks)) { - if (!isNullOrUndefined(hooks.willDetach)) { - hooks.willDetach(node.dom); - } - if (!isNullOrUndefined(hooks.componentWillUnmount)) { - hooks.componentWillUnmount(node.dom, hooks); - } - } - var children = (isNullOrUndefined(instance) ? node.children : null) || instanceChildren; - - if (!isNullOrUndefined(children)) { - if (isArray(children)) { - for (var i = 0; i < children.length; i++) { - unmount(children[i], null); - } - } else { - unmount(children, null); - } - } - } - - function VNode(blueprint) { - this.bp = blueprint; - this.dom = null; - this.instance = null; - this.tag = null; - this.children = null; - this.style = null; - this.className = null; - this.attrs = null; - this.events = null; - this.hooks = null; - this.key = null; - this.clipData = null; - } - - VNode.prototype = { - setAttrs: function setAttrs(attrs) { - this.attrs = attrs; - return this; - }, - setTag: function setTag(tag) { - this.tag = tag; - return this; - }, - setStyle: function setStyle(style) { - this.style = style; - return this; - }, - setClassName: function setClassName(className) { - this.className = className; - return this; - }, - setChildren: function setChildren(children) { - this.children = children; - return this; - }, - setHooks: function setHooks(hooks) { - this.hooks = hooks; - return this; - }, - setEvents: function setEvents(events) { - this.events = events; - return this; - }, - setKey: function setKey(key) { - this.key = key; - return this; - } - }; - - function createVNode(bp) { - return new VNode(bp); - } - - function isAttrAnEvent$1(attr) { - return attr[0] === 'o' && attr[1] === 'n' && attr.length > 3; - } - - function isAttrAHook$1(hook) { - return hook === 'onCreated' - || hook === 'onAttached' - || hook === 'onWillDetach' - || hook === 'onWillUpdate' - || hook === 'onDidUpdate'; - } - - function isAttrAComponentHook$1(hook) { - return hook === 'onComponentWillMount' - || hook === 'onComponentDidMount' - || hook === 'onComponentWillUnmount' - || hook === 'onComponentShouldUpdate' - || hook === 'onComponentWillUpdate' - || hook === 'onComponentDidUpdate'; - } - - - function createBlueprint(shape, childrenType) { - var tag = shape.tag || null; - var tagIsDynamic = tag && tag.arg !== undefined ? true : false; - - var children = isNullOrUndefined(shape.children) ? null : shape.children; - var childrenIsDynamic = children && children.arg !== undefined ? true : false; - - var attrs = shape.attrs || null; - var attrsIsDynamic = attrs && attrs.arg !== undefined ? true : false; - - var hooks = shape.hooks || null; - var hooksIsDynamic = hooks && hooks.arg !== undefined ? true : false; - - var events = shape.events || null; - var eventsIsDynamic = events && events.arg !== undefined ? true : false; - - var key = shape.key === undefined ? null : shape.key; - var keyIsDynamic = !isNullOrUndefined(key) && !isNullOrUndefined(key.arg); - - var style = shape.style || null; - var styleIsDynamic = style && style.arg !== undefined ? true : false; - - var className = shape.className === undefined ? null : shape.className; - var classNameIsDynamic = className && className.arg !== undefined ? true : false; - - var spread = shape.spread === undefined ? null : shape.spread; - var hasSpread = shape.spread !== undefined; - - var blueprint = { - lazy: shape.lazy || false, - dom: null, - pool: [], - tag: tagIsDynamic ? null : tag, - className: className !== '' && className ? className : null, - style: style !== '' && style ? style : null, - isComponent: tagIsDynamic, - hasAttrs: attrsIsDynamic || (attrs ? true : false), - hasHooks: hooksIsDynamic, - hasEvents: eventsIsDynamic, - hasStyle: styleIsDynamic || (style !== '' && style ? true : false), - hasClassName: classNameIsDynamic || (className !== '' && className ? true : false), - childrenType: childrenType === undefined ? (children ? 5 : 0) : childrenType, - attrKeys: null, - eventKeys: null, - isSVG: shape.isSVG || false - }; - - return function () { - var vNode = new VNode(blueprint); - - if (tagIsDynamic === true) { - vNode.tag = arguments[tag.arg]; - } - if (childrenIsDynamic === true) { - vNode.children = arguments[children.arg]; - } - if (hasSpread) { - var _spread = arguments[spread.arg]; - var attrs$1; - var events$1; - var hooks$1; - var attrKeys = []; - var eventKeys = []; - - for (var prop in _spread) { - var value = _spread[prop]; - - if (prop === 'className' || (prop === 'class' && !blueprint.isSVG)) { - vNode.className = value; - blueprint.hasClassName = true; - } else if (prop === 'style') { - vNode.style = value; - blueprint.hasStyle = true; - } else if (prop === 'key') { - vNode.key = value; - } else if (isAttrAHook$1(prop) || isAttrAComponentHook$1(prop)) { - if (!hooks$1) { - hooks$1 = {}; - } - hooks$1[prop[2].toLowerCase() + prop.substring(3)] = value; - } else if (isAttrAnEvent$1(prop)) { - if (!events$1) { - events$1 = {}; - } - eventKeys.push(prop.toLowerCase()); - events$1[prop.toLowerCase()] = value; - } else if (prop === 'children') { - vNode.children = value; - blueprint.childrenType = blueprint.childrenType || 5; - } else { - if (!attrs$1) { - attrs$1 = {}; - } - attrKeys.push(prop); - attrs$1[prop] = value; - } - } - if (attrs$1) { - vNode.attrs = attrs$1; - blueprint.attrKeys = attrKeys; - blueprint.hasAttrs = true; - } - if (events$1) { - vNode.events = events$1; - blueprint.eventKeys = eventKeys; - blueprint.hasEvents = true; - } - if (hooks$1) { - vNode.hooks = hooks$1; - blueprint.hasHooks = true; - } - } else { - if (attrsIsDynamic === true) { - vNode.attrs = arguments[attrs.arg]; - } else { - vNode.attrs = attrs; - } - if (hooksIsDynamic === true) { - vNode.hooks = arguments[hooks.arg]; - } - if (eventsIsDynamic === true) { - vNode.events = arguments[events.arg]; - } - if (keyIsDynamic === true) { - vNode.key = arguments[key.arg]; - } else { - vNode.key = key; - } - if (styleIsDynamic === true) { - vNode.style = arguments[style.arg]; - } else { - vNode.style = blueprint.style; - } - if (classNameIsDynamic === true) { - vNode.className = arguments[className.arg]; - } else { - vNode.className = blueprint.className; - } - } - return vNode; - }; - } - - function VText(text) { - this.text = text; - this.dom = null; - } - - function VPlaceholder() { - this.placeholder = true; - this.dom = null; - } - - function VList(items) { - this.dom = null; - this.pointer = null; - this.items = items; - } - - function createVText(text) { - return new VText(text); - } - - function createVPlaceholder() { - return new VPlaceholder(); - } - - function createVList(items) { - return new VList(items); - } - - function constructDefaults(string, object, value) { - /* eslint no-return-assign: 0 */ - string.split(',').forEach(function (i) { return object[i] = value; }); - } - - var xlinkNS = 'http://www.w3.org/1999/xlink'; - var xmlNS = 'http://www.w3.org/XML/1998/namespace'; - var strictProps = {}; - var booleanProps = {}; - var namespaces = {}; - var isUnitlessNumber = {}; - - constructDefaults('xlink:href,xlink:arcrole,xlink:actuate,xlink:role,xlink:titlef,xlink:type', namespaces, xlinkNS); - constructDefaults('xml:base,xml:lang,xml:space', namespaces, xmlNS); - constructDefaults('volume,value', strictProps, true); - constructDefaults('muted,scoped,loop,open,checked,default,capture,disabled,selected,readonly,multiple,required,autoplay,controls,seamless,reversed,allowfullscreen,novalidate', booleanProps, true); - constructDefaults('animationIterationCount,borderImageOutset,borderImageSlice,borderImageWidth,boxFlex,boxFlexGroup,boxOrdinalGroup,columnCount,flex,flexGrow,flexPositive,flexShrink,flexNegative,flexOrder,gridRow,gridColumn,fontWeight,lineClamp,lineHeight,opacity,order,orphans,tabSize,widows,zIndex,zoom,fillOpacity,floodOpacity,stopOpacity,strokeDasharray,strokeDashoffset,strokeMiterlimit,strokeOpacity,strokeWidth,', isUnitlessNumber, true); - - function isVText(o) { - return o.text !== undefined; - } - - function isVPlaceholder(o) { - return o.placeholder === true; - } - - function isVList(o) { - return o.items !== undefined; - } - - function isVNode(o) { - return o.tag !== undefined || o.bp !== undefined; - } - - function insertOrAppend(parentDom, newNode, nextNode) { - if (isNullOrUndefined(nextNode)) { - parentDom.appendChild(newNode); - } else { - parentDom.insertBefore(newNode, nextNode); - } - } - - function replaceVListWithNode(parentDom, vList, dom) { - var pointer = vList.pointer; - - unmountVList(vList, parentDom, false); - replaceNode(parentDom, dom, pointer); - } - - function documentCreateElement(tag, isSVG) { - var dom; - - if (isSVG === true) { - dom = document.createElementNS('http://www.w3.org/2000/svg', tag); - } else { - dom = document.createElement(tag); - } - return dom; - } - - function appendText(text, parentDom, singleChild) { - if (parentDom === null) { - return document.createTextNode(text); - } else { - if (singleChild) { - if (text !== '') { - parentDom.textContent = text; - return parentDom.firstChild; - } else { - var textNode = document.createTextNode(''); - - parentDom.appendChild(textNode); - return textNode; - } - } else { - var textNode$1 = document.createTextNode(text); - - parentDom.appendChild(textNode$1); - return textNode$1; - } - } - } - - function replaceWithNewNode(lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG) { - var lastInstance = null; - var instanceLastNode = lastNode._lastNode; - - if (!isNullOrUndefined(instanceLastNode)) { - lastInstance = lastNode; - lastNode = instanceLastNode; - } - unmount(lastNode, false); - var dom = mount(nextNode, null, lifecycle, context, instance, isSVG); - - nextNode.dom = dom; - replaceNode(parentDom, dom, lastNode.dom); - if (lastInstance !== null) { - lastInstance._lastNode = nextNode; - } - } - - function replaceNode(parentDom, nextDom, lastDom) { - parentDom.replaceChild(nextDom, lastDom); - } - - function normalise(object) { - if (isStringOrNumber(object)) { - return createVText(object); - } else if (isInvalidNode(object)) { - return createVPlaceholder(); - } else if (isArray(object)) { - return createVList(object); - } - return object; - } - - function normaliseChild(children, i) { - var child = children[i]; - - return children[i] = normalise(child); - } - - function remove(node, parentDom) { - if (isVList(node)) { - return unmount(node, parentDom); - } - var dom = node.dom; - if (dom === parentDom) { - dom.innerHTML = ''; - } else { - removeChild(parentDom, dom); - if (recyclingEnabled) { - pool(node); - } - } - unmount(node, false); - } - - function removeChild(parentDom, dom) { - parentDom.removeChild(dom); - } - - function removeEvents(events, lastEventKeys, dom) { - var eventKeys = lastEventKeys || Object.keys(events); - - for (var i = 0; i < eventKeys.length; i++) { - var event = eventKeys[i]; - - dom[event] = null; - } - } - - // TODO: for node we need to check if document is valid - function getActiveNode() { - return document.activeElement; - } - - function removeAllChildren(dom, children) { - if (recyclingEnabled) { - var childrenLength = children.length; - - if (childrenLength > 5) { - for (var i = 0; i < childrenLength; i++) { - var child = children[i]; - - if (!isInvalidNode(child)) { - pool(child); - } - } - } - } - dom.textContent = ''; - } - - function resetActiveNode(activeNode) { - if (activeNode !== null && activeNode !== document.body && document.activeElement !== activeNode) { - activeNode.focus(); // TODO: verify are we doing new focus event, if user has focus listener this might trigger it - } - } - - function isKeyed(lastChildren, nextChildren) { - if (lastChildren.complex) { - return false; - } - return nextChildren.length && !isNullOrUndefined(nextChildren[0]) && !isNullOrUndefined(nextChildren[0].key) - && lastChildren.length && !isNullOrUndefined(lastChildren[0]) && !isNullOrUndefined(lastChildren[0].key); - } - - function selectOptionValueIfNeeded(vdom, values) { - if (vdom.tag !== 'option') { - for (var i = 0, len = vdom.children.length; i < len; i++) { - selectOptionValueIfNeeded(vdom.children[i], values); - } - // NOTE! Has to be a return here to catch optGroup elements - return; - } - - var value = vdom.attrs && vdom.attrs.value; - - if (values[value]) { - vdom.attrs = vdom.attrs || {}; - vdom.attrs.selected = 'selected'; - vdom.dom.selected = true; - } else { - vdom.dom.selected = false; - } - } - - function selectValue(vdom) { - var value = vdom.attrs && vdom.attrs.value; - - var values = {}; - if (isArray(value)) { - for (var i = 0, len = value.length; i < len; i++) { - values[value[i]] = value[i]; - } - } else { - values[value] = value; - } - for (var i$1 = 0, len$1 = vdom.children.length; i$1 < len$1; i$1++) { - selectOptionValueIfNeeded(vdom.children[i$1], values); - } - - if (vdom.attrs && vdom.attrs[value]) { - delete vdom.attrs.value; // TODO! Avoid deletion here. Set to null or undef. Not sure what you want to usev - } - } - - function handleAttachedHooks(hooks, lifecycle, dom) { - if (!isNullOrUndefined(hooks.created)) { - hooks.created(dom); - } - if (!isNullOrUndefined(hooks.attached)) { - lifecycle.addListener(function () { - hooks.attached(dom); - }); - } - } - - function setValueProperty(nextNode) { - var value = nextNode.attrs.value; - if (!isNullOrUndefined(value)) { - nextNode.dom.value = value; - } - } - - function setFormElementProperties(nextTag, nextNode) { - if (nextTag === 'input' && nextNode.attrs) { - var inputType = nextNode.attrs.type; - if (inputType === 'text') { - setValueProperty(nextNode); - } else if (inputType === 'checkbox' || inputType === 'radio') { - var checked = nextNode.attrs.checked; - nextNode.dom.checked = !!checked; - } - } else if (nextTag === 'textarea') { - setValueProperty(nextNode); - } - } - - function mount(input, parentDom, lifecycle, context, instance, isSVG) { - if (isVPlaceholder(input)) { - return mountVPlaceholder(input, parentDom); - } else if (isVText(input)) { - return mountVText(input, parentDom); - } else if (isVList(input)) { - return mountVList(input, parentDom, lifecycle, context, instance, isSVG); - } else if (isVNode(input)) { - return mountVNode$1(input, parentDom, lifecycle, context, instance, isSVG); - } else { - var normalisedInput = normalise(input); - - if (input !== normalisedInput) { - return mount(normalisedInput, parentDom, lifecycle, context, instance, isSVG); - } else { - throw new Error(("Inferno Error: invalid object \"" + (typeof input) + "\" passed to mount()")); - } - } - } - - function mountVNode$1(vNode, parentDom, lifecycle, context, instance, isSVG) { - var bp = vNode.bp; - - if (isUndefined(bp)) { - return mountVNodeWithoutBlueprint(vNode, parentDom, lifecycle, context, instance, isSVG); - } else { - if (recyclingEnabled) { - var dom = recycle(vNode, bp, lifecycle, context, instance); - - if (!isNull(dom)) { - if (!isNull(parentDom)) { - parentDom.appendChild(dom); - } - return dom; - } - } - return mountVNodeWithBlueprint(vNode, bp, parentDom, lifecycle, context, instance); - } - } - - function mountVList(vList, parentDom, lifecycle, context, instance, isSVG) { - var items = vList.items; - var pointer = document.createTextNode(''); - var dom = document.createDocumentFragment(); - - mountArrayChildren(items, dom, lifecycle, context, instance, isSVG); - vList.pointer = pointer; - vList.dom = dom; - dom.appendChild(pointer); - if (parentDom) { - insertOrAppend(parentDom, dom); - } - return dom; - } - - function mountVText(vText, parentDom) { - var dom = document.createTextNode(vText.text); - - vText.dom = dom; - if (parentDom) { - insertOrAppend(parentDom, dom); - } - return dom; - } - - function mountVPlaceholder(vPlaceholder, parentDom) { - var dom = document.createTextNode(''); - - vPlaceholder.dom = dom; - if (parentDom) { - insertOrAppend(parentDom, dom); - } - return dom; - } - - function handleSelects(node) { - if (node.tag === 'select') { - selectValue(node); - } - } - - function mountBlueprintAttrs(node, bp, dom, instance) { - handleSelects(node); - var attrs = node.attrs; - - if (isNull(bp.attrKeys)) { - var newKeys = Object.keys(attrs); - bp.attrKeys = bp.attrKeys ? bp.attrKeys.concat(newKeys) : newKeys; - } - var attrKeys = bp.attrKeys; - - mountAttributes(node, attrs, attrKeys, dom, instance); - } - - function mountBlueprintEvents(node, bp, dom) { - var events = node.events; - - if (isNull(bp.eventKeys)) { - bp.eventKeys = Object.keys(events); - } - var eventKeys = bp.eventKeys; - - mountEvents(events, eventKeys, dom); - } - - function mountVNodeWithBlueprint(node, bp, parentDom, lifecycle, context, instance) { - var tag = node.tag; - - if (isTrue(bp.isComponent)) { - return mountComponent(node, tag, node.attrs || {}, node.hooks, node.children, instance, parentDom, lifecycle, context); - } - var dom = documentCreateElement(bp.tag, bp.isSVG); - - node.dom = dom; - if (isTrue(bp.hasHooks)) { - handleAttachedHooks(node.hooks, lifecycle, dom); - } - if (isTrue(bp.lazy)) { - handleLazyAttached(node, lifecycle, dom); - } - var children = node.children; - // bp.childrenType: - // 0: no children - // 1: text node - // 2: single child - // 3: multiple children - // 4: multiple children (keyed) - // 5: variable children (defaults to no optimisation) - - switch (bp.childrenType) { - case 1: - appendText(children, dom, true); - break; - case 2: - mount(node.children, dom, lifecycle, context, instance, bp.isSVG); - break; - case 3: - mountArrayChildren(children, dom, lifecycle, context, instance, bp.isSVG); - break; - case 4: - for (var i = 0; i < children.length; i++) { - mount(children[i], dom, lifecycle, context, instance, bp.isSVG); - } - break; - case 5: - mountChildren(node, children, dom, lifecycle, context, instance, bp.isSVG); - break; - default: - break; - } - - if (isTrue(bp.hasAttrs)) { - mountBlueprintAttrs(node, bp, dom, instance); - } - if (isTrue(bp.hasClassName)) { - dom.className = node.className; - } - if (isTrue(bp.hasStyle)) { - patchStyle(null, node.style, dom); - } - if (isTrue(bp.hasEvents)) { - mountBlueprintEvents(node, bp, dom); - } - if (!isNull(parentDom)) { - parentDom.appendChild(dom); - } - return dom; - } - - function mountVNodeWithoutBlueprint(node, parentDom, lifecycle, context, instance, isSVG) { - var tag = node.tag; - - if (isFunction(tag)) { - return mountComponent(node, tag, node.attrs || {}, node.hooks, node.children, instance, parentDom, lifecycle, context); - } - if (!isString(tag) || tag === '') { - throw Error('Inferno Error: Expected function or string for element tag type'); - } - if (tag === 'svg') { - isSVG = true; - } - var dom = documentCreateElement(tag, isSVG); - var children = node.children; - var attrs = node.attrs; - var events = node.events; - var hooks = node.hooks; - var className = node.className; - var style = node.style; - - node.dom = dom; - if (!isNullOrUndefined(hooks)) { - handleAttachedHooks(hooks, lifecycle, dom); - } - if (!isInvalidNode(children)) { - mountChildren(node, children, dom, lifecycle, context, instance, isSVG); - } - if (!isNullOrUndefined(attrs)) { - handleSelects(node); - mountAttributes(node, attrs, Object.keys(attrs), dom, instance); - } - if (!isNullOrUndefined(className)) { - dom.className = className; - } - if (!isNullOrUndefined(style)) { - patchStyle(null, style, dom); - } - if (!isNullOrUndefined(events)) { - mountEvents(events, Object.keys(events), dom); - } - if (!isNull(parentDom)) { - parentDom.appendChild(dom); - } - return dom; - } - - function mountArrayChildren(children, parentDom, lifecycle, context, instance, isSVG) { - children.complex = false; - for (var i = 0; i < children.length; i++) { - var child = normaliseChild(children, i); - - if (isVText(child)) { - mountVText(child, parentDom); - children.complex = true; - } else if (isVPlaceholder(child)) { - mountVPlaceholder(child, parentDom); - children.complex = true; - } else if (isVList(child)) { - mountVList(child, parentDom, lifecycle, context, instance, isSVG); - children.complex = true; - } else { - mount(child, parentDom, lifecycle, context, instance, isSVG); - } - } - } - - function mountChildren(node, children, parentDom, lifecycle, context, instance, isSVG) { - if (isArray(children)) { - mountArrayChildren(children, parentDom, lifecycle, context, instance, isSVG); - } else if (isStringOrNumber(children)) { - appendText(children, parentDom, true); - } else if (!isInvalidNode(children)) { - mount(children, parentDom, lifecycle, context, instance, isSVG); - } - } - - function mountRef(instance, value, refValue) { - if (!isInvalidNode(instance) && isString(value)) { - instance.refs[value] = refValue; - } - } - - function mountEvents(events, eventKeys, dom) { - for (var i = 0; i < eventKeys.length; i++) { - var event = eventKeys[i]; - - dom[event] = events[event]; - } - } - - function mountComponent(parentNode, Component, props, hooks, children, lastInstance, parentDom, lifecycle, context) { - props = addChildrenToProps(children, props); - - var dom; - if (isStatefulComponent(Component)) { - var instance = new Component(props, context); - - instance._patch = patch; - instance._componentToDOMNodeMap = componentToDOMNodeMap; - if (!isNullOrUndefined(lastInstance) && props.ref) { - mountRef(lastInstance, props.ref, instance); - } - var childContext = instance.getChildContext(); - - if (!isNullOrUndefined(childContext)) { - context = Object.assign({}, context, childContext); - } - instance.context = context; - instance._unmounted = false; - instance._parentNode = parentNode; - if (lastInstance) { - instance._parentComponent = lastInstance; - } - instance._pendingSetState = true; - instance.componentWillMount(); - var node = instance.render(); - - if (isInvalidNode(node)) { - node = createVPlaceholder(); - } - instance._pendingSetState = false; - dom = mount(node, null, lifecycle, context, instance, false); - instance._lastNode = node; - instance.componentDidMount(); - if (parentDom !== null && !isInvalidNode(dom)) { - parentDom.appendChild(dom); - } - componentToDOMNodeMap.set(instance, dom); - parentNode.dom = dom; - parentNode.instance = instance; - } else { - if (!isNullOrUndefined(hooks)) { - if (!isNullOrUndefined(hooks.componentWillMount)) { - hooks.componentWillMount(null, props); - } - if (!isNullOrUndefined(hooks.componentDidMount)) { - lifecycle.addListener(function () { - hooks.componentDidMount(dom, props); - }); - } - } - - /* eslint new-cap: 0 */ - var node$1 = Component(props, context); - - if (isInvalidNode(node$1)) { - node$1 = createVPlaceholder(); - } - dom = mount(node$1, null, lifecycle, context, null, false); - - parentNode.instance = node$1; - - if (parentDom !== null && !isInvalidNode(dom)) { - parentDom.appendChild(dom); - } - parentNode.dom = dom; - } - return dom; - } - - function mountAttributes(node, attrs, attrKeys, dom, instance) { - for (var i = 0; i < attrKeys.length; i++) { - var attr = attrKeys[i]; - - if (attr === 'ref') { - mountRef(getRefInstance$1(node, instance), attrs[attr], dom); - } else { - patchAttribute(attr, null, attrs[attr], dom); - } - } - } - - function patch(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG) { - if (lastInput !== nextInput) { - if (isInvalidNode(lastInput)) { - mount(nextInput, parentDom, lifecycle, context, instance, isSVG); - } else if (isInvalidNode(nextInput)) { - remove(lastInput, parentDom); - } else if (isStringOrNumber(lastInput)) { - if (isStringOrNumber(nextInput)) { - parentDom.firstChild.nodeValue = nextInput; - } else { - var dom = mount(nextInput, null, lifecycle, context, instance, isSVG); - - nextInput.dom = dom; - replaceNode(parentDom, dom, parentDom.firstChild); - } - } else if (isStringOrNumber(nextInput)) { - replaceNode(parentDom, document.createTextNode(nextInput), lastInput.dom); - } else { - if (isVList(nextInput)) { - if (isVList(lastInput)) { - patchVList(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG); - } else { - replaceNode(parentDom, mountVList(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); - unmount(lastInput, null); - } - } else if (isVList(lastInput)) { - replaceVListWithNode(parentDom, lastInput, mount(nextInput, null, lifecycle, context, instance, isSVG)); - } else if (isVPlaceholder(nextInput)) { - if (isVPlaceholder(lastInput)) { - patchVFragment(lastInput, nextInput); - } else { - replaceNode(parentDom, mountVPlaceholder(nextInput, null), lastInput.dom); - unmount(lastInput, null); - } - } else if (isVPlaceholder(lastInput)) { - replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); - } else if (isVText(nextInput)) { - if (isVText(lastInput)) { - patchVText(lastInput, nextInput); - } else { - replaceNode(parentDom, mountVText(nextInput, null), lastInput.dom); - unmount(lastInput, null); - } - } else if (isVText(lastInput)) { - replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); - } else if (isVNode(nextInput)) { - if (isVNode(lastInput)) { - patchVNode(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG, false); - } else { - replaceNode(parentDom, mountVNode(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); - unmount(lastInput, null); - } - } else if (isVNode(lastInput)) { - replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); - unmount(lastInput, null); - } else { - return patch(lastInput, normalise(nextInput), parentDom, lifecycle, context, instance, isSVG); - } - } - } - return nextInput; - } - - function patchTextNode(dom, lastChildren, nextChildren) { - if (isStringOrNumber(lastChildren)) { - dom.firstChild.nodeValue = nextChildren; - } else { - dom.textContent = nextChildren; - } - } - - function patchRef(instance, lastValue, nextValue, dom) { - if (instance) { - if (isString(lastValue)) { - delete instance.refs[lastValue]; - } - if (isString(nextValue)) { - instance.refs[nextValue] = dom; - } - } - } - - function patchChildren(lastNode, nextNode, dom, lifecycle, context, instance, isSVG) { - var nextChildren = nextNode.children; - var lastChildren = lastNode.children; - - if (lastChildren === nextChildren) { - return; - } - if (isInvalidNode(lastChildren)) { - if (isStringOrNumber(nextChildren)) { - patchTextNode(dom, lastChildren, nextChildren); - } else if (!isInvalidNode(nextChildren)) { - if (isArray(nextChildren)) { - mountArrayChildren(nextChildren, dom, lifecycle, context, instance, isSVG); - } else { - mount(nextChildren, dom, lifecycle, context, instance, isSVG); - } - } - } else { - if (isInvalidNode(nextChildren)) { - removeAllChildren(dom, lastChildren); - } else { - if (isArray(lastChildren)) { - if (isArray(nextChildren)) { - nextChildren.complex = lastChildren.complex; - if (isKeyed(lastChildren, nextChildren)) { - patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, null); - } else { - patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, null); - } - } else { - patchNonKeyedChildren(lastChildren, [nextChildren], dom, lifecycle, context, instance, isSVG, null); - } - } else { - if (isArray(nextChildren)) { - var lastChild = lastChildren; - - if (isStringOrNumber(lastChildren)) { - lastChild = createVText(lastChild); - lastChild.dom = dom.firstChild; - } - patchNonKeyedChildren([lastChild], nextChildren, dom, lifecycle, context, instance, isSVG, null); - } else if (isStringOrNumber(nextChildren)) { - patchTextNode(dom, lastChildren, nextChildren); - } else if (isStringOrNumber(lastChildren)) { - patch(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG); - } else { - patchVNode(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, false); - } - } - } - } - } - - function patchVNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, isSVG, skipLazyCheck) { - var lastBp = lastVNode.bp; - var nextBp = nextVNode.bp; - - if (lastBp === undefined || nextBp === undefined) { - patchVNodeWithoutBlueprint(lastVNode, nextVNode, parentDom, lifecycle, context, instance, isSVG); - } else { - patchVNodeWithBlueprint(lastVNode, nextVNode, lastBp, nextBp, parentDom, lifecycle, context, instance, skipLazyCheck); - } - } - - function patchVNodeWithBlueprint(lastVNode, nextVNode, lastBp, nextBp, parentDom, lifecycle, context, instance, skipLazyCheck) { - var nextHooks; - - if (nextBp.hasHooks === true) { - nextHooks = nextVNode.hooks; - if (nextHooks && !isNullOrUndefined(nextHooks.willUpdate)) { - nextHooks.willUpdate(lastVNode.dom); - } - } - var nextTag = nextVNode.tag || nextBp.tag; - var lastTag = lastVNode.tag || lastBp.tag; - - if (lastTag !== nextTag) { - if (lastBp.isComponent === true) { - var lastNodeInstance = lastVNode.instance; - - if (nextBp.isComponent === true) { - replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, false); - } else if (isStatefulComponent(lastTag)) { - unmountVNode(lastVNode, null, true); - var lastNode = lastNodeInstance._lastNode; - patchVNodeWithBlueprint(lastNode, nextVNode, lastNode.bp, nextBp, parentDom, lifecycle, context, instance, nextBp.isSVG); - } else { - unmountVNode(lastVNode, null, true); - patchVNodeWithBlueprint(lastNodeInstance, nextVNode, lastNodeInstance.bp, nextBp, parentDom, lifecycle, context, instance, nextBp.isSVG); - } - } else { - replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, nextBp.isSVG); - } - } else if (isNullOrUndefined(lastTag)) { - nextVNode.dom = lastVNode.dom; - } else { - if (lastBp.isComponent === true) { - if (nextBp.isComponent === true) { - var instance$1 = lastVNode.instance; - - if (!isNullOrUndefined(instance$1) && instance$1._unmounted) { - var newDom = mountComponent(nextVNode, lastTag, nextVNode.attrs || {}, nextVNode.hooks, nextVNode.children, instance$1, parentDom, lifecycle, context); - if (parentDom !== null) { - replaceNode(parentDom, newDom, lastVNode.dom); - } - } else { - nextVNode.instance = instance$1; - nextVNode.dom = lastVNode.dom; - patchComponent(true, nextVNode, nextVNode.tag, lastBp, nextBp, instance$1, lastVNode.attrs || {}, nextVNode.attrs || {}, nextVNode.hooks, lastVNode.children, nextVNode.children, parentDom, lifecycle, context); - } - } - } else { - var dom = lastVNode.dom; - var lastChildrenType = lastBp.childrenType; - var nextChildrenType = nextBp.childrenType; - nextVNode.dom = dom; - - if (nextBp.lazy === true && skipLazyCheck === false) { - var clipData = lastVNode.clipData; - - if (lifecycle.scrollY === null) { - lifecycle.refresh(); - } - - nextVNode.clipData = clipData; - if (clipData.pending === true || clipData.top - lifecycle.scrollY > lifecycle.screenHeight) { - if (setClipNode(clipData, dom, lastVNode, nextVNode, parentDom, lifecycle, context, instance, lastBp.isSVG)) { - return; - } - } - if (clipData.bottom < lifecycle.scrollY) { - if (setClipNode(clipData, dom, lastVNode, nextVNode, parentDom, lifecycle, context, instance, lastBp.isSVG)) { - return; - } - } - } - - if (lastChildrenType > 0 || nextChildrenType > 0) { - if (nextChildrenType === 5 || lastChildrenType === 5) { - patchChildren(lastVNode, nextVNode, dom, lifecycle, context, instance); - } else { - var lastChildren = lastVNode.children; - var nextChildren = nextVNode.children; - - if (lastChildrenType === 0 || isInvalidNode(lastChildren)) { - if (nextChildrenType > 2) { - mountArrayChildren(nextChildren, dom, lifecycle, context, instance); - } else { - mount(nextChildren, dom, lifecycle, context, instance); - } - } else if (nextChildrenType === 0 || isInvalidNode(nextChildren)) { - if (lastChildrenType > 2) { - removeAllChildren(dom, lastChildren); - } else { - remove(lastChildren, dom); - } - } else { - if (lastChildren !== nextChildren) { - if (lastChildrenType === 4 && nextChildrenType === 4) { - patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, nextBp.isSVG, null); - } else if (lastChildrenType === 2 && nextChildrenType === 2) { - patch(lastChildren, nextChildren, dom, lifecycle, context, instance, true, nextBp.isSVG); - } else if (lastChildrenType === 1 && nextChildrenType === 1) { - patchTextNode(dom, lastChildren, nextChildren); - } else { - patchChildren(lastVNode, nextVNode, dom, lifecycle, context, instance, nextBp.isSVG); - } - } - } - } - } - if (lastBp.hasAttrs === true || nextBp.hasAttrs === true) { - patchAttributes(lastVNode, nextVNode, lastBp.attrKeys, nextBp.attrKeys, dom, instance); - } - if (lastBp.hasEvents === true || nextBp.hasEvents === true) { - patchEvents(lastVNode.events, nextVNode.events, lastBp.eventKeys, nextBp.eventKeys, dom); - } - if (lastBp.hasClassName === true || nextBp.hasClassName === true) { - var nextClassName = nextVNode.className; - - if (lastVNode.className !== nextClassName) { - if (isNullOrUndefined(nextClassName)) { - dom.removeAttribute('class'); - } else { - dom.className = nextClassName; - } - } - } - if (lastBp.hasStyle === true || nextBp.hasStyle === true) { - var nextStyle = nextVNode.style; - var lastStyle = lastVNode.style; - - if (lastStyle !== nextStyle) { - patchStyle(lastStyle, nextStyle, dom); - } - } - if (nextBp.hasHooks === true && !isNullOrUndefined(nextHooks.didUpdate)) { - nextHooks.didUpdate(dom); - } - setFormElementProperties(nextTag, nextVNode); - } - } - } - - function patchVNodeWithoutBlueprint(lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG) { - var nextHooks = nextNode.hooks; - var nextHooksDefined = !isNullOrUndefined(nextHooks); - - if (nextHooksDefined && !isNullOrUndefined(nextHooks.willUpdate)) { - nextHooks.willUpdate(lastNode.dom); - } - var nextTag = nextNode.tag || ((isNullOrUndefined(nextNode.bp)) ? null : nextNode.bp.tag); - var lastTag = lastNode.tag || ((isNullOrUndefined(lastNode.bp)) ? null : lastNode.bp.tag); - - if (nextTag === 'svg') { - isSVG = true; - } - if (lastTag !== nextTag) { - var lastNodeInstance = lastNode.instance; - - if (isFunction(lastTag)) { - if (isFunction(nextTag)) { - replaceWithNewNode(lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); - } else if (isStatefulComponent(lastTag)) { - unmountVNode(lastNode, null, true); - patchVNodeWithoutBlueprint(lastNodeInstance._lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); - } else { - unmountVNode(lastNode, null, true); - patchVNodeWithoutBlueprint(lastNodeInstance, nextNode, parentDom, lifecycle, context, instance, isSVG); - } - } else { - replaceWithNewNode(lastNodeInstance || lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); - } - } else if (isNullOrUndefined(lastTag)) { - nextNode.dom = lastNode.dom; - } else { - if (isFunction(lastTag)) { - if (isFunction(nextTag)) { - var instance$1 = lastNode._instance; - - if (!isNullOrUndefined(instance$1) && instance$1._unmounted) { - var newDom = mountComponent(nextNode, lastTag, nextNode.attrs || {}, nextNode.hooks, nextNode.children, instance$1, parentDom, lifecycle, context); - if (parentDom !== null) { - replaceNode(parentDom, newDom, lastNode.dom); - } - } else { - nextNode.instance = lastNode.instance; - nextNode.dom = lastNode.dom; - patchComponent(false, nextNode, nextNode.tag, null, null, nextNode.instance, lastNode.attrs || {}, nextNode.attrs || {}, nextNode.hooks, lastNode.children, nextNode.children, parentDom, lifecycle, context); - } - } - } else { - var dom = lastNode.dom; - var nextClassName = nextNode.className; - var nextStyle = nextNode.style; - - nextNode.dom = dom; - - patchChildren(lastNode, nextNode, dom, lifecycle, context, instance, isSVG); - patchAttributes(lastNode, nextNode, null, null, dom, instance); - patchEvents(lastNode.events, nextNode.events, null, null, dom); - - if (lastNode.className !== nextClassName) { - if (isNullOrUndefined(nextClassName)) { - dom.removeAttribute('class'); - } else { - dom.className = nextClassName; - } - } - if (lastNode.style !== nextStyle) { - patchStyle(lastNode.style, nextStyle, dom); - } - if (nextHooksDefined && !isNullOrUndefined(nextHooks.didUpdate)) { - nextHooks.didUpdate(dom); - } - setFormElementProperties(nextTag, nextNode); - } - } - } - - function patchAttributes(lastNode, nextNode, lastAttrKeys, nextAttrKeys, dom, instance) { - if (lastNode.tag === 'select') { - selectValue(nextNode); - } - var nextAttrs = nextNode.attrs; - var lastAttrs = lastNode.attrs; - var nextAttrsIsUndef = isNullOrUndefined(nextAttrs); - var lastAttrsIsNotUndef = !isNullOrUndefined(lastAttrs); - - if (!nextAttrsIsUndef) { - var nextAttrsKeys = nextAttrKeys || Object.keys(nextAttrs); - var attrKeysLength = nextAttrsKeys.length; - - for (var i = 0; i < attrKeysLength; i++) { - var attr = nextAttrsKeys[i]; - var lastAttrVal = lastAttrsIsNotUndef && lastAttrs[attr]; - var nextAttrVal = nextAttrs[attr]; - - if (lastAttrVal !== nextAttrVal) { - if (attr === 'ref') { - patchRef(instance, lastAttrVal, nextAttrVal, dom); - } else { - patchAttribute(attr, lastAttrVal, nextAttrVal, dom); - } - } - } - } - if (lastAttrsIsNotUndef) { - var lastAttrsKeys = lastAttrKeys || Object.keys(lastAttrs); - var attrKeysLength$1 = lastAttrsKeys.length; - - for (var i$1 = 0; i$1 < attrKeysLength$1; i$1++) { - var attr$1 = lastAttrsKeys[i$1]; - - if (nextAttrsIsUndef || isNullOrUndefined(nextAttrs[attr$1])) { - if (attr$1 === 'ref') { - patchRef(getRefInstance(node, instance), lastAttrs[attr$1], null, dom); - } else { - dom.removeAttribute(attr$1); - } - } - } - } - } - - - function patchStyle(lastAttrValue, nextAttrValue, dom) { - if (isString(nextAttrValue)) { - dom.style.cssText = nextAttrValue; - } else if (isNullOrUndefined(lastAttrValue)) { - if (!isNullOrUndefined(nextAttrValue)) { - var styleKeys = Object.keys(nextAttrValue); - - for (var i = 0; i < styleKeys.length; i++) { - var style = styleKeys[i]; - var value = nextAttrValue[style]; - - if (isNumber(value) && !isUnitlessNumber[style]) { - dom.style[style] = value + 'px'; - } else { - dom.style[style] = value; - } - } - } - } else if (isNullOrUndefined(nextAttrValue)) { - dom.removeAttribute('style'); - } else { - var styleKeys$1 = Object.keys(nextAttrValue); - - for (var i$1 = 0; i$1 < styleKeys$1.length; i$1++) { - var style$1 = styleKeys$1[i$1]; - var value$1 = nextAttrValue[style$1]; - - if (isNumber(value$1) && !isUnitlessNumber[style$1]) { - dom.style[style$1] = value$1 + 'px'; - } else { - dom.style[style$1] = value$1; - } - } - var lastStyleKeys = Object.keys(lastAttrValue); - - for (var i$2 = 0; i$2 < lastStyleKeys.length; i$2++) { - var style$2 = lastStyleKeys[i$2]; - if (isNullOrUndefined(nextAttrValue[style$2])) { - dom.style[style$2] = ''; - } - } - } - } - - function patchEvents(lastEvents, nextEvents, _lastEventKeys, _nextEventKeys, dom) { - var nextEventsDefined = !isNullOrUndefined(nextEvents); - var lastEventsDefined = !isNullOrUndefined(lastEvents); - var lastEventKeys; - - if (lastEventsDefined) { - lastEventKeys = _lastEventKeys || Object.keys(lastEvents); - } - if (nextEventsDefined) { - var nextEventKeys = _nextEventKeys || Object.keys(nextEvents); - - if (lastEventsDefined) { - for (var i = 0; i < nextEventKeys.length; i++) { - var event = nextEventKeys[i]; - var lastEvent = lastEvents[event]; - var nextEvent = nextEvents[event]; - - if (lastEvent !== nextEvent) { - dom[event] = nextEvent; - } - } - for (var i$1 = 0; i$1 < lastEventKeys.length; i$1++) { - var event$1 = lastEventKeys[i$1]; - - if (isNullOrUndefined(nextEvents[event$1])) { - dom[event$1] = null; - } - } - } else { - mountEvents(nextEvents, nextEventKeys, dom); - } - } else if (lastEventsDefined) { - removeEvents(lastEvents, lastEventKeys, dom); - } - } - - function patchAttribute(attrName, lastAttrValue, nextAttrValue, dom) { - if (attrName === 'dangerouslySetInnerHTML') { - var lastHtml = lastAttrValue && lastAttrValue.__html; - var nextHtml = nextAttrValue && nextAttrValue.__html; - - if (isNullOrUndefined(nextHtml)) { - throw new Error('Inferno Error: dangerouslySetInnerHTML requires an object with a __html propety containing the innerHTML content'); - } - if (lastHtml !== nextHtml) { - dom.innerHTML = nextHtml; - } - } else if (attrName === 'eventData') { - dom.eventData = nextAttrValue; - } else if (strictProps[attrName]) { - dom[attrName] = nextAttrValue === null ? '' : nextAttrValue; - } else { - if (booleanProps[attrName]) { - dom[attrName] = nextAttrValue ? true : false; - } else { - var ns = namespaces[attrName]; - - if (nextAttrValue === false || isNullOrUndefined(nextAttrValue)) { - if (ns !== undefined) { - dom.removeAttributeNS(ns, attrName); - } else { - dom.removeAttribute(attrName); - } - } else { - if (ns !== undefined) { - dom.setAttributeNS(ns, attrName, nextAttrValue === true ? attrName : nextAttrValue); - } else { - dom.setAttribute(attrName, nextAttrValue === true ? attrName : nextAttrValue); - } - } - } - } - } - - function patchComponent(hasBlueprint, lastNode, Component, lastBp, nextBp, instance, lastProps, nextProps, nextHooks, lastChildren, nextChildren, parentDom, lifecycle, context) { - nextProps = addChildrenToProps(nextChildren, nextProps); - - if (isStatefulComponent(Component)) { - var prevProps = instance.props; - var prevState = instance.state; - var nextState = instance.state; - - var childContext = instance.getChildContext(); - if (!isNullOrUndefined(childContext)) { - context = Object.assign({}, context, childContext); - } - instance.context = context; - var nextNode = instance._updateComponent(prevState, nextState, prevProps, nextProps); - - if (nextNode === NO_RENDER) { - nextNode = instance._lastNode; - } else if (isNullOrUndefined(nextNode)) { - nextNode = createVPlaceholder(); - } - patch(instance._lastNode, nextNode, parentDom, lifecycle, context, instance, null, false); - lastNode.dom = nextNode.dom; - instance._lastNode = nextNode; - instance.componentDidUpdate(prevProps, prevState); - componentToDOMNodeMap.set(instance, nextNode.dom); - } else { - var shouldUpdate = true; - var nextHooksDefined = (hasBlueprint && nextBp.hasHooks === true) || !isNullOrUndefined(nextHooks); - - lastProps = addChildrenToProps(lastChildren, lastProps); - if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentShouldUpdate)) { - shouldUpdate = nextHooks.componentShouldUpdate(lastNode.dom, lastProps, nextProps); - } - if (shouldUpdate !== false) { - if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentWillUpdate)) { - nextHooks.componentWillUpdate(lastNode.dom, lastProps, nextProps); - } - var nextNode$1 = Component(nextProps, context); - - if (isInvalidNode(nextNode$1)) { - nextNode$1 = createVPlaceholder(); - } - nextNode$1.dom = lastNode.dom; - patch(instance, nextNode$1, parentDom, lifecycle, context, null, null, false); - lastNode.instance = nextNode$1; - if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentDidUpdate)) { - nextHooks.componentDidUpdate(lastNode.dom, lastProps, nextProps); - } - } - } - } - - function patchVList(lastVList, nextVList, parentDom, lifecycle, context, instance, isSVG) { - var lastItems = lastVList.items; - var nextItems = nextVList.items; - var pointer = lastVList.pointer; - - nextVList.dom = lastVList.dom; - nextVList.pointer = pointer; - if (!lastItems !== nextItems) { - if (isKeyed(lastItems, nextItems)) { - patchKeyedChildren(lastItems, nextItems, parentDom, lifecycle, context, instance, isSVG, nextVList); - } else { - patchNonKeyedChildren(lastItems, nextItems, parentDom, lifecycle, context, instance, isSVG, nextVList); - } - } - } - - function patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, parentVList) { - var lastChildrenLength = lastChildren.length; - var nextChildrenLength = nextChildren.length; - var commonLength = lastChildrenLength > nextChildrenLength ? nextChildrenLength : lastChildrenLength; - var i = 0; - - for (; i < commonLength; i++) { - var lastChild = lastChildren[i]; - var nextChild = normaliseChild(nextChildren, i); - - patch(lastChild, nextChild, dom, lifecycle, context, instance, isSVG); - } - if (lastChildrenLength < nextChildrenLength) { - for (i = commonLength; i < nextChildrenLength; i++) { - var child = normaliseChild(nextChildren, i); - - insertOrAppend(dom, mount(child, null, lifecycle, context, instance, isSVG), parentVList && parentVList.pointer); - } - } else if (lastChildrenLength > nextChildrenLength) { - for (i = commonLength; i < lastChildrenLength; i++) { - remove(lastChildren[i], dom); - } - } - } - - function patchVFragment(lastVFragment, nextVFragment) { - nextVFragment.dom = lastVFragment.dom; - } - - function patchVText(lastVText, nextVText) { - var nextText = nextVText.text; - var dom = lastVText.dom; - - nextVText.dom = dom; - if (lastVText.text !== nextText) { - dom.nodeValue = nextText; - } - } - - function patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, parentVList) { - var lastChildrenLength = lastChildren.length; - var nextChildrenLength = nextChildren.length; - var lastEndIndex = lastChildrenLength - 1; - var nextEndIndex = nextChildrenLength - 1; - var lastStartIndex = 0; - var nextStartIndex = 0; - var lastStartNode = null; - var nextStartNode = null; - var nextEndNode = null; - var lastEndNode = null; - var nextNode; - - while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { - nextStartNode = nextChildren[nextStartIndex]; - lastStartNode = lastChildren[lastStartIndex]; - - if (nextStartNode.key !== lastStartNode.key) { - break; - } - patchVNode(lastStartNode, nextStartNode, dom, lifecycle, context, instance, isSVG, false); - nextStartIndex++; - lastStartIndex++; - } - while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { - nextEndNode = nextChildren[nextEndIndex]; - lastEndNode = lastChildren[lastEndIndex]; - - if (nextEndNode.key !== lastEndNode.key) { - break; - } - patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); - nextEndIndex--; - lastEndIndex--; - } - while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { - nextEndNode = nextChildren[nextEndIndex]; - lastStartNode = lastChildren[lastStartIndex]; - - if (nextEndNode.key !== lastStartNode.key) { - break; - } - nextNode = (nextEndIndex + 1 < nextChildrenLength) ? nextChildren[nextEndIndex + 1].dom : null; - patchVNode(lastStartNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); - insertOrAppend(dom, nextEndNode.dom, nextNode); - nextEndIndex--; - lastStartIndex++; - } - while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { - nextStartNode = nextChildren[nextStartIndex]; - lastEndNode = lastChildren[lastEndIndex]; - - if (nextStartNode.key !== lastEndNode.key) { - break; - } - nextNode = lastChildren[lastStartIndex].dom; - patchVNode(lastEndNode, nextStartNode, dom, lifecycle, context, instance, isSVG, false); - insertOrAppend(dom, nextStartNode.dom, nextNode); - nextStartIndex++; - lastEndIndex--; - } - - if (lastStartIndex > lastEndIndex) { - if (nextStartIndex <= nextEndIndex) { - nextNode = (nextEndIndex + 1 < nextChildrenLength) ? nextChildren[nextEndIndex + 1].dom : parentVList && parentVList.pointer; - for (; nextStartIndex <= nextEndIndex; nextStartIndex++) { - insertOrAppend(dom, mount(nextChildren[nextStartIndex], null, lifecycle, context, instance, isSVG), nextNode); - } - } - } else if (nextStartIndex > nextEndIndex) { - while (lastStartIndex <= lastEndIndex) { - remove(lastChildren[lastStartIndex++], dom); - } - } else { - var aLength = lastEndIndex - lastStartIndex + 1; - var bLength = nextEndIndex - nextStartIndex + 1; - var sources = new Array(bLength); - - // Mark all nodes as inserted. - var i; - for (i = 0; i < bLength; i++) { - sources[i] = -1; - } - var moved = false; - var removeOffset = 0; - var lastTarget = 0; - var index; - var removed = true; - var k = 0; - - if ((bLength <= 4) || (aLength * bLength <= 16)) { - for (i = lastStartIndex; i <= lastEndIndex; i++) { - removed = true; - lastEndNode = lastChildren[i]; - if (k < bLength) { - for (index = nextStartIndex; index <= nextEndIndex; index++) { - nextEndNode = nextChildren[index]; - if (lastEndNode.key === nextEndNode.key) { - sources[index - nextStartIndex] = i; - - if (lastTarget > index) { - moved = true; - } else { - lastTarget = index; - } - patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); - k++; - removed = false; - break; - } - } - } - if (removed) { - remove(lastEndNode, dom); - removeOffset++; - } - } - } else { - var prevItemsMap = new Map(); - - for (i = nextStartIndex; i <= nextEndIndex; i++) { - prevItemsMap.set(nextChildren[i].key, i); - } - for (i = lastStartIndex; i <= lastEndIndex; i++) { - removed = true; - lastEndNode = lastChildren[i]; - - if (k < nextChildrenLength) { - index = prevItemsMap.get(lastEndNode.key); - - if (index !== undefined) { - nextEndNode = nextChildren[index]; - sources[index - nextStartIndex] = i; - if (lastTarget > index) { - moved = true; - } else { - lastTarget = index; - } - patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); - k++; - removed = false; - } - } - if (removed) { - remove(lastEndNode, dom); - removeOffset++; - } - } - } - - var pos; - if (moved) { - var seq = lis_algorithm(sources); - index = seq.length - 1; - for (i = bLength - 1; i >= 0; i--) { - if (sources[i] === -1) { - pos = i + nextStartIndex; - nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; - insertOrAppend(dom, mount(nextChildren[pos], null, lifecycle, context, instance, isSVG), nextNode); - } else { - if (index < 0 || i !== seq[index]) { - pos = i + nextStartIndex; - nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; - insertOrAppend(dom, nextChildren[pos].dom, nextNode); - } else { - index--; - } - } - } - } else if (aLength - removeOffset !== bLength) { - for (i = bLength - 1; i >= 0; i--) { - if (sources[i] === -1) { - pos = i + nextStartIndex; - nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; - insertOrAppend(dom, mount(nextChildren[pos], null, lifecycle, context, instance, isSVG), nextNode); - } - } - } - } - } - - // https://en.wikipedia.org/wiki/Longest_increasing_subsequence - function lis_algorithm(a) { - var p = a.slice(0); - var result = []; - result.push(0); - var i; - var j; - var u; - var v; - var c; - - for (i = 0; i < a.length; i++) { - if (a[i] === -1) { - continue; - } - - j = result[result.length - 1]; - if (a[j] < a[i]) { - p[i] = j; - result.push(i); - continue; - } - - u = 0; - v = result.length - 1; - - while (u < v) { - c = ((u + v) / 2) | 0; - if (a[result[c]] < a[i]) { - u = c + 1; - } else { - v = c; - } - } - - if (a[i] < a[result[u]]) { - if (u > 0) { - p[i] = result[u - 1]; - } - result[u] = i; - } - } - - u = result.length; - v = result[u - 1]; - - while (u-- > 0) { - result[u] = v; - v = p[v]; - } - - return result; - } - - var screenWidth = isBrowser && window.screen.width; - var screenHeight = isBrowser && window.screen.height; - var scrollX = 0; - var scrollY = 0; - var lastScrollTime = 0; - - if (isBrowser) { - window.onscroll = function () { - scrollX = window.scrollX; - scrollY = window.scrollY; - lastScrollTime = performance.now(); - }; - - window.resize = function () { - scrollX = window.scrollX; - scrollY = window.scrollY; - screenWidth = window.screen.width; - screenHeight = window.screen.height; - lastScrollTime = performance.now(); - }; - } - - function Lifecycle() { - this._listeners = []; - this.scrollX = null; - this.scrollY = null; - this.screenHeight = screenHeight; - this.screenWidth = screenWidth; - } - - Lifecycle.prototype = { - refresh: function refresh() { - this.scrollX = isBrowser && window.scrollX; - this.scrollY = isBrowser && window.scrollY; - }, - addListener: function addListener(callback) { - this._listeners.push(callback); - }, - trigger: function trigger() { - var this$1 = this; - - for (var i = 0; i < this._listeners.length; i++) { - this$1._listeners[i](); - } - } - }; - - function handleLazyAttached(node, lifecycle, dom) { - lifecycle.addListener(function () { - var rect = dom.getBoundingClientRect(); - - if (lifecycle.scrollY === null) { - lifecycle.refresh(); - } - node.clipData = { - top: rect.top + lifecycle.scrollY, - left: rect.left + lifecycle.scrollX, - bottom: rect.bottom + lifecycle.scrollY, - right: rect.right + lifecycle.scrollX, - pending: false - }; - }); - } - - function hydrateChild(child, childNodes, counter, parentDom, lifecycle, context, instance) { - var domNode = childNodes[counter.i]; - - if (isVText(child)) { - var text = child.text; - - child.dom = domNode; - if (domNode.nodeType === 3 && text !== '') { - domNode.nodeValue = text; - } else { - var newDomNode = mountVText(text); - - replaceNode(parentDom, newDomNode, domNode); - childNodes.splice(childNodes.indexOf(domNode), 1, newDomNode); - child.dom = newDomNode; - } - } else if (isVPlaceholder(child)) { - child.dom = domNode; - } else if (isVList(child)) { - var items = child.items; - - // this doesn't really matter, as it won't be used again, but it's what it should be given the purpose of VList - child.dom = document.createDocumentFragment(); - for (var i = 0; i < items.length; i++) { - var rebuild = hydrateChild(normaliseChild(items, i), childNodes, counter, parentDom, lifecycle, context, instance); - - if (rebuild) { - return true; - } - } - // at the end of every VList, there should be a "pointer". It's an empty TextNode used for tracking the VList - var pointer = childNodes[counter.i++]; - - if (pointer && pointer.nodeType === 3) { - child.pointer = pointer; - } else { - // there is a problem, we need to rebuild this tree - return true; - } - } else { - var rebuild$1 = hydrateNode(child, domNode, parentDom, lifecycle, context, instance, false); - - if (rebuild$1) { - return true; - } - } - counter.i++; - } - - function getChildNodesWithoutComments(domNode) { - var childNodes = []; - var rawChildNodes = domNode.childNodes; - var length = rawChildNodes.length; - var i = 0; - - while (i < length) { - var rawChild = rawChildNodes[i]; - - if (rawChild.nodeType === 8) { - if (rawChild.data === '!') { - var placeholder = document.createTextNode(''); - - domNode.replaceChild(placeholder, rawChild); - childNodes.push(placeholder); - i++; - } else { - domNode.removeChild(rawChild); - length--; - } - } else { - childNodes.push(rawChild); - i++; - } - } - return childNodes; - } - - function hydrateComponent(node, Component, props, hooks, children, domNode, parentDom, lifecycle, context, lastInstance, isRoot) { - props = addChildrenToProps(children, props); - - if (isStatefulComponent(Component)) { - var instance = node.instance = new Component(props); - - instance._patch = patch; - if (!isNullOrUndefined(lastInstance) && props.ref) { - mountRef(lastInstance, props.ref, instance); - } - var childContext = instance.getChildContext(); - - if (!isNullOrUndefined(childContext)) { - context = Object.assign({}, context, childContext); - } - instance.context = context; - instance._unmounted = false; - instance._parentNode = node; - if (lastInstance) { - instance._parentComponent = lastInstance; - } - instance._pendingSetState = true; - instance.componentWillMount(); - var nextNode = instance.render(); - - instance._pendingSetState = false; - if (isInvalidNode(nextNode)) { - nextNode = createVPlaceholder(); - } - hydrateNode(nextNode, domNode, parentDom, lifecycle, context, instance, isRoot); - instance._lastNode = nextNode; - instance.componentDidMount(); - - } else { - var instance$1 = node.instance = Component(props); - - if (!isNullOrUndefined(hooks)) { - if (!isNullOrUndefined(hooks.componentWillMount)) { - hooks.componentWillMount(null, props); - } - if (!isNullOrUndefined(hooks.componentDidMount)) { - lifecycle.addListener(function () { - hooks.componentDidMount(domNode, props); - }); - } - } - return hydrateNode(instance$1, domNode, parentDom, lifecycle, context, instance$1, isRoot); - } - } - - function hydrateNode(node, domNode, parentDom, lifecycle, context, instance, isRoot) { - var bp = node.bp; - var tag = node.tag || bp.tag; - - if (isFunction(tag)) { - node.dom = domNode; - hydrateComponent(node, tag, node.attrs || {}, node.hooks, node.children, domNode, parentDom, lifecycle, context, instance, isRoot); - } else { - if ( - domNode.nodeType !== 1 || - tag !== domNode.tagName.toLowerCase() - ) { - // TODO remake node - } else { - node.dom = domNode; - var hooks = node.hooks; - - if ((bp && bp.hasHooks === true) || !isNullOrUndefined(hooks)) { - handleAttachedHooks(hooks, lifecycle, domNode); - } - var children = node.children; - - if (!isNullOrUndefined(children)) { - if (isStringOrNumber(children)) { - if (domNode.textContent !== children) { - domNode.textContent = children; - } - } else { - var childNodes = getChildNodesWithoutComments(domNode); - var counter = { i: 0 }; - var rebuild = false; - - if (isArray(children)) { - for (var i = 0; i < children.length; i++) { - rebuild = hydrateChild(normaliseChild(children, i), childNodes, counter, domNode, lifecycle, context, instance); - - if (rebuild) { - break; - } - } - } else { - if (childNodes.length === 1) { - rebuild = hydrateChild(children, childNodes, counter, domNode, lifecycle, context, instance); - } else { - rebuild = true; - } - } - - if (rebuild) { - // TODO scrap children and rebuild again - } - } - } - var className = node.className; - var style = node.style; - - if (!isNullOrUndefined(className)) { - domNode.className = className; - } - if (!isNullOrUndefined(style)) { - patchStyle(null, style, domNode); - } - if (bp && bp.hasAttrs === true) { - mountBlueprintAttrs(node, bp, domNode, instance); - } else { - var attrs = node.attrs; - - if (!isNullOrUndefined(attrs)) { - handleSelects(node); - mountAttributes(node, attrs, Object.keys(attrs), domNode, instance); - } - } - if (bp && bp.hasEvents === true) { - mountBlueprintEvents(node, bp, domNode); - } else { - var events = node.events; - - if (!isNullOrUndefined(events)) { - mountEvents(events, Object.keys(events), domNode); - } - } - } - } - } - var documetBody = isBrowser ? document.body : null; - - function hydrate(node, parentDom, lifecycle) { - if (parentDom && parentDom.nodeType === 1) { - var rootNode = parentDom.querySelector('[data-infernoroot]'); - - if (rootNode && rootNode.parentNode === parentDom) { - hydrateNode(node, rootNode, parentDom, lifecycle, {}, true); - return true; - } - } - // clear parentDom, unless it's document.body - if (parentDom !== documetBody) { - parentDom.textContent = ''; - } else { - console.warn('Inferno Warning: rendering to the "document.body" is dangerous! Use a dedicated container element instead.'); - } - return false; - } - - var roots = new Map(); - var componentToDOMNodeMap = new Map(); - - function findDOMNode(domNode) { - return componentToDOMNodeMap.get(domNode) || null; - } - - function render(input, parentDom) { - var root = roots.get(parentDom); - var lifecycle = new Lifecycle(); - - if (isUndefined(root)) { - if (!isInvalidNode(input)) { - if (!hydrate(input, parentDom, lifecycle)) { - mount(input, parentDom, lifecycle, {}, null, false); - } - lifecycle.trigger(); - roots.set(parentDom, { input: input }); - } - } else { - var activeNode = getActiveNode(); - var nextInput = patch(root.input, input, parentDom, lifecycle, {}, null, false); - - lifecycle.trigger(); - if (isNull(input)) { - roots.delete(parentDom); - } - root.input = nextInput; - resetActiveNode(activeNode); - } - } - - function createAttrsAndEvents(props, tag) { - var events = null; - var hooks = null; - var attrs = null; - var className = null; - var style = null; - - if (!isNullOrUndefined(props)) { - if (isArray(props)) { - return props; - } - for (var prop in props) { - if (prop === 'className') { - className = props[prop]; - } else if (prop === 'style') { - style = props[prop]; - } else if (isAttrAHook(prop) && !isFunction(tag)) { - if (isNullOrUndefined(hooks)) { - hooks = {}; - } - hooks[prop.substring(2).toLowerCase()] = props[prop]; - delete props[prop]; - } else if (isAttrAnEvent(prop) && !isFunction(tag)) { - if (isNullOrUndefined(events)) { - events = {}; - } - events[prop.toLowerCase()] = props[prop]; - delete props[prop]; - } else if (isAttrAComponentHook(prop) && isFunction(tag)) { - if (isNullOrUndefined(hooks)) { - hooks = {}; - } - hooks['c' + prop.substring(3)] = props[prop]; - delete props[prop]; - } else if (!isFunction(tag)) { - if (isNullOrUndefined(attrs)) { - attrs = {}; - } - attrs[prop] = props[prop]; - } else { - attrs = props; - } - } - } - return { attrs: attrs, events: events, className: className, style: style, hooks: hooks }; - } - - function createChild(ref) { - var tag = ref.tag; - var attrs = ref.attrs; - var children = ref.children; - var className = ref.className; - var style = ref.style; - var events = ref.events; - var hooks = ref.hooks; - - if (tag === undefined && !isNullOrUndefined(attrs) && !attrs.tpl && !isNullOrUndefined(children) && children.length === 0) { - return null; - } - var key = !isNullOrUndefined(attrs) && !isNullOrUndefined(attrs.key) ? attrs.key : undefined; - - if (!isNullOrUndefined(children) && children.length === 0) { - children = null; - } else if (!isInvalidNode(children)) { - children = isArray(children) && children.length === 1 ? createChildren(children[0]) : createChildren(children); - } - - if (key !== undefined) { - delete attrs.key; - } - var attrsAndEvents = createAttrsAndEvents(attrs, tag); - var vNode = createVNode(); - - className = className || attrsAndEvents.className; - style = style || attrsAndEvents.style; - - vNode.tag = tag || null; - vNode.attrs = attrsAndEvents.attrs || null; - vNode.events = attrsAndEvents.events || events; - vNode.hooks = attrsAndEvents.hooks || hooks; - vNode.children = children === undefined ? null : children; - vNode.key = key === undefined ? null : key; - vNode.className = className === undefined ? null : className; - vNode.style = style === undefined ? null : style; - - return vNode; - } - - function createChildren(children) { - var childrenDefined = !isNullOrUndefined(children); - if (childrenDefined && isArray(children)) { - var newChildren = []; - - for (var i = 0; i < children.length; i++) { - var child = children[i]; - if (!isNullOrUndefined(child) && typeof child === 'object') { - if (isArray(child)) { - if (child.length > 0) { - newChildren.push(createChildren(child)); - } else { - newChildren.push(null); - } - } else { - newChildren.push(createChild(child)); - } - } else { - newChildren.push(child); - } - } - return newChildren; - } else if (childrenDefined && typeof children === 'object') { - return children.dom === undefined ? createChild(children) : children; - } - return children; - } - - function createElement(tag, props) { - var children = [], len = arguments.length - 2; - while ( len-- > 0 ) children[ len ] = arguments[ len + 2 ]; - - return createChild({ tag: tag, attrs: props, children: children }); - } - - var noOp = 'Inferno Error: Can only update a mounted or mounting component. This usually means you called setState() or forceUpdate() on an unmounted component. This is a no-op.'; - - // Copy of the util from dom/util, otherwise it makes massive bundles - function getActiveNode$1() { - return document.activeElement; - } - - // Copy of the util from dom/util, otherwise it makes massive bundles - function resetActiveNode$1(activeNode) { - if (activeNode !== document.body && document.activeElement !== activeNode) { - activeNode.focus(); // TODO: verify are we doing new focus event, if user has focus listener this might trigger it - } - } - - function queueStateChanges(component, newState, callback) { - for (var stateKey in newState) { - component._pendingState[stateKey] = newState[stateKey]; - } - if (!component._pendingSetState) { - component._pendingSetState = true; - applyState(component, false, callback); - } else { - component.state = Object.assign({}, component.state, component._pendingState); - component._pendingState = {}; - } - } - - function applyState(component, force, callback) { - if ((!component._deferSetState || force) && !component._blockRender) { - component._pendingSetState = false; - var pendingState = component._pendingState; - var prevState = component.state; - var nextState = Object.assign({}, prevState, pendingState); - var props = component.props; - - component._pendingState = {}; - var nextNode = component._updateComponent(prevState, nextState, props, props, force); - - if (nextNode === NO_RENDER) { - nextNode = component._lastNode; - } else if (isNullOrUndefined(nextNode)) { - nextNode = createVPlaceholder(); - } - var lastNode = component._lastNode; - var parentDom = lastNode.dom.parentNode; - var activeNode = getActiveNode$1(); - var subLifecycle = new Lifecycle(); - - component._patch(lastNode, nextNode, parentDom, subLifecycle, component.context, component, null); - component._lastNode = nextNode; - component._componentToDOMNodeMap.set(component, nextNode.dom); - component._parentNode.dom = nextNode.dom; - component.componentDidUpdate(props, prevState); - subLifecycle.trigger(); - if (!isNullOrUndefined(callback)) { - callback(); - } - resetActiveNode$1(activeNode); - } +}(this, (function (exports) { 'use strict'; + +function addChildrenToProps(children, props) { + if (!isNullOrUndefined(children)) { + var isChildrenArray = isArray(children); + if (isChildrenArray && children.length > 0 || !isChildrenArray) { + if (props) { + props = Object.assign({}, props, { children: children }); + } else { + props = { + children: children + }; + } + } + } + return props; +} + +var NO_RENDER = 'NO_RENDER'; + +// Runs only once in applications lifetime +var isBrowser = typeof window !== 'undefined' && window.document; + +function isArray(obj) { + return obj instanceof Array; +} + +function isStatefulComponent(obj) { + return obj.prototype && obj.prototype.render !== undefined; +} + +function isStringOrNumber(obj) { + return isString(obj) || isNumber(obj); +} + +function isNullOrUndefined(obj) { + return isUndefined(obj) || isNull(obj); +} + +function isInvalidNode(obj) { + return isNull(obj) || obj === false || obj === true || isUndefined(obj); +} + +function isFunction(obj) { + return typeof obj === 'function'; +} + +function isAttrAnEvent(attr) { + return attr[0] === 'o' && attr[1] === 'n' && attr.length > 3; +} + +function isString(obj) { + return typeof obj === 'string'; +} + +function isNumber(obj) { + return typeof obj === 'number'; +} + +function isNull(obj) { + return obj === null; +} + +function isTrue(obj) { + return obj === true; +} + +function isUndefined(obj) { + return obj === undefined; +} + +function isAttrAHook(hook) { + return hook === 'onCreated' + || hook === 'onAttached' + || hook === 'onWillDetach' + || hook === 'onWillUpdate' + || hook === 'onDidUpdate'; +} + +function isAttrAComponentHook(hook) { + return hook === 'onComponentWillMount' + || hook === 'onComponentDidMount' + || hook === 'onComponentWillUnmount' + || hook === 'onComponentShouldUpdate' + || hook === 'onComponentWillUpdate' + || hook === 'onComponentDidUpdate'; +} + +function deepScanChildrenForNode(children, node) { + if (!isInvalidNode(children)) { + if (isArray(children)) { + for (var i = 0; i < children.length; i++) { + var child = children[i]; + + if (!isInvalidNode(child)) { + if (child === node) { + return true; + } else if (child.children) { + return deepScanChildrenForNode(child.children, node); + } + } + } + } else { + if (children === node) { + return true; + } else if (children.children) { + return deepScanChildrenForNode(children.children, node); + } + } + } + return false; +} + +function getRefInstance$1(node, instance) { + var children = instance.props.children; + + if (deepScanChildrenForNode(children, node)) { + return getRefInstance$1(node, instance._parentComponent); + } + return instance; +} + +var recyclingEnabled = true; + +function recycle(node, bp, lifecycle, context, instance) { + if (bp !== undefined) { + var pool = bp.pool; + var recycledNode = pool.pop(); + + if (!isNullOrUndefined(recycledNode)) { + patch(recycledNode, node, null, lifecycle, context, instance, bp.isSVG); + return node.dom; + } + } + return null; +} + +function pool(node) { + var bp = node.bp; + + if (!isNullOrUndefined(bp)) { + bp.pool.push(node); + return true; + } + return false; +} + +function unmount(input, parentDom) { + if (isVList(input)) { + unmountVList(input, parentDom, true); + } else if (isVNode(input)) { + unmountVNode(input, parentDom, false); + } +} + +function unmountVList(vList, parentDom, removePointer) { + var items = vList.items; + var itemsLength = items.length; + var pointer = vList.pointer; + + if (itemsLength > 0) { + for (var i = 0; i < itemsLength; i++) { + var item = items[i]; + + if (isVList(item)) { + unmountVList(item, parentDom, true); + } else { + if (parentDom) { + removeChild(parentDom, item.dom); + } + unmount(item, null); + } + } + } + if (parentDom && removePointer) { + removeChild(parentDom, pointer); + } +} + +function unmountVNode(node, parentDom, shallow) { + var instance = node.instance; + var instanceHooks = null; + var instanceChildren = null; + + if (!isNullOrUndefined(instance)) { + instanceHooks = instance.hooks; + instanceChildren = instance.children; + + if (instance.render !== undefined) { + instance.componentWillUnmount(); + instance._unmounted = true; + componentToDOMNodeMap.delete(instance); + !shallow && unmount(instance._lastNode, null); + } + } + var hooks = node.hooks || instanceHooks; + + if (!isNullOrUndefined(hooks)) { + if (!isNullOrUndefined(hooks.willDetach)) { + hooks.willDetach(node.dom); + } + if (!isNullOrUndefined(hooks.componentWillUnmount)) { + hooks.componentWillUnmount(node.dom, hooks); + } + } + var children = (isNullOrUndefined(instance) ? node.children : null) || instanceChildren; + + if (!isNullOrUndefined(children)) { + if (isArray(children)) { + for (var i = 0; i < children.length; i++) { + unmount(children[i], null); + } + } else { + unmount(children, null); + } + } +} + +function VNode(blueprint) { + this.bp = blueprint; + this.dom = null; + this.instance = null; + this.tag = null; + this.children = null; + this.style = null; + this.className = null; + this.attrs = null; + this.events = null; + this.hooks = null; + this.key = null; + this.clipData = null; +} + +VNode.prototype = { + setAttrs: function setAttrs(attrs) { + this.attrs = attrs; + return this; + }, + setTag: function setTag(tag) { + this.tag = tag; + return this; + }, + setStyle: function setStyle(style) { + this.style = style; + return this; + }, + setClassName: function setClassName(className) { + this.className = className; + return this; + }, + setChildren: function setChildren(children) { + this.children = children; + return this; + }, + setHooks: function setHooks(hooks) { + this.hooks = hooks; + return this; + }, + setEvents: function setEvents(events) { + this.events = events; + return this; + }, + setKey: function setKey(key) { + this.key = key; + return this; + } +}; + +function createVNode(bp) { + return new VNode(bp); +} + +function isAttrAnEvent$1(attr) { + return attr[0] === 'o' && attr[1] === 'n' && attr.length > 3; +} + +function isAttrAHook$1(hook) { + return hook === 'onCreated' + || hook === 'onAttached' + || hook === 'onWillDetach' + || hook === 'onWillUpdate' + || hook === 'onDidUpdate'; +} + +function isAttrAComponentHook$1(hook) { + return hook === 'onComponentWillMount' + || hook === 'onComponentDidMount' + || hook === 'onComponentWillUnmount' + || hook === 'onComponentShouldUpdate' + || hook === 'onComponentWillUpdate' + || hook === 'onComponentDidUpdate'; +} + + +function createBlueprint(shape, childrenType) { + var tag = shape.tag || null; + var tagIsDynamic = tag && tag.arg !== undefined ? true : false; + + var children = isNullOrUndefined(shape.children) ? null : shape.children; + var childrenIsDynamic = children && children.arg !== undefined ? true : false; + + var attrs = shape.attrs || null; + var attrsIsDynamic = attrs && attrs.arg !== undefined ? true : false; + + var hooks = shape.hooks || null; + var hooksIsDynamic = hooks && hooks.arg !== undefined ? true : false; + + var events = shape.events || null; + var eventsIsDynamic = events && events.arg !== undefined ? true : false; + + var key = shape.key === undefined ? null : shape.key; + var keyIsDynamic = !isNullOrUndefined(key) && !isNullOrUndefined(key.arg); + + var style = shape.style || null; + var styleIsDynamic = style && style.arg !== undefined ? true : false; + + var className = shape.className === undefined ? null : shape.className; + var classNameIsDynamic = className && className.arg !== undefined ? true : false; + + var spread = shape.spread === undefined ? null : shape.spread; + var hasSpread = shape.spread !== undefined; + + var blueprint = { + lazy: shape.lazy || false, + dom: null, + pool: [], + tag: tagIsDynamic ? null : tag, + className: className !== '' && className ? className : null, + style: style !== '' && style ? style : null, + isComponent: tagIsDynamic, + hasAttrs: attrsIsDynamic || (attrs ? true : false), + hasHooks: hooksIsDynamic, + hasEvents: eventsIsDynamic, + hasStyle: styleIsDynamic || (style !== '' && style ? true : false), + hasClassName: classNameIsDynamic || (className !== '' && className ? true : false), + childrenType: childrenType === undefined ? (children ? 5 : 0) : childrenType, + attrKeys: null, + eventKeys: null, + isSVG: shape.isSVG || false + }; + + return function () { + var vNode = new VNode(blueprint); + + if (tagIsDynamic === true) { + vNode.tag = arguments[tag.arg]; + } + if (childrenIsDynamic === true) { + vNode.children = arguments[children.arg]; + } + if (hasSpread) { + var _spread = arguments[spread.arg]; + var attrs$1; + var events$1; + var hooks$1; + var attrKeys = []; + var eventKeys = []; + + for (var prop in _spread) { + var value = _spread[prop]; + + if (prop === 'className' || (prop === 'class' && !blueprint.isSVG)) { + vNode.className = value; + blueprint.hasClassName = true; + } else if (prop === 'style') { + vNode.style = value; + blueprint.hasStyle = true; + } else if (prop === 'key') { + vNode.key = value; + } else if (isAttrAHook$1(prop) || isAttrAComponentHook$1(prop)) { + if (!hooks$1) { + hooks$1 = {}; + } + hooks$1[prop[2].toLowerCase() + prop.substring(3)] = value; + } else if (isAttrAnEvent$1(prop)) { + if (!events$1) { + events$1 = {}; + } + eventKeys.push(prop.toLowerCase()); + events$1[prop.toLowerCase()] = value; + } else if (prop === 'children') { + vNode.children = value; + blueprint.childrenType = blueprint.childrenType || 5; + } else { + if (!attrs$1) { + attrs$1 = {}; + } + attrKeys.push(prop); + attrs$1[prop] = value; + } + } + if (attrs$1) { + vNode.attrs = attrs$1; + blueprint.attrKeys = attrKeys; + blueprint.hasAttrs = true; + } + if (events$1) { + vNode.events = events$1; + blueprint.eventKeys = eventKeys; + blueprint.hasEvents = true; + } + if (hooks$1) { + vNode.hooks = hooks$1; + blueprint.hasHooks = true; + } + } else { + if (attrsIsDynamic === true) { + vNode.attrs = arguments[attrs.arg]; + } else { + vNode.attrs = attrs; + } + if (hooksIsDynamic === true) { + vNode.hooks = arguments[hooks.arg]; + } + if (eventsIsDynamic === true) { + vNode.events = arguments[events.arg]; + } + if (keyIsDynamic === true) { + vNode.key = arguments[key.arg]; + } else { + vNode.key = key; + } + if (styleIsDynamic === true) { + vNode.style = arguments[style.arg]; + } else { + vNode.style = blueprint.style; + } + if (classNameIsDynamic === true) { + vNode.className = arguments[className.arg]; + } else { + vNode.className = blueprint.className; + } + } + return vNode; + }; +} + +function VText(text) { + this.text = text; + this.dom = null; +} + +function VPlaceholder() { + this.placeholder = true; + this.dom = null; +} + +function VList(items) { + this.dom = null; + this.pointer = null; + this.items = items; +} + +function createVText(text) { + return new VText(text); +} + +function createVPlaceholder() { + return new VPlaceholder(); +} + +function createVList(items) { + return new VList(items); +} + +function constructDefaults(string, object, value) { + /* eslint no-return-assign: 0 */ + string.split(',').forEach(function (i) { return object[i] = value; }); +} + +var xlinkNS = 'http://www.w3.org/1999/xlink'; +var xmlNS = 'http://www.w3.org/XML/1998/namespace'; +var strictProps = {}; +var booleanProps = {}; +var namespaces = {}; +var isUnitlessNumber = {}; + +constructDefaults('xlink:href,xlink:arcrole,xlink:actuate,xlink:role,xlink:titlef,xlink:type', namespaces, xlinkNS); +constructDefaults('xml:base,xml:lang,xml:space', namespaces, xmlNS); +constructDefaults('volume,value', strictProps, true); +constructDefaults('muted,scoped,loop,open,checked,default,capture,disabled,selected,readonly,multiple,required,autoplay,controls,seamless,reversed,allowfullscreen,novalidate', booleanProps, true); +constructDefaults('animationIterationCount,borderImageOutset,borderImageSlice,borderImageWidth,boxFlex,boxFlexGroup,boxOrdinalGroup,columnCount,flex,flexGrow,flexPositive,flexShrink,flexNegative,flexOrder,gridRow,gridColumn,fontWeight,lineClamp,lineHeight,opacity,order,orphans,tabSize,widows,zIndex,zoom,fillOpacity,floodOpacity,stopOpacity,strokeDasharray,strokeDashoffset,strokeMiterlimit,strokeOpacity,strokeWidth,', isUnitlessNumber, true); + +function isVText(o) { + return o.text !== undefined; +} + +function isVPlaceholder(o) { + return o.placeholder === true; +} + +function isVList(o) { + return o.items !== undefined; +} + +function isVNode(o) { + return o.tag !== undefined || o.bp !== undefined; +} + +function insertOrAppend(parentDom, newNode, nextNode) { + if (isNullOrUndefined(nextNode)) { + parentDom.appendChild(newNode); + } else { + parentDom.insertBefore(newNode, nextNode); + } +} + +function replaceVListWithNode(parentDom, vList, dom) { + var pointer = vList.pointer; + + unmountVList(vList, parentDom, false); + replaceNode(parentDom, dom, pointer); +} + +function documentCreateElement(tag, isSVG) { + var dom; + + if (isSVG === true) { + dom = document.createElementNS('http://www.w3.org/2000/svg', tag); + } else { + dom = document.createElement(tag); + } + return dom; +} + +function appendText(text, parentDom, singleChild) { + if (parentDom === null) { + return document.createTextNode(text); + } else { + if (singleChild) { + if (text !== '') { + parentDom.textContent = text; + return parentDom.firstChild; + } else { + var textNode = document.createTextNode(''); + + parentDom.appendChild(textNode); + return textNode; + } + } else { + var textNode$1 = document.createTextNode(text); + + parentDom.appendChild(textNode$1); + return textNode$1; + } + } +} + +function replaceWithNewNode(lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG) { + var lastInstance = null; + var instanceLastNode = lastNode._lastNode; + + if (!isNullOrUndefined(instanceLastNode)) { + lastInstance = lastNode; + lastNode = instanceLastNode; + } + unmount(lastNode, false); + var dom = mount(nextNode, null, lifecycle, context, instance, isSVG); + + nextNode.dom = dom; + replaceNode(parentDom, dom, lastNode.dom); + if (lastInstance !== null) { + lastInstance._lastNode = nextNode; + } +} + +function replaceNode(parentDom, nextDom, lastDom) { + parentDom.replaceChild(nextDom, lastDom); +} + +function normalise(object) { + if (isStringOrNumber(object)) { + return createVText(object); + } else if (isInvalidNode(object)) { + return createVPlaceholder(); + } else if (isArray(object)) { + return createVList(object); + } + return object; +} + +function normaliseChild(children, i) { + var child = children[i]; + + return children[i] = normalise(child); +} + +function remove(node, parentDom) { + if (isVList(node)) { + return unmount(node, parentDom); + } + var dom = node.dom; + if (dom === parentDom) { + dom.innerHTML = ''; + } else { + removeChild(parentDom, dom); + if (recyclingEnabled) { + pool(node); + } + } + unmount(node, false); +} + +function removeChild(parentDom, dom) { + parentDom.removeChild(dom); +} + +function removeEvents(events, lastEventKeys, dom) { + var eventKeys = lastEventKeys || Object.keys(events); + + for (var i = 0; i < eventKeys.length; i++) { + var event = eventKeys[i]; + + dom[event] = null; + } +} + +// TODO: for node we need to check if document is valid +function getActiveNode() { + return document.activeElement; +} + +function removeAllChildren(dom, children) { + if (recyclingEnabled) { + var childrenLength = children.length; + + if (childrenLength > 5) { + for (var i = 0; i < childrenLength; i++) { + var child = children[i]; + + if (!isInvalidNode(child)) { + pool(child); + } + } + } + } + dom.textContent = ''; +} + +function resetActiveNode(activeNode) { + if (activeNode !== null && activeNode !== document.body && document.activeElement !== activeNode) { + activeNode.focus(); // TODO: verify are we doing new focus event, if user has focus listener this might trigger it + } +} + +function isKeyed(lastChildren, nextChildren) { + if (lastChildren.complex) { + return false; + } + return nextChildren.length && !isNullOrUndefined(nextChildren[0]) && !isNullOrUndefined(nextChildren[0].key) + && lastChildren.length && !isNullOrUndefined(lastChildren[0]) && !isNullOrUndefined(lastChildren[0].key); +} + +function selectOptionValueIfNeeded(vdom, values) { + if (vdom.tag !== 'option') { + for (var i = 0, len = vdom.children.length; i < len; i++) { + selectOptionValueIfNeeded(vdom.children[i], values); + } + // NOTE! Has to be a return here to catch optGroup elements + return; + } + + var value = vdom.attrs && vdom.attrs.value; + + if (values[value]) { + vdom.attrs = vdom.attrs || {}; + vdom.attrs.selected = 'selected'; + vdom.dom.selected = true; + } else { + vdom.dom.selected = false; + } +} + +function selectValue(vdom) { + var value = vdom.attrs && vdom.attrs.value; + + var values = {}; + if (isArray(value)) { + for (var i = 0, len = value.length; i < len; i++) { + values[value[i]] = value[i]; + } + } else { + values[value] = value; + } + for (var i$1 = 0, len$1 = vdom.children.length; i$1 < len$1; i$1++) { + selectOptionValueIfNeeded(vdom.children[i$1], values); + } + + if (vdom.attrs && vdom.attrs[value]) { + delete vdom.attrs.value; // TODO! Avoid deletion here. Set to null or undef. Not sure what you want to usev + } +} + +function handleAttachedHooks(hooks, lifecycle, dom) { + if (!isNullOrUndefined(hooks.created)) { + hooks.created(dom); + } + if (!isNullOrUndefined(hooks.attached)) { + lifecycle.addListener(function () { + hooks.attached(dom); + }); + } +} + +function setValueProperty(nextNode) { + var value = nextNode.attrs.value; + if (!isNullOrUndefined(value)) { + nextNode.dom.value = value; + } +} + +function setFormElementProperties(nextTag, nextNode) { + if (nextTag === 'input' && nextNode.attrs) { + var inputType = nextNode.attrs.type; + if (inputType === 'text') { + setValueProperty(nextNode); + } else if (inputType === 'checkbox' || inputType === 'radio') { + var checked = nextNode.attrs.checked; + nextNode.dom.checked = !!checked; + } + } else if (nextTag === 'textarea') { + setValueProperty(nextNode); + } +} + +function mount(input, parentDom, lifecycle, context, instance, isSVG) { + if (isVPlaceholder(input)) { + return mountVPlaceholder(input, parentDom); + } else if (isVText(input)) { + return mountVText(input, parentDom); + } else if (isVList(input)) { + return mountVList(input, parentDom, lifecycle, context, instance, isSVG); + } else if (isVNode(input)) { + return mountVNode$1(input, parentDom, lifecycle, context, instance, isSVG); + } else { + var normalisedInput = normalise(input); + + if (input !== normalisedInput) { + return mount(normalisedInput, parentDom, lifecycle, context, instance, isSVG); + } else { + throw new Error(("Inferno Error: invalid object \"" + (typeof input) + "\" passed to mount()")); + } + } +} + +function mountVNode$1(vNode, parentDom, lifecycle, context, instance, isSVG) { + var bp = vNode.bp; + + if (isUndefined(bp)) { + return mountVNodeWithoutBlueprint(vNode, parentDom, lifecycle, context, instance, isSVG); + } else { + if (recyclingEnabled) { + var dom = recycle(vNode, bp, lifecycle, context, instance); + + if (!isNull(dom)) { + if (!isNull(parentDom)) { + parentDom.appendChild(dom); + } + return dom; + } + } + return mountVNodeWithBlueprint(vNode, bp, parentDom, lifecycle, context, instance); + } +} + +function mountVList(vList, parentDom, lifecycle, context, instance, isSVG) { + var items = vList.items; + var pointer = document.createTextNode(''); + var dom = document.createDocumentFragment(); + + mountArrayChildren(items, dom, lifecycle, context, instance, isSVG); + vList.pointer = pointer; + vList.dom = dom; + dom.appendChild(pointer); + if (parentDom) { + insertOrAppend(parentDom, dom); + } + return dom; +} + +function mountVText(vText, parentDom) { + var dom = document.createTextNode(vText.text); + + vText.dom = dom; + if (parentDom) { + insertOrAppend(parentDom, dom); + } + return dom; +} + +function mountVPlaceholder(vPlaceholder, parentDom) { + var dom = document.createTextNode(''); + + vPlaceholder.dom = dom; + if (parentDom) { + insertOrAppend(parentDom, dom); + } + return dom; +} + +function handleSelects(node) { + if (node.tag === 'select') { + selectValue(node); + } +} + +function mountBlueprintAttrs(node, bp, dom, instance) { + handleSelects(node); + var attrs = node.attrs; + + if (isNull(bp.attrKeys)) { + var newKeys = Object.keys(attrs); + bp.attrKeys = bp.attrKeys ? bp.attrKeys.concat(newKeys) : newKeys; + } + var attrKeys = bp.attrKeys; + + mountAttributes(node, attrs, attrKeys, dom, instance); +} + +function mountBlueprintEvents(node, bp, dom) { + var events = node.events; + + if (isNull(bp.eventKeys)) { + bp.eventKeys = Object.keys(events); + } + var eventKeys = bp.eventKeys; + + mountEvents(events, eventKeys, dom); +} + +function mountVNodeWithBlueprint(node, bp, parentDom, lifecycle, context, instance) { + var tag = node.tag; + + if (isTrue(bp.isComponent)) { + return mountComponent(node, tag, node.attrs || {}, node.hooks, node.children, instance, parentDom, lifecycle, context); + } + var dom = documentCreateElement(bp.tag, bp.isSVG); + + node.dom = dom; + if (isTrue(bp.hasHooks)) { + handleAttachedHooks(node.hooks, lifecycle, dom); + } + if (isTrue(bp.lazy)) { + handleLazyAttached(node, lifecycle, dom); + } + var children = node.children; + // bp.childrenType: + // 0: no children + // 1: text node + // 2: single child + // 3: multiple children + // 4: multiple children (keyed) + // 5: variable children (defaults to no optimisation) + + switch (bp.childrenType) { + case 1: + appendText(children, dom, true); + break; + case 2: + mount(node.children, dom, lifecycle, context, instance, bp.isSVG); + break; + case 3: + mountArrayChildren(children, dom, lifecycle, context, instance, bp.isSVG); + break; + case 4: + for (var i = 0; i < children.length; i++) { + mount(children[i], dom, lifecycle, context, instance, bp.isSVG); + } + break; + case 5: + mountChildren(node, children, dom, lifecycle, context, instance, bp.isSVG); + break; + default: + break; + } + + if (isTrue(bp.hasAttrs)) { + mountBlueprintAttrs(node, bp, dom, instance); + } + if (isTrue(bp.hasClassName)) { + dom.className = node.className; + } + if (isTrue(bp.hasStyle)) { + patchStyle(null, node.style, dom); + } + if (isTrue(bp.hasEvents)) { + mountBlueprintEvents(node, bp, dom); + } + if (!isNull(parentDom)) { + parentDom.appendChild(dom); + } + return dom; +} + +function mountVNodeWithoutBlueprint(node, parentDom, lifecycle, context, instance, isSVG) { + var tag = node.tag; + + if (isFunction(tag)) { + return mountComponent(node, tag, node.attrs || {}, node.hooks, node.children, instance, parentDom, lifecycle, context); + } + if (!isString(tag) || tag === '') { + throw Error('Inferno Error: Expected function or string for element tag type'); + } + if (tag === 'svg') { + isSVG = true; + } + var dom = documentCreateElement(tag, isSVG); + var children = node.children; + var attrs = node.attrs; + var events = node.events; + var hooks = node.hooks; + var className = node.className; + var style = node.style; + + node.dom = dom; + if (!isNullOrUndefined(hooks)) { + handleAttachedHooks(hooks, lifecycle, dom); + } + if (!isInvalidNode(children)) { + mountChildren(node, children, dom, lifecycle, context, instance, isSVG); + } + if (!isNullOrUndefined(attrs)) { + handleSelects(node); + mountAttributes(node, attrs, Object.keys(attrs), dom, instance); + } + if (!isNullOrUndefined(className)) { + dom.className = className; + } + if (!isNullOrUndefined(style)) { + patchStyle(null, style, dom); + } + if (!isNullOrUndefined(events)) { + mountEvents(events, Object.keys(events), dom); + } + if (!isNull(parentDom)) { + parentDom.appendChild(dom); + } + return dom; +} + +function mountArrayChildren(children, parentDom, lifecycle, context, instance, isSVG) { + children.complex = false; + for (var i = 0; i < children.length; i++) { + var child = normaliseChild(children, i); + + if (isVText(child)) { + mountVText(child, parentDom); + children.complex = true; + } else if (isVPlaceholder(child)) { + mountVPlaceholder(child, parentDom); + children.complex = true; + } else if (isVList(child)) { + mountVList(child, parentDom, lifecycle, context, instance, isSVG); + children.complex = true; + } else { + mount(child, parentDom, lifecycle, context, instance, isSVG); + } + } +} + +function mountChildren(node, children, parentDom, lifecycle, context, instance, isSVG) { + if (isArray(children)) { + mountArrayChildren(children, parentDom, lifecycle, context, instance, isSVG); + } else if (isStringOrNumber(children)) { + appendText(children, parentDom, true); + } else if (!isInvalidNode(children)) { + mount(children, parentDom, lifecycle, context, instance, isSVG); + } +} + +function mountRef(instance, value, refValue) { + if (!isInvalidNode(instance) && isString(value)) { + instance.refs[value] = refValue; + } +} + +function mountEvents(events, eventKeys, dom) { + for (var i = 0; i < eventKeys.length; i++) { + var event = eventKeys[i]; + + dom[event] = events[event]; + } +} + +function mountComponent(parentNode, Component, props, hooks, children, lastInstance, parentDom, lifecycle, context) { + props = addChildrenToProps(children, props); + + var dom; + if (isStatefulComponent(Component)) { + var instance = new Component(props, context); + + instance._patch = patch; + instance._componentToDOMNodeMap = componentToDOMNodeMap; + if (!isNullOrUndefined(lastInstance) && props.ref) { + mountRef(lastInstance, props.ref, instance); + } + var childContext = instance.getChildContext(); + + if (!isNullOrUndefined(childContext)) { + context = Object.assign({}, context, childContext); + } + instance.context = context; + instance._unmounted = false; + instance._parentNode = parentNode; + if (lastInstance) { + instance._parentComponent = lastInstance; + } + instance._pendingSetState = true; + instance.componentWillMount(); + var node = instance.render(); + + if (isInvalidNode(node)) { + node = createVPlaceholder(); + } + instance._pendingSetState = false; + dom = mount(node, null, lifecycle, context, instance, false); + instance._lastNode = node; + instance.componentDidMount(); + if (parentDom !== null && !isInvalidNode(dom)) { + parentDom.appendChild(dom); + } + componentToDOMNodeMap.set(instance, dom); + parentNode.dom = dom; + parentNode.instance = instance; + } else { + if (!isNullOrUndefined(hooks)) { + if (!isNullOrUndefined(hooks.componentWillMount)) { + hooks.componentWillMount(null, props); + } + if (!isNullOrUndefined(hooks.componentDidMount)) { + lifecycle.addListener(function () { + hooks.componentDidMount(dom, props); + }); + } + } + + /* eslint new-cap: 0 */ + var node$1 = Component(props, context); + + if (isInvalidNode(node$1)) { + node$1 = createVPlaceholder(); + } + dom = mount(node$1, null, lifecycle, context, null, false); + + parentNode.instance = node$1; + + if (parentDom !== null && !isInvalidNode(dom)) { + parentDom.appendChild(dom); + } + parentNode.dom = dom; + } + return dom; +} + +function mountAttributes(node, attrs, attrKeys, dom, instance) { + for (var i = 0; i < attrKeys.length; i++) { + var attr = attrKeys[i]; + + if (attr === 'ref') { + mountRef(getRefInstance$1(node, instance), attrs[attr], dom); + } else { + patchAttribute(attr, null, attrs[attr], dom); + } + } +} + +function patch(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG) { + if (lastInput !== nextInput) { + if (isInvalidNode(lastInput)) { + mount(nextInput, parentDom, lifecycle, context, instance, isSVG); + } else if (isInvalidNode(nextInput)) { + remove(lastInput, parentDom); + } else if (isStringOrNumber(lastInput)) { + if (isStringOrNumber(nextInput)) { + parentDom.firstChild.nodeValue = nextInput; + } else { + var dom = mount(nextInput, null, lifecycle, context, instance, isSVG); + + nextInput.dom = dom; + replaceNode(parentDom, dom, parentDom.firstChild); + } + } else if (isStringOrNumber(nextInput)) { + replaceNode(parentDom, document.createTextNode(nextInput), lastInput.dom); + } else { + if (isVList(nextInput)) { + if (isVList(lastInput)) { + patchVList(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG); + } else { + replaceNode(parentDom, mountVList(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); + unmount(lastInput, null); + } + } else if (isVList(lastInput)) { + replaceVListWithNode(parentDom, lastInput, mount(nextInput, null, lifecycle, context, instance, isSVG)); + } else if (isVPlaceholder(nextInput)) { + if (isVPlaceholder(lastInput)) { + patchVFragment(lastInput, nextInput); + } else { + replaceNode(parentDom, mountVPlaceholder(nextInput, null), lastInput.dom); + unmount(lastInput, null); + } + } else if (isVPlaceholder(lastInput)) { + replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); + } else if (isVText(nextInput)) { + if (isVText(lastInput)) { + patchVText(lastInput, nextInput); + } else { + replaceNode(parentDom, mountVText(nextInput, null), lastInput.dom); + unmount(lastInput, null); + } + } else if (isVText(lastInput)) { + replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); + } else if (isVNode(nextInput)) { + if (isVNode(lastInput)) { + patchVNode(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG, false); + } else { + replaceNode(parentDom, mountVNode(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); + unmount(lastInput, null); + } + } else if (isVNode(lastInput)) { + replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); + unmount(lastInput, null); + } else { + return patch(lastInput, normalise(nextInput), parentDom, lifecycle, context, instance, isSVG); + } + } + } + return nextInput; +} + +function patchTextNode(dom, lastChildren, nextChildren) { + if (isStringOrNumber(lastChildren) && lastChildren !== '') { + dom.firstChild.nodeValue = nextChildren; + } else { + dom.textContent = nextChildren; + } +} + +function patchRef(instance, lastValue, nextValue, dom) { + if (instance) { + if (isString(lastValue)) { + delete instance.refs[lastValue]; + } + if (isString(nextValue)) { + instance.refs[nextValue] = dom; + } + } +} + +function patchChildren(lastNode, nextNode, dom, lifecycle, context, instance, isSVG) { + var nextChildren = nextNode.children; + var lastChildren = lastNode.children; + + if (lastChildren === nextChildren) { + return; + } + if (isInvalidNode(lastChildren)) { + if (isStringOrNumber(nextChildren)) { + patchTextNode(dom, lastChildren, nextChildren); + } else if (!isInvalidNode(nextChildren)) { + if (isArray(nextChildren)) { + mountArrayChildren(nextChildren, dom, lifecycle, context, instance, isSVG); + } else { + mount(nextChildren, dom, lifecycle, context, instance, isSVG); + } + } + } else { + if (isInvalidNode(nextChildren)) { + removeAllChildren(dom, lastChildren); + } else { + if (isArray(lastChildren)) { + if (isArray(nextChildren)) { + nextChildren.complex = lastChildren.complex; + if (isKeyed(lastChildren, nextChildren)) { + patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, null); + } else { + patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, null); + } + } else { + patchNonKeyedChildren(lastChildren, [nextChildren], dom, lifecycle, context, instance, isSVG, null); + } + } else { + if (isArray(nextChildren)) { + var lastChild = lastChildren; + + if (isStringOrNumber(lastChildren)) { + lastChild = createVText(lastChild); + lastChild.dom = dom.firstChild; + } + patchNonKeyedChildren([lastChild], nextChildren, dom, lifecycle, context, instance, isSVG, null); + } else if (isStringOrNumber(nextChildren)) { + patchTextNode(dom, lastChildren, nextChildren); + } else if (isStringOrNumber(lastChildren)) { + patch(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG); + } else { + patchVNode(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, false); + } + } + } + } +} + +function patchVNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, isSVG, skipLazyCheck) { + var lastBp = lastVNode.bp; + var nextBp = nextVNode.bp; + + if (lastBp === undefined || nextBp === undefined) { + patchVNodeWithoutBlueprint(lastVNode, nextVNode, parentDom, lifecycle, context, instance, isSVG); + } else { + patchVNodeWithBlueprint(lastVNode, nextVNode, lastBp, nextBp, parentDom, lifecycle, context, instance, skipLazyCheck); + } +} + +function patchVNodeWithBlueprint(lastVNode, nextVNode, lastBp, nextBp, parentDom, lifecycle, context, instance, skipLazyCheck) { + var nextHooks; + + if (nextBp.hasHooks === true) { + nextHooks = nextVNode.hooks; + if (nextHooks && !isNullOrUndefined(nextHooks.willUpdate)) { + nextHooks.willUpdate(lastVNode.dom); + } + } + var nextTag = nextVNode.tag || nextBp.tag; + var lastTag = lastVNode.tag || lastBp.tag; + + if (lastTag !== nextTag) { + if (lastBp && lastBp.isComponent === true) { + var lastNodeInstance = lastVNode.instance; + + if (nextBp.isComponent === true) { + replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, false); + } else if (isStatefulComponent(lastTag)) { + unmountVNode(lastVNode, null, true); + var lastNode = lastNodeInstance._lastNode; + patchVNodeWithBlueprint(lastNode, nextVNode, lastNode.bp, nextBp, parentDom, lifecycle, context, instance, nextBp.isSVG); + } else { + unmountVNode(lastVNode, null, true); + patchVNodeWithBlueprint(lastNodeInstance, nextVNode, lastNodeInstance.bp, nextBp, parentDom, lifecycle, context, instance, nextBp.isSVG); + } + } else { + replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, nextBp.isSVG); + } + } else if (isNullOrUndefined(lastTag)) { + nextVNode.dom = lastVNode.dom; + } else { + if (lastBp && lastBp.isComponent === true) { + if (nextBp.isComponent === true) { + var instance$1 = lastVNode.instance; + + if (!isNullOrUndefined(instance$1) && instance$1._unmounted) { + var newDom = mountComponent(nextVNode, lastTag, nextVNode.attrs || {}, nextVNode.hooks, nextVNode.children, instance$1, parentDom, lifecycle, context); + if (parentDom !== null) { + replaceNode(parentDom, newDom, lastVNode.dom); + } + } else { + nextVNode.instance = instance$1; + nextVNode.dom = lastVNode.dom; + patchComponent(true, nextVNode, nextVNode.tag, lastBp, nextBp, instance$1, lastVNode.attrs || {}, nextVNode.attrs || {}, nextVNode.hooks, lastVNode.children, nextVNode.children, parentDom, lifecycle, context); + } + } + } else { + var dom = lastVNode.dom; + var lastChildrenType = lastBp.childrenType; + var nextChildrenType = nextBp.childrenType; + nextVNode.dom = dom; + + if (nextBp.lazy === true && skipLazyCheck === false) { + var clipData = lastVNode.clipData; + + if (lifecycle.scrollY === null) { + lifecycle.refresh(); + } + + nextVNode.clipData = clipData; + if (clipData.pending === true || clipData.top - lifecycle.scrollY > lifecycle.screenHeight) { + if (setClipNode(clipData, dom, lastVNode, nextVNode, parentDom, lifecycle, context, instance, lastBp.isSVG)) { + return; + } + } + if (clipData.bottom < lifecycle.scrollY) { + if (setClipNode(clipData, dom, lastVNode, nextVNode, parentDom, lifecycle, context, instance, lastBp.isSVG)) { + return; + } + } + } + + if (lastChildrenType > 0 || nextChildrenType > 0) { + if (nextChildrenType === 5 || lastChildrenType === 5) { + patchChildren(lastVNode, nextVNode, dom, lifecycle, context, instance); + } else { + var lastChildren = lastVNode.children; + var nextChildren = nextVNode.children; + + if (lastChildrenType === 0 || isInvalidNode(lastChildren)) { + if (nextChildrenType > 2) { + mountArrayChildren(nextChildren, dom, lifecycle, context, instance); + } else { + mount(nextChildren, dom, lifecycle, context, instance); + } + } else if (nextChildrenType === 0 || isInvalidNode(nextChildren)) { + if (lastChildrenType > 2) { + removeAllChildren(dom, lastChildren); + } else { + remove(lastChildren, dom); + } + } else { + if (lastChildren !== nextChildren) { + if (lastChildrenType === 4 && nextChildrenType === 4) { + patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, nextBp.isSVG, null); + } else if (lastChildrenType === 2 && nextChildrenType === 2) { + patch(lastChildren, nextChildren, dom, lifecycle, context, instance, true, nextBp.isSVG); + } else if (lastChildrenType === 1 && nextChildrenType === 1) { + patchTextNode(dom, lastChildren, nextChildren); + } else { + patchChildren(lastVNode, nextVNode, dom, lifecycle, context, instance, nextBp.isSVG); + } + } + } + } + } + if (lastBp.hasAttrs === true || nextBp.hasAttrs === true) { + patchAttributes(lastVNode, nextVNode, lastBp.attrKeys, nextBp.attrKeys, dom, instance); + } + if (lastBp.hasEvents === true || nextBp.hasEvents === true) { + patchEvents(lastVNode.events, nextVNode.events, lastBp.eventKeys, nextBp.eventKeys, dom); + } + if (lastBp.hasClassName === true || nextBp.hasClassName === true) { + var nextClassName = nextVNode.className; + + if (lastVNode.className !== nextClassName) { + if (isNullOrUndefined(nextClassName)) { + dom.removeAttribute('class'); + } else { + dom.className = nextClassName; + } + } + } + if (lastBp.hasStyle === true || nextBp.hasStyle === true) { + var nextStyle = nextVNode.style; + var lastStyle = lastVNode.style; + + if (lastStyle !== nextStyle) { + patchStyle(lastStyle, nextStyle, dom); + } + } + if (nextBp.hasHooks === true && !isNullOrUndefined(nextHooks.didUpdate)) { + nextHooks.didUpdate(dom); + } + setFormElementProperties(nextTag, nextVNode); + } + } +} + +function patchVNodeWithoutBlueprint(lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG) { + var nextHooks = nextNode.hooks; + var nextHooksDefined = !isNullOrUndefined(nextHooks); + + if (nextHooksDefined && !isNullOrUndefined(nextHooks.willUpdate)) { + nextHooks.willUpdate(lastNode.dom); + } + var nextTag = nextNode.tag || ((isNullOrUndefined(nextNode.bp)) ? null : nextNode.bp.tag); + var lastTag = lastNode.tag || ((isNullOrUndefined(lastNode.bp)) ? null : lastNode.bp.tag); + + if (nextTag === 'svg') { + isSVG = true; + } + if (lastTag !== nextTag) { + var lastNodeInstance = lastNode.instance; + + if (isFunction(lastTag)) { + if (isFunction(nextTag)) { + replaceWithNewNode(lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); + } else if (isStatefulComponent(lastTag)) { + unmountVNode(lastNode, null, true); + patchVNodeWithoutBlueprint(lastNodeInstance._lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); + } else { + unmountVNode(lastNode, null, true); + patchVNodeWithoutBlueprint(lastNodeInstance, nextNode, parentDom, lifecycle, context, instance, isSVG); + } + } else { + replaceWithNewNode(lastNodeInstance || lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); + } + } else if (isNullOrUndefined(lastTag)) { + nextNode.dom = lastNode.dom; + } else { + if (isFunction(lastTag)) { + if (isFunction(nextTag)) { + var instance$1 = lastNode._instance; + + if (!isNullOrUndefined(instance$1) && instance$1._unmounted) { + var newDom = mountComponent(nextNode, lastTag, nextNode.attrs || {}, nextNode.hooks, nextNode.children, instance$1, parentDom, lifecycle, context); + if (parentDom !== null) { + replaceNode(parentDom, newDom, lastNode.dom); + } + } else { + nextNode.instance = lastNode.instance; + nextNode.dom = lastNode.dom; + patchComponent(false, nextNode, nextNode.tag, null, null, nextNode.instance, lastNode.attrs || {}, nextNode.attrs || {}, nextNode.hooks, lastNode.children, nextNode.children, parentDom, lifecycle, context); + } + } + } else { + var dom = lastNode.dom; + var nextClassName = nextNode.className; + var nextStyle = nextNode.style; + + nextNode.dom = dom; + + patchChildren(lastNode, nextNode, dom, lifecycle, context, instance, isSVG); + patchAttributes(lastNode, nextNode, null, null, dom, instance); + patchEvents(lastNode.events, nextNode.events, null, null, dom); + + if (lastNode.className !== nextClassName) { + if (isNullOrUndefined(nextClassName)) { + dom.removeAttribute('class'); + } else { + dom.className = nextClassName; + } + } + if (lastNode.style !== nextStyle) { + patchStyle(lastNode.style, nextStyle, dom); + } + if (nextHooksDefined && !isNullOrUndefined(nextHooks.didUpdate)) { + nextHooks.didUpdate(dom); + } + setFormElementProperties(nextTag, nextNode); + } + } +} + +function patchAttributes(lastNode, nextNode, lastAttrKeys, nextAttrKeys, dom, instance) { + if (lastNode.tag === 'select') { + selectValue(nextNode); + } + var nextAttrs = nextNode.attrs; + var lastAttrs = lastNode.attrs; + var nextAttrsIsUndef = isNullOrUndefined(nextAttrs); + var lastAttrsIsNotUndef = !isNullOrUndefined(lastAttrs); + + if (!nextAttrsIsUndef) { + var nextAttrsKeys = nextAttrKeys || Object.keys(nextAttrs); + var attrKeysLength = nextAttrsKeys.length; + + for (var i = 0; i < attrKeysLength; i++) { + var attr = nextAttrsKeys[i]; + var lastAttrVal = lastAttrsIsNotUndef && lastAttrs[attr]; + var nextAttrVal = nextAttrs[attr]; + + if (lastAttrVal !== nextAttrVal) { + if (attr === 'ref') { + patchRef(instance, lastAttrVal, nextAttrVal, dom); + } else { + patchAttribute(attr, lastAttrVal, nextAttrVal, dom); + } + } + } + } + if (lastAttrsIsNotUndef) { + var lastAttrsKeys = lastAttrKeys || Object.keys(lastAttrs); + var attrKeysLength$1 = lastAttrsKeys.length; + + for (var i$1 = 0; i$1 < attrKeysLength$1; i$1++) { + var attr$1 = lastAttrsKeys[i$1]; + + if (nextAttrsIsUndef || isNullOrUndefined(nextAttrs[attr$1])) { + if (attr$1 === 'ref') { + patchRef(getRefInstance(node, instance), lastAttrs[attr$1], null, dom); + } else { + dom.removeAttribute(attr$1); + } + } + } + } +} + + +function patchStyle(lastAttrValue, nextAttrValue, dom) { + if (isString(nextAttrValue)) { + dom.style.cssText = nextAttrValue; + } else if (isNullOrUndefined(lastAttrValue)) { + if (!isNullOrUndefined(nextAttrValue)) { + var styleKeys = Object.keys(nextAttrValue); + + for (var i = 0; i < styleKeys.length; i++) { + var style = styleKeys[i]; + var value = nextAttrValue[style]; + + if (isNumber(value) && !isUnitlessNumber[style]) { + dom.style[style] = value + 'px'; + } else { + dom.style[style] = value; + } + } + } + } else if (isNullOrUndefined(nextAttrValue)) { + dom.removeAttribute('style'); + } else { + var styleKeys$1 = Object.keys(nextAttrValue); + + for (var i$1 = 0; i$1 < styleKeys$1.length; i$1++) { + var style$1 = styleKeys$1[i$1]; + var value$1 = nextAttrValue[style$1]; + + if (isNumber(value$1) && !isUnitlessNumber[style$1]) { + dom.style[style$1] = value$1 + 'px'; + } else { + dom.style[style$1] = value$1; + } + } + var lastStyleKeys = Object.keys(lastAttrValue); + + for (var i$2 = 0; i$2 < lastStyleKeys.length; i$2++) { + var style$2 = lastStyleKeys[i$2]; + if (isNullOrUndefined(nextAttrValue[style$2])) { + dom.style[style$2] = ''; + } + } + } +} + +function patchEvents(lastEvents, nextEvents, _lastEventKeys, _nextEventKeys, dom) { + var nextEventsDefined = !isNullOrUndefined(nextEvents); + var lastEventsDefined = !isNullOrUndefined(lastEvents); + var lastEventKeys; + + if (lastEventsDefined) { + lastEventKeys = _lastEventKeys || Object.keys(lastEvents); + } + if (nextEventsDefined) { + var nextEventKeys = _nextEventKeys || Object.keys(nextEvents); + + if (lastEventsDefined) { + for (var i = 0; i < nextEventKeys.length; i++) { + var event = nextEventKeys[i]; + var lastEvent = lastEvents[event]; + var nextEvent = nextEvents[event]; + + if (lastEvent !== nextEvent) { + dom[event] = nextEvent; + } + } + for (var i$1 = 0; i$1 < lastEventKeys.length; i$1++) { + var event$1 = lastEventKeys[i$1]; + + if (isNullOrUndefined(nextEvents[event$1])) { + dom[event$1] = null; + } + } + } else { + mountEvents(nextEvents, nextEventKeys, dom); + } + } else if (lastEventsDefined) { + removeEvents(lastEvents, lastEventKeys, dom); + } +} + +function patchAttribute(attrName, lastAttrValue, nextAttrValue, dom) { + if (attrName === 'dangerouslySetInnerHTML') { + var lastHtml = lastAttrValue && lastAttrValue.__html; + var nextHtml = nextAttrValue && nextAttrValue.__html; + + if (isNullOrUndefined(nextHtml)) { + throw new Error('Inferno Error: dangerouslySetInnerHTML requires an object with a __html propety containing the innerHTML content'); + } + if (lastHtml !== nextHtml) { + dom.innerHTML = nextHtml; + } + } else if (attrName === 'eventData') { + dom.eventData = nextAttrValue; + } else if (strictProps[attrName]) { + dom[attrName] = nextAttrValue === null ? '' : nextAttrValue; + } else { + if (booleanProps[attrName]) { + dom[attrName] = nextAttrValue ? true : false; + } else { + var ns = namespaces[attrName]; + + if (nextAttrValue === false || isNullOrUndefined(nextAttrValue)) { + if (ns !== undefined) { + dom.removeAttributeNS(ns, attrName); + } else { + dom.removeAttribute(attrName); + } + } else { + if (ns !== undefined) { + dom.setAttributeNS(ns, attrName, nextAttrValue === true ? attrName : nextAttrValue); + } else { + dom.setAttribute(attrName, nextAttrValue === true ? attrName : nextAttrValue); + } + } + } + } +} + +function patchComponent(hasBlueprint, lastNode, Component, lastBp, nextBp, instance, lastProps, nextProps, nextHooks, lastChildren, nextChildren, parentDom, lifecycle, context) { + nextProps = addChildrenToProps(nextChildren, nextProps); + + if (isStatefulComponent(Component)) { + var prevProps = instance.props; + var prevState = instance.state; + var nextState = instance.state; + + var childContext = instance.getChildContext(); + if (!isNullOrUndefined(childContext)) { + context = Object.assign({}, context, childContext); + } + instance.context = context; + var nextNode = instance._updateComponent(prevState, nextState, prevProps, nextProps); + + if (nextNode === NO_RENDER) { + nextNode = instance._lastNode; + } else if (isNullOrUndefined(nextNode)) { + nextNode = createVPlaceholder(); + } + patch(instance._lastNode, nextNode, parentDom, lifecycle, context, instance, null, false); + lastNode.dom = nextNode.dom; + instance._lastNode = nextNode; + instance.componentDidUpdate(prevProps, prevState); + componentToDOMNodeMap.set(instance, nextNode.dom); + } else { + var shouldUpdate = true; + var nextHooksDefined = (hasBlueprint && nextBp.hasHooks === true) || !isNullOrUndefined(nextHooks); + + lastProps = addChildrenToProps(lastChildren, lastProps); + if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentShouldUpdate)) { + shouldUpdate = nextHooks.componentShouldUpdate(lastNode.dom, lastProps, nextProps); + } + if (shouldUpdate !== false) { + if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentWillUpdate)) { + nextHooks.componentWillUpdate(lastNode.dom, lastProps, nextProps); + } + var nextNode$1 = Component(nextProps, context); + + if (isInvalidNode(nextNode$1)) { + nextNode$1 = createVPlaceholder(); + } + nextNode$1.dom = lastNode.dom; + patch(instance, nextNode$1, parentDom, lifecycle, context, null, null, false); + lastNode.instance = nextNode$1; + if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentDidUpdate)) { + nextHooks.componentDidUpdate(lastNode.dom, lastProps, nextProps); + } + } + } +} + +function patchVList(lastVList, nextVList, parentDom, lifecycle, context, instance, isSVG) { + var lastItems = lastVList.items; + var nextItems = nextVList.items; + var pointer = lastVList.pointer; + + nextVList.dom = lastVList.dom; + nextVList.pointer = pointer; + if (!lastItems !== nextItems) { + if (isKeyed(lastItems, nextItems)) { + patchKeyedChildren(lastItems, nextItems, parentDom, lifecycle, context, instance, isSVG, nextVList); + } else { + patchNonKeyedChildren(lastItems, nextItems, parentDom, lifecycle, context, instance, isSVG, nextVList); + } + } +} + +function patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, parentVList) { + var lastChildrenLength = lastChildren.length; + var nextChildrenLength = nextChildren.length; + var commonLength = lastChildrenLength > nextChildrenLength ? nextChildrenLength : lastChildrenLength; + var i = 0; + + for (; i < commonLength; i++) { + var lastChild = lastChildren[i]; + var nextChild = normaliseChild(nextChildren, i); + + patch(lastChild, nextChild, dom, lifecycle, context, instance, isSVG); + } + if (lastChildrenLength < nextChildrenLength) { + for (i = commonLength; i < nextChildrenLength; i++) { + var child = normaliseChild(nextChildren, i); + + insertOrAppend(dom, mount(child, null, lifecycle, context, instance, isSVG), parentVList && parentVList.pointer); + } + } else if (lastChildrenLength > nextChildrenLength) { + for (i = commonLength; i < lastChildrenLength; i++) { + remove(lastChildren[i], dom); + } + } +} + +function patchVFragment(lastVFragment, nextVFragment) { + nextVFragment.dom = lastVFragment.dom; +} + +function patchVText(lastVText, nextVText) { + var nextText = nextVText.text; + var dom = lastVText.dom; + + nextVText.dom = dom; + if (lastVText.text !== nextText) { + dom.nodeValue = nextText; + } +} + +function patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, parentVList) { + var lastChildrenLength = lastChildren.length; + var nextChildrenLength = nextChildren.length; + var lastEndIndex = lastChildrenLength - 1; + var nextEndIndex = nextChildrenLength - 1; + var lastStartIndex = 0; + var nextStartIndex = 0; + var lastStartNode = null; + var nextStartNode = null; + var nextEndNode = null; + var lastEndNode = null; + var nextNode; + + while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { + nextStartNode = nextChildren[nextStartIndex]; + lastStartNode = lastChildren[lastStartIndex]; + + if (nextStartNode.key !== lastStartNode.key) { + break; + } + patchVNode(lastStartNode, nextStartNode, dom, lifecycle, context, instance, isSVG, false); + nextStartIndex++; + lastStartIndex++; + } + while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { + nextEndNode = nextChildren[nextEndIndex]; + lastEndNode = lastChildren[lastEndIndex]; + + if (nextEndNode.key !== lastEndNode.key) { + break; + } + patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); + nextEndIndex--; + lastEndIndex--; + } + while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { + nextEndNode = nextChildren[nextEndIndex]; + lastStartNode = lastChildren[lastStartIndex]; + + if (nextEndNode.key !== lastStartNode.key) { + break; + } + nextNode = (nextEndIndex + 1 < nextChildrenLength) ? nextChildren[nextEndIndex + 1].dom : null; + patchVNode(lastStartNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); + insertOrAppend(dom, nextEndNode.dom, nextNode); + nextEndIndex--; + lastStartIndex++; + } + while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { + nextStartNode = nextChildren[nextStartIndex]; + lastEndNode = lastChildren[lastEndIndex]; + + if (nextStartNode.key !== lastEndNode.key) { + break; + } + nextNode = lastChildren[lastStartIndex].dom; + patchVNode(lastEndNode, nextStartNode, dom, lifecycle, context, instance, isSVG, false); + insertOrAppend(dom, nextStartNode.dom, nextNode); + nextStartIndex++; + lastEndIndex--; + } + + if (lastStartIndex > lastEndIndex) { + if (nextStartIndex <= nextEndIndex) { + nextNode = (nextEndIndex + 1 < nextChildrenLength) ? nextChildren[nextEndIndex + 1].dom : parentVList && parentVList.pointer; + for (; nextStartIndex <= nextEndIndex; nextStartIndex++) { + insertOrAppend(dom, mount(nextChildren[nextStartIndex], null, lifecycle, context, instance, isSVG), nextNode); + } + } + } else if (nextStartIndex > nextEndIndex) { + while (lastStartIndex <= lastEndIndex) { + remove(lastChildren[lastStartIndex++], dom); + } + } else { + var aLength = lastEndIndex - lastStartIndex + 1; + var bLength = nextEndIndex - nextStartIndex + 1; + var sources = new Array(bLength); + + // Mark all nodes as inserted. + var i; + for (i = 0; i < bLength; i++) { + sources[i] = -1; + } + var moved = false; + var removeOffset = 0; + var lastTarget = 0; + var index; + var removed = true; + var k = 0; + + if ((bLength <= 4) || (aLength * bLength <= 16)) { + for (i = lastStartIndex; i <= lastEndIndex; i++) { + removed = true; + lastEndNode = lastChildren[i]; + if (k < bLength) { + for (index = nextStartIndex; index <= nextEndIndex; index++) { + nextEndNode = nextChildren[index]; + if (lastEndNode.key === nextEndNode.key) { + sources[index - nextStartIndex] = i; + + if (lastTarget > index) { + moved = true; + } else { + lastTarget = index; + } + patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); + k++; + removed = false; + break; + } + } + } + if (removed) { + remove(lastEndNode, dom); + removeOffset++; + } + } + } else { + var prevItemsMap = new Map(); + + for (i = nextStartIndex; i <= nextEndIndex; i++) { + prevItemsMap.set(nextChildren[i].key, i); + } + for (i = lastStartIndex; i <= lastEndIndex; i++) { + removed = true; + lastEndNode = lastChildren[i]; + + if (k < nextChildrenLength) { + index = prevItemsMap.get(lastEndNode.key); + + if (index !== undefined) { + nextEndNode = nextChildren[index]; + sources[index - nextStartIndex] = i; + if (lastTarget > index) { + moved = true; + } else { + lastTarget = index; + } + patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); + k++; + removed = false; + } + } + if (removed) { + remove(lastEndNode, dom); + removeOffset++; + } + } + } + + var pos; + if (moved) { + var seq = lis_algorithm(sources); + index = seq.length - 1; + for (i = bLength - 1; i >= 0; i--) { + if (sources[i] === -1) { + pos = i + nextStartIndex; + nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; + insertOrAppend(dom, mount(nextChildren[pos], null, lifecycle, context, instance, isSVG), nextNode); + } else { + if (index < 0 || i !== seq[index]) { + pos = i + nextStartIndex; + nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; + insertOrAppend(dom, nextChildren[pos].dom, nextNode); + } else { + index--; + } + } + } + } else if (aLength - removeOffset !== bLength) { + for (i = bLength - 1; i >= 0; i--) { + if (sources[i] === -1) { + pos = i + nextStartIndex; + nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; + insertOrAppend(dom, mount(nextChildren[pos], null, lifecycle, context, instance, isSVG), nextNode); + } + } + } + } +} + +// https://en.wikipedia.org/wiki/Longest_increasing_subsequence +function lis_algorithm(a) { + var p = a.slice(0); + var result = []; + result.push(0); + var i; + var j; + var u; + var v; + var c; + + for (i = 0; i < a.length; i++) { + if (a[i] === -1) { + continue; + } + + j = result[result.length - 1]; + if (a[j] < a[i]) { + p[i] = j; + result.push(i); + continue; + } + + u = 0; + v = result.length - 1; + + while (u < v) { + c = ((u + v) / 2) | 0; + if (a[result[c]] < a[i]) { + u = c + 1; + } else { + v = c; + } + } + + if (a[i] < a[result[u]]) { + if (u > 0) { + p[i] = result[u - 1]; + } + result[u] = i; + } + } + + u = result.length; + v = result[u - 1]; + + while (u-- > 0) { + result[u] = v; + v = p[v]; + } + + return result; +} + +var screenWidth = isBrowser && window.screen.width; +var screenHeight = isBrowser && window.screen.height; +var scrollX = 0; +var scrollY = 0; +var lastScrollTime = 0; + +if (isBrowser) { + window.onscroll = function () { + scrollX = window.scrollX; + scrollY = window.scrollY; + lastScrollTime = performance.now(); + }; + + window.resize = function () { + scrollX = window.scrollX; + scrollY = window.scrollY; + screenWidth = window.screen.width; + screenHeight = window.screen.height; + lastScrollTime = performance.now(); + }; +} + +function Lifecycle() { + this._listeners = []; + this.scrollX = null; + this.scrollY = null; + this.screenHeight = screenHeight; + this.screenWidth = screenWidth; +} + +Lifecycle.prototype = { + refresh: function refresh() { + this.scrollX = isBrowser && window.scrollX; + this.scrollY = isBrowser && window.scrollY; + }, + addListener: function addListener(callback) { + this._listeners.push(callback); + }, + trigger: function trigger() { + var this$1 = this; + + for (var i = 0; i < this._listeners.length; i++) { + this$1._listeners[i](); + } + } +}; + +function handleLazyAttached(node, lifecycle, dom) { + lifecycle.addListener(function () { + var rect = dom.getBoundingClientRect(); + + if (lifecycle.scrollY === null) { + lifecycle.refresh(); + } + node.clipData = { + top: rect.top + lifecycle.scrollY, + left: rect.left + lifecycle.scrollX, + bottom: rect.bottom + lifecycle.scrollY, + right: rect.right + lifecycle.scrollX, + pending: false + }; + }); +} + +function hydrateChild(child, childNodes, counter, parentDom, lifecycle, context, instance) { + var domNode = childNodes[counter.i]; + + if (isVText(child)) { + var text = child.text; + + child.dom = domNode; + if (domNode.nodeType === 3 && text !== '') { + domNode.nodeValue = text; + } else { + var newDomNode = mountVText(text); + + replaceNode(parentDom, newDomNode, domNode); + childNodes.splice(childNodes.indexOf(domNode), 1, newDomNode); + child.dom = newDomNode; + } + } else if (isVPlaceholder(child)) { + child.dom = domNode; + } else if (isVList(child)) { + var items = child.items; + + // this doesn't really matter, as it won't be used again, but it's what it should be given the purpose of VList + child.dom = document.createDocumentFragment(); + for (var i = 0; i < items.length; i++) { + var rebuild = hydrateChild(normaliseChild(items, i), childNodes, counter, parentDom, lifecycle, context, instance); + + if (rebuild) { + return true; + } + } + // at the end of every VList, there should be a "pointer". It's an empty TextNode used for tracking the VList + var pointer = childNodes[counter.i++]; + + if (pointer && pointer.nodeType === 3) { + child.pointer = pointer; + } else { + // there is a problem, we need to rebuild this tree + return true; + } + } else { + var rebuild$1 = hydrateNode(child, domNode, parentDom, lifecycle, context, instance, false); + + if (rebuild$1) { + return true; + } + } + counter.i++; +} + +function getChildNodesWithoutComments(domNode) { + var childNodes = []; + var rawChildNodes = domNode.childNodes; + var length = rawChildNodes.length; + var i = 0; + + while (i < length) { + var rawChild = rawChildNodes[i]; + + if (rawChild.nodeType === 8) { + if (rawChild.data === '!') { + var placeholder = document.createTextNode(''); + + domNode.replaceChild(placeholder, rawChild); + childNodes.push(placeholder); + i++; + } else { + domNode.removeChild(rawChild); + length--; + } + } else { + childNodes.push(rawChild); + i++; + } + } + return childNodes; +} + +function hydrateComponent(node, Component, props, hooks, children, domNode, parentDom, lifecycle, context, lastInstance, isRoot) { + props = addChildrenToProps(children, props); + + if (isStatefulComponent(Component)) { + var instance = node.instance = new Component(props); + + instance._patch = patch; + if (!isNullOrUndefined(lastInstance) && props.ref) { + mountRef(lastInstance, props.ref, instance); + } + var childContext = instance.getChildContext(); + + if (!isNullOrUndefined(childContext)) { + context = Object.assign({}, context, childContext); + } + instance.context = context; + instance._unmounted = false; + instance._parentNode = node; + if (lastInstance) { + instance._parentComponent = lastInstance; + } + instance._pendingSetState = true; + instance.componentWillMount(); + var nextNode = instance.render(); + + instance._pendingSetState = false; + if (isInvalidNode(nextNode)) { + nextNode = createVPlaceholder(); + } + hydrateNode(nextNode, domNode, parentDom, lifecycle, context, instance, isRoot); + instance._lastNode = nextNode; + instance.componentDidMount(); + + } else { + var instance$1 = node.instance = Component(props); + + if (!isNullOrUndefined(hooks)) { + if (!isNullOrUndefined(hooks.componentWillMount)) { + hooks.componentWillMount(null, props); + } + if (!isNullOrUndefined(hooks.componentDidMount)) { + lifecycle.addListener(function () { + hooks.componentDidMount(domNode, props); + }); + } + } + return hydrateNode(instance$1, domNode, parentDom, lifecycle, context, instance$1, isRoot); + } +} + +function hydrateNode(node, domNode, parentDom, lifecycle, context, instance, isRoot) { + var bp = node.bp; + var tag = node.tag || bp.tag; + + if (isFunction(tag)) { + node.dom = domNode; + hydrateComponent(node, tag, node.attrs || {}, node.hooks, node.children, domNode, parentDom, lifecycle, context, instance, isRoot); + } else { + if ( + domNode.nodeType !== 1 || + tag !== domNode.tagName.toLowerCase() + ) { + // TODO remake node + } else { + node.dom = domNode; + var hooks = node.hooks; + + if ((bp && bp.hasHooks === true) || !isNullOrUndefined(hooks)) { + handleAttachedHooks(hooks, lifecycle, domNode); + } + var children = node.children; + + if (!isNullOrUndefined(children)) { + if (isStringOrNumber(children)) { + if (domNode.textContent !== children) { + domNode.textContent = children; + } + } else { + var childNodes = getChildNodesWithoutComments(domNode); + var counter = { i: 0 }; + var rebuild = false; + + if (isArray(children)) { + for (var i = 0; i < children.length; i++) { + rebuild = hydrateChild(normaliseChild(children, i), childNodes, counter, domNode, lifecycle, context, instance); + + if (rebuild) { + break; + } + } + } else { + if (childNodes.length === 1) { + rebuild = hydrateChild(children, childNodes, counter, domNode, lifecycle, context, instance); + } else { + rebuild = true; + } + } + + if (rebuild) { + // TODO scrap children and rebuild again + } + } + } + var className = node.className; + var style = node.style; + + if (!isNullOrUndefined(className)) { + domNode.className = className; + } + if (!isNullOrUndefined(style)) { + patchStyle(null, style, domNode); + } + if (bp && bp.hasAttrs === true) { + mountBlueprintAttrs(node, bp, domNode, instance); + } else { + var attrs = node.attrs; + + if (!isNullOrUndefined(attrs)) { + handleSelects(node); + mountAttributes(node, attrs, Object.keys(attrs), domNode, instance); + } + } + if (bp && bp.hasEvents === true) { + mountBlueprintEvents(node, bp, domNode); + } else { + var events = node.events; + + if (!isNullOrUndefined(events)) { + mountEvents(events, Object.keys(events), domNode); + } + } + } + } +} +var documetBody = isBrowser ? document.body : null; + +function hydrate(node, parentDom, lifecycle) { + if (parentDom && parentDom.nodeType === 1) { + var rootNode = parentDom.querySelector('[data-infernoroot]'); + + if (rootNode && rootNode.parentNode === parentDom) { + hydrateNode(node, rootNode, parentDom, lifecycle, {}, true); + return true; + } + } + // clear parentDom, unless it's document.body + if (parentDom !== documetBody) { + parentDom.textContent = ''; + } else { + console.warn('Inferno Warning: rendering to the "document.body" is dangerous! Use a dedicated container element instead.'); + } + return false; +} + +var roots = new Map(); +var componentToDOMNodeMap = new Map(); + +function findDOMNode(domNode) { + return componentToDOMNodeMap.get(domNode) || null; +} + +function render(input, parentDom) { + var root = roots.get(parentDom); + var lifecycle = new Lifecycle(); + + if (isUndefined(root)) { + if (!isInvalidNode(input)) { + if (!hydrate(input, parentDom, lifecycle)) { + mount(input, parentDom, lifecycle, {}, null, false); + } + lifecycle.trigger(); + roots.set(parentDom, { input: input }); + } + } else { + var activeNode = getActiveNode(); + var nextInput = patch(root.input, input, parentDom, lifecycle, {}, null, false); + + lifecycle.trigger(); + if (isNull(input)) { + roots.delete(parentDom); + } + root.input = nextInput; + resetActiveNode(activeNode); + } +} + +function createAttrsAndEvents(props, tag) { + var events = null; + var hooks = null; + var attrs = null; + var className = null; + var style = null; + + if (!isNullOrUndefined(props)) { + if (isArray(props)) { + return props; + } + for (var prop in props) { + if (prop === 'className') { + className = props[prop]; + } else if (prop === 'style') { + style = props[prop]; + } else if (isAttrAHook(prop) && !isFunction(tag)) { + if (isNullOrUndefined(hooks)) { + hooks = {}; + } + hooks[prop.substring(2).toLowerCase()] = props[prop]; + delete props[prop]; + } else if (isAttrAnEvent(prop) && !isFunction(tag)) { + if (isNullOrUndefined(events)) { + events = {}; + } + events[prop.toLowerCase()] = props[prop]; + delete props[prop]; + } else if (isAttrAComponentHook(prop) && isFunction(tag)) { + if (isNullOrUndefined(hooks)) { + hooks = {}; + } + hooks['c' + prop.substring(3)] = props[prop]; + delete props[prop]; + } else if (!isFunction(tag)) { + if (isNullOrUndefined(attrs)) { + attrs = {}; + } + attrs[prop] = props[prop]; + } else { + attrs = props; + } + } + } + return { attrs: attrs, events: events, className: className, style: style, hooks: hooks }; +} + +function createChild(ref) { + var tag = ref.tag; + var attrs = ref.attrs; + var children = ref.children; + var className = ref.className; + var style = ref.style; + var events = ref.events; + var hooks = ref.hooks; + + if (tag === undefined && !isNullOrUndefined(attrs) && !attrs.tpl && !isNullOrUndefined(children) && children.length === 0) { + return null; + } + var key = !isNullOrUndefined(attrs) && !isNullOrUndefined(attrs.key) ? attrs.key : undefined; + + if (!isNullOrUndefined(children) && children.length === 0) { + children = null; + } else if (!isInvalidNode(children)) { + children = isArray(children) && children.length === 1 ? createChildren(children[0]) : createChildren(children); + } + + if (key !== undefined) { + delete attrs.key; + } + var attrsAndEvents = createAttrsAndEvents(attrs, tag); + var vNode = createVNode(); + + className = className || attrsAndEvents.className; + style = style || attrsAndEvents.style; + + vNode.tag = tag || null; + vNode.attrs = attrsAndEvents.attrs || null; + vNode.events = attrsAndEvents.events || events; + vNode.hooks = attrsAndEvents.hooks || hooks; + vNode.children = children === undefined ? null : children; + vNode.key = key === undefined ? null : key; + vNode.className = className === undefined ? null : className; + vNode.style = style === undefined ? null : style; + + return vNode; +} + +function createChildren(children) { + var childrenDefined = !isNullOrUndefined(children); + if (childrenDefined && isArray(children)) { + var newChildren = []; + + for (var i = 0; i < children.length; i++) { + var child = children[i]; + if (!isNullOrUndefined(child) && typeof child === 'object') { + if (isArray(child)) { + if (child.length > 0) { + newChildren.push(createChildren(child)); + } else { + newChildren.push(null); + } + } else { + newChildren.push(createChild(child)); + } + } else { + newChildren.push(child); + } + } + return newChildren; + } else if (childrenDefined && typeof children === 'object') { + return children.dom === undefined ? createChild(children) : children; + } + return children; +} + +function createElement(tag, props) { + var children = [], len = arguments.length - 2; + while ( len-- > 0 ) children[ len ] = arguments[ len + 2 ]; + + return createChild({ tag: tag, attrs: props, children: children }); +} + +var noOp = 'Inferno Error: Can only update a mounted or mounting component. This usually means you called setState() or forceUpdate() on an unmounted component. This is a no-op.'; + +// Copy of the util from dom/util, otherwise it makes massive bundles +function getActiveNode$1() { + return document.activeElement; +} + +// Copy of the util from dom/util, otherwise it makes massive bundles +function resetActiveNode$1(activeNode) { + if (activeNode !== document.body && document.activeElement !== activeNode) { + activeNode.focus(); // TODO: verify are we doing new focus event, if user has focus listener this might trigger it + } +} + +function queueStateChanges(component, newState, callback) { + for (var stateKey in newState) { + component._pendingState[stateKey] = newState[stateKey]; + } + if (!component._pendingSetState) { + component._pendingSetState = true; + applyState(component, false, callback); + } else { + component.state = Object.assign({}, component.state, component._pendingState); + component._pendingState = {}; + } +} + +function applyState(component, force, callback) { + if ((!component._deferSetState || force) && !component._blockRender) { + component._pendingSetState = false; + var pendingState = component._pendingState; + var prevState = component.state; + var nextState = Object.assign({}, prevState, pendingState); + var props = component.props; + + component._pendingState = {}; + var nextNode = component._updateComponent(prevState, nextState, props, props, force); + + if (nextNode === NO_RENDER) { + nextNode = component._lastNode; + } else if (isNullOrUndefined(nextNode)) { + nextNode = createVPlaceholder(); + } + var lastNode = component._lastNode; + var parentDom = lastNode.dom.parentNode; + var activeNode = getActiveNode$1(); + var subLifecycle = new Lifecycle(); + + component._patch(lastNode, nextNode, parentDom, subLifecycle, component.context, component, null); + component._lastNode = nextNode; + component._componentToDOMNodeMap.set(component, nextNode.dom); + component._parentNode.dom = nextNode.dom; + component.componentDidUpdate(props, prevState); + subLifecycle.trigger(); + if (!isNullOrUndefined(callback)) { + callback(); + } + resetActiveNode$1(activeNode); + } +} + +var Component = function Component(props, context) { + if ( context === void 0 ) context = {}; + + /** @type {object} */ + this.props = props || {}; + + /** @type {object} */ + this.state = {}; + + /** @type {object} */ + this.refs = {}; + this._blockRender = false; + this._blockSetState = false; + this._deferSetState = false; + this._pendingSetState = false; + this._pendingState = {}; + this._parentNode = null; + this._lastNode = null; + this._unmounted = true; + this.context = context; + this._patch = null; + this._parentComponent = null; + this._componentToDOMNodeMap = null; +}; + +Component.prototype.render = function render () { +}; + +Component.prototype.forceUpdate = function forceUpdate (callback) { + if (this._unmounted) { + throw Error(noOp); + } + applyState(this, true, callback); +}; + +Component.prototype.setState = function setState (newState, callback) { + if (this._unmounted) { + throw Error(noOp); + } + if (this._blockSetState === false) { + queueStateChanges(this, newState, callback); + } else { + throw Error('Inferno Warning: Cannot update state via setState() in componentWillUpdate()'); + } +}; + +Component.prototype.componentDidMount = function componentDidMount () { +}; + +Component.prototype.componentWillMount = function componentWillMount () { +}; + +Component.prototype.componentWillUnmount = function componentWillUnmount () { +}; + +Component.prototype.componentDidUpdate = function componentDidUpdate () { +}; + +Component.prototype.shouldComponentUpdate = function shouldComponentUpdate () { + return true; +}; + +Component.prototype.componentWillReceiveProps = function componentWillReceiveProps () { +}; + +Component.prototype.componentWillUpdate = function componentWillUpdate () { +}; + +Component.prototype.getChildContext = function getChildContext () { +}; + +Component.prototype._updateComponent = function _updateComponent (prevState, nextState, prevProps, nextProps, force) { + if (this._unmounted === true) { + this._unmounted = false; + return false; + } + if (!isNullOrUndefined(nextProps) && isNullOrUndefined(nextProps.children)) { + nextProps.children = prevProps.children; + } + if (prevProps !== nextProps || prevState !== nextState || force) { + if (prevProps !== nextProps) { + this._blockRender = true; + this.componentWillReceiveProps(nextProps); + this._blockRender = false; + if (this._pendingSetState) { + nextState = Object.assign({}, nextState, this._pendingState); + this._pendingSetState = false; + this._pendingState = {}; + } + } + var shouldUpdate = this.shouldComponentUpdate(nextProps, nextState); + + if (shouldUpdate !== false || force) { + this._blockSetState = true; + this.componentWillUpdate(nextProps, nextState); + this._blockSetState = false; + this.props = nextProps; + this.state = nextState; + return this.render(); + } + } + return NO_RENDER; +}; + +// don't autobind these methods since they already have guaranteed context. +var AUTOBIND_BLACKLIST = { + constructor: 1, + render: 1, + shouldComponentUpdate: 1, + componentWillRecieveProps: 1, + componentWillUpdate: 1, + componentDidUpdate: 1, + componentWillMount: 1, + componentDidMount: 1, + componentWillUnmount: 1, + componentDidUnmount: 1 +}; + +function F() { +} + +function extend(base, props, all) { + for (var key in props) { + if (all === true || !isNullOrUndefined(props[key])) { + 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.hasOwnProperty(i)) { + (ctx[i] = v.bind(ctx)).__bound = true; + } + } +} + +function createClass(obj) { + function Cl(props) { + extend(this, obj); + Component.call(this, props); + bindAll(this); + if (this.getInitialState) { + this.state = this.getInitialState(); + } + } + + F.prototype = Component.prototype; + Cl.prototype = new F(); + Cl.prototype.constructor = Cl; + Cl.displayName = obj.displayName || 'Component'; + return Cl; +} + +function escapeText(str) { + return (str + '') + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(/\//g, '/'); +} + +function escapeAttr(str) { + return (str + '') + .replace(/&/g, '&') + .replace(/"/g, '"'); +} + +function toHyphenCase(str) { + return str.replace(/([a-zA-Z])(?=[A-Z])/g, '$1-').toLowerCase(); +} + +var voidElements = { + area: true, + base: true, + br: true, + col: true, + command: true, + embed: true, + hr: true, + img: true, + input: true, + keygen: true, + link: true, + meta: true, + param: true, + source: true, + track: true, + wbr: true +}; + +function isVoidElement(str) { + return !!voidElements[str]; +} + +function renderComponent(Component, props, children, context, isRoot) { + props = addChildrenToProps(children, props); + + if (isStatefulComponent(Component)) { + var instance = new Component(props, context); + var childContext = instance.getChildContext(); + + if (!isNullOrUndefined(childContext)) { + context = Object.assign({}, context, childContext); + } + instance.context = context; + // Block setting state - we should render only once, using latest state + instance._pendingSetState = true; + instance.componentWillMount(); + var node = instance.render(); + + instance._pendingSetState = false; + return renderNode(node, context, isRoot); + } else { + return renderNode(Component(props, context), context, isRoot); + } +} + +function renderChildren(children, context) { + if (children && isArray(children)) { + var childrenResult = []; + var insertComment = false; + + for (var i = 0; i < children.length; i++) { + var child = children[i]; + var isText = isStringOrNumber(child); + var isInvalid = isInvalidNode(child); + + if (isText || isInvalid) { + if (insertComment === true) { + if (isInvalidNode(child)) { + childrenResult.push(''); + } else { + childrenResult.push(''); + } + } + if (isText) { + childrenResult.push(escapeText(child)); + } + insertComment = true; + } else if (isArray(child)) { + childrenResult.push(''); + childrenResult.push(renderChildren(child)); + childrenResult.push(''); + insertComment = true; + } else { + insertComment = false; + childrenResult.push(renderNode(child, context, false)); + } + } + return childrenResult.join(''); + } else if (!isInvalidNode(children)) { + if (isStringOrNumber(children)) { + return escapeText(children); + } else { + return renderNode(children, context, false) || ''; + } + } + return ''; +} + +function renderStyleToString(style) { + if (isStringOrNumber(style)) { + return style; + } else { + var styles = []; + var keys = Object.keys(style); + + for (var i = 0; i < keys.length; i++) { + var styleName = keys[i]; + var value = style[styleName]; + var px = isNumber(value) && !isUnitlessNumber[styleName] ? 'px' : ''; + + if (!isNullOrUndefined(value)) { + styles.push(((toHyphenCase(styleName)) + ":" + (escapeAttr(value)) + px + ";")); + } + } + return styles.join(); + } +} + +function renderNode(node, context, isRoot) { + if (!isInvalidNode(node)) { + var bp = node.bp; + var tag = node.tag || (bp && bp.tag); + var outputAttrs = []; + var className = node.className; + var style = node.style; + + if (isFunction(tag)) { + return renderComponent(tag, node.attrs, node.children, context, isRoot); + } + if (!isNullOrUndefined(className)) { + outputAttrs.push('class="' + escapeAttr(className) + '"'); + } + if (!isNullOrUndefined(style)) { + outputAttrs.push('style="' + renderStyleToString(style) + '"'); + } + var attrs = node.attrs; + var attrKeys = (attrs && Object.keys(attrs)) || []; + var html = ''; + + if (bp && bp.hasAttrs === true) { + attrKeys = bp.attrKeys ? bp.attrKeys.concat(attrKeys) : attrKeys; + } + attrKeys.forEach(function (attrsKey, i) { + var attr = attrKeys[i]; + var value = attrs[attr]; + + if (attr === 'dangerouslySetInnerHTML') { + html = value.__html; + } else { + if (isStringOrNumber(value)) { + outputAttrs.push(escapeAttr(attr) + '="' + escapeAttr(value) + '"'); + } else if (isTrue(value)) { + outputAttrs.push(escapeAttr(attr)); + } + } + }); + + if (isRoot) { + outputAttrs.push('data-infernoroot'); + } + if (isVoidElement(tag)) { + return ("<" + tag + (outputAttrs.length > 0 ? ' ' + outputAttrs.join(' ') : '') + ">"); + } else { + return ("<" + tag + (outputAttrs.length > 0 ? ' ' + outputAttrs.join(' ') : '') + ">" + (html || renderChildren(node.children, context)) + ""); + } + } +} + +function renderToString(node) { + return renderNode(node, null, false); +} + +function renderToStaticMarkup(node) { + return renderNode(node, null, true); +} + +var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {} + +function interopDefault(ex) { + return ex && typeof ex === 'object' && 'default' in ex ? ex['default'] : ex; +} + +function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; +} + +var index$1 = createCommonjsModule(function (module, exports) { +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define('PropTypes', ['exports', 'module'], factory); + } else if (typeof exports !== 'undefined' && typeof module !== 'undefined') { + factory(exports, module); + } else { + var mod = { + exports: {} + }; + factory(mod.exports, mod); + global.PropTypes = mod.exports; } +})(commonjsGlobal, function (exports, module) { - var Component = function Component(props, context) { - if ( context === void 0 ) context = {}; - - /** @type {object} */ - this.props = props || {}; - - /** @type {object} */ - this.state = {}; - - /** @type {object} */ - this.refs = {}; - this._blockRender = false; - this._blockSetState = false; - this._deferSetState = false; - this._pendingSetState = false; - this._pendingState = {}; - this._parentNode = null; - this._lastNode = null; - this._unmounted = true; - this.context = context; - this._patch = null; - this._parentComponent = null; - this._componentToDOMNodeMap = null; - }; + 'use strict'; - Component.prototype.render = function render () { - }; + var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7; - Component.prototype.forceUpdate = function forceUpdate (callback) { - if (this._unmounted) { - throw Error(noOp); - } - applyState(this, true, callback); - }; + var ReactElement = {}; - Component.prototype.setState = function setState (newState, callback) { - if (this._unmounted) { - throw Error(noOp); - } - if (this._blockSetState === false) { - queueStateChanges(this, newState, callback); - } else { - throw Error('Inferno Warning: Cannot update state via setState() in componentWillUpdate()'); - } + ReactElement.isValidElement = function (object) { + return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; }; - Component.prototype.componentDidMount = function componentDidMount () { + var ReactPropTypeLocationNames = { + prop: 'prop', + context: 'context', + childContext: 'child context' }; - Component.prototype.componentWillMount = function componentWillMount () { - }; - - Component.prototype.componentWillUnmount = function componentWillUnmount () { - }; - - Component.prototype.componentDidUpdate = function componentDidUpdate () { - }; - - Component.prototype.shouldComponentUpdate = function shouldComponentUpdate () { - return true; - }; - - Component.prototype.componentWillReceiveProps = function componentWillReceiveProps () { - }; - - Component.prototype.componentWillUpdate = function componentWillUpdate () { - }; - - Component.prototype.getChildContext = function getChildContext () { - }; - - Component.prototype._updateComponent = function _updateComponent (prevState, nextState, prevProps, nextProps, force) { - if (this._unmounted === true) { - this._unmounted = false; - return false; - } - if (!isNullOrUndefined(nextProps) && isNullOrUndefined(nextProps.children)) { - nextProps.children = prevProps.children; - } - if (prevProps !== nextProps || prevState !== nextState || force) { - if (prevProps !== nextProps) { - this._blockRender = true; - this.componentWillReceiveProps(nextProps); - this._blockRender = false; - if (this._pendingSetState) { - nextState = Object.assign({}, nextState, this._pendingState); - this._pendingSetState = false; - this._pendingState = {}; - } - } - var shouldUpdate = this.shouldComponentUpdate(nextProps, nextState); - - if (shouldUpdate !== false || force) { - this._blockSetState = true; - this.componentWillUpdate(nextProps, nextState); - this._blockSetState = false; - this.props = nextProps; - this.state = nextState; - return this.render(); - } - } - return NO_RENDER; - }; - - // don't autobind these methods since they already have guaranteed context. - var AUTOBIND_BLACKLIST = { - constructor: 1, - render: 1, - shouldComponentUpdate: 1, - componentWillRecieveProps: 1, - componentWillUpdate: 1, - componentDidUpdate: 1, - componentWillMount: 1, - componentDidMount: 1, - componentWillUnmount: 1, - componentDidUnmount: 1 + var emptyFunction = { + thatReturns: function thatReturns(what) { + return function () { + return what; + }; + } }; - function F() { - } - - function extend(base, props, all) { - for (var key in props) { - if (all === true || !isNullOrUndefined(props[key])) { - 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.hasOwnProperty(i)) { - (ctx[i] = v.bind(ctx)).__bound = true; - } - } - } - - function createClass(obj) { - function Cl(props) { - extend(this, obj); - Component.call(this, props); - bindAll(this); - if (this.getInitialState) { - this.state = this.getInitialState(); - } - } - - F.prototype = Component.prototype; - Cl.prototype = new F(); - Cl.prototype.constructor = Cl; - Cl.displayName = obj.displayName || 'Component'; - return Cl; - } - - function escapeText(str) { - return (str + '') - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, ''') - .replace(/\//g, '/'); - } - - function escapeAttr(str) { - return (str + '') - .replace(/&/g, '&') - .replace(/"/g, '"'); - } - - function toHyphenCase(str) { - return str.replace(/([a-zA-Z])(?=[A-Z])/g, '$1-').toLowerCase(); + var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; + var FAUX_ITERATOR_SYMBOL = '@@iterator'; + function getIteratorFn(maybeIterable) { + var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); + if (typeof iteratorFn === 'function') { + return iteratorFn; + } } - var voidElements = { - area: true, - base: true, - br: true, - col: true, - command: true, - embed: true, - hr: true, - img: true, - input: true, - keygen: true, - link: true, - meta: true, - param: true, - source: true, - track: true, - wbr: true + var ANONYMOUS = '<>'; + + var ReactPropTypes = { + array: createPrimitiveTypeChecker('array'), + bool: createPrimitiveTypeChecker('boolean'), + func: createPrimitiveTypeChecker('function'), + number: createPrimitiveTypeChecker('number'), + object: createPrimitiveTypeChecker('object'), + string: createPrimitiveTypeChecker('string'), + + any: createAnyTypeChecker(), + arrayOf: createArrayOfTypeChecker, + element: createElementTypeChecker(), + instanceOf: createInstanceTypeChecker, + node: createNodeChecker(), + objectOf: createObjectOfTypeChecker, + oneOf: createEnumTypeChecker, + oneOfType: createUnionTypeChecker, + shape: createShapeTypeChecker }; - function isVoidElement(str) { - return !!voidElements[str]; - } - - function renderComponent(Component, props, children, context, isRoot) { - props = addChildrenToProps(children, props); - - if (isStatefulComponent(Component)) { - var instance = new Component(props, context); - var childContext = instance.getChildContext(); - - if (!isNullOrUndefined(childContext)) { - context = Object.assign({}, context, childContext); - } - instance.context = context; - // Block setting state - we should render only once, using latest state - instance._pendingSetState = true; - instance.componentWillMount(); - var node = instance.render(); - - instance._pendingSetState = false; - return renderNode(node, context, isRoot); - } else { - return renderNode(Component(props, context), context, isRoot); - } - } - - function renderChildren(children, context) { - if (children && isArray(children)) { - var childrenResult = []; - var insertComment = false; - - for (var i = 0; i < children.length; i++) { - var child = children[i]; - var isText = isStringOrNumber(child); - var isInvalid = isInvalidNode(child); - - if (isText || isInvalid) { - if (insertComment === true) { - if (isInvalidNode(child)) { - childrenResult.push(''); - } else { - childrenResult.push(''); - } - } - if (isText) { - childrenResult.push(escapeText(child)); - } - insertComment = true; - } else if (isArray(child)) { - childrenResult.push(''); - childrenResult.push(renderChildren(child)); - childrenResult.push(''); - insertComment = true; - } else { - insertComment = false; - childrenResult.push(renderNode(child, context, false)); - } - } - return childrenResult.join(''); - } else if (!isInvalidNode(children)) { - if (isStringOrNumber(children)) { - return escapeText(children); - } else { - return renderNode(children, context, false) || ''; - } - } - return ''; - } - - function renderStyleToString(style) { - if (isStringOrNumber(style)) { - return style; - } else { - var styles = []; - var keys = Object.keys(style); - - for (var i = 0; i < keys.length; i++) { - var styleName = keys[i]; - var value = style[styleName]; - var px = isNumber(value) && !isUnitlessNumber[styleName] ? 'px' : ''; - - if (!isNullOrUndefined(value)) { - styles.push(((toHyphenCase(styleName)) + ":" + (escapeAttr(value)) + px + ";")); - } - } - return styles.join(); - } - } + function createChainableTypeChecker(validate) { + function checkType(isRequired, props, propName, componentName, location, propFullName) { + componentName = componentName || ANONYMOUS; + propFullName = propFullName || propName; + if (props[propName] == null) { + var locationName = ReactPropTypeLocationNames[location]; + if (isRequired) { + return new Error('Required ' + locationName + ' `' + propFullName + '` was not specified in ' + ('`' + componentName + '`.')); + } + return null; + } else { + return validate(props, propName, componentName, location, propFullName); + } + } - function renderNode(node, context, isRoot) { - if (!isInvalidNode(node)) { - var bp = node.bp; - var tag = node.tag || (bp && bp.tag); - var outputAttrs = []; - var className = node.className; - var style = node.style; - - if (isFunction(tag)) { - return renderComponent(tag, node.attrs, node.children, context, isRoot); - } - if (!isNullOrUndefined(className)) { - outputAttrs.push('class="' + escapeAttr(className) + '"'); - } - if (!isNullOrUndefined(style)) { - outputAttrs.push('style="' + renderStyleToString(style) + '"'); - } - var attrs = node.attrs; - var attrKeys = (attrs && Object.keys(attrs)) || []; - var html = ''; - - if (bp && bp.hasAttrs === true) { - attrKeys = bp.attrKeys ? bp.attrKeys.concat(attrKeys) : attrKeys; - } - attrKeys.forEach(function (attrsKey, i) { - var attr = attrKeys[i]; - var value = attrs[attr]; - - if (attr === 'dangerouslySetInnerHTML') { - html = value.__html; - } else { - if (isStringOrNumber(value)) { - outputAttrs.push(escapeAttr(attr) + '="' + escapeAttr(value) + '"'); - } else if (isTrue(value)) { - outputAttrs.push(escapeAttr(attr)); - } - } - }); - - if (isRoot) { - outputAttrs.push('data-infernoroot'); - } - if (isVoidElement(tag)) { - return ("<" + tag + (outputAttrs.length > 0 ? ' ' + outputAttrs.join(' ') : '') + ">"); - } else { - return ("<" + tag + (outputAttrs.length > 0 ? ' ' + outputAttrs.join(' ') : '') + ">" + (html || renderChildren(node.children, context)) + ""); - } - } - } + var chainedCheckType = checkType.bind(null, false); + chainedCheckType.isRequired = checkType.bind(null, true); - function renderToString(node) { - return renderNode(node, null, false); + return chainedCheckType; } - function renderToStaticMarkup(node) { - return renderNode(node, null, true); - } + function createPrimitiveTypeChecker(expectedType) { + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== expectedType) { + var locationName = ReactPropTypeLocationNames[location]; - var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {} + var preciseType = getPreciseType(propValue); - function interopDefault(ex) { - return ex && typeof ex === 'object' && 'default' in ex ? ex['default'] : ex; + return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.')); + } + return null; + } + return createChainableTypeChecker(validate); } - function createCommonjsModule(fn, module) { - return module = { exports: {} }, fn(module, module.exports), module.exports; + function createAnyTypeChecker() { + return createChainableTypeChecker(emptyFunction.thatReturns(null)); } - var index$1 = createCommonjsModule(function (module, exports) { - (function (global, factory) { - if (typeof define === 'function' && define.amd) { - define('PropTypes', ['exports', 'module'], factory); - } else if (typeof exports !== 'undefined' && typeof module !== 'undefined') { - factory(exports, module); - } else { - var mod = { - exports: {} - }; - factory(mod.exports, mod); - global.PropTypes = mod.exports; + function createArrayOfTypeChecker(typeChecker) { + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + if (!Array.isArray(propValue)) { + var locationName = ReactPropTypeLocationNames[location]; + var propType = getPropType(propValue); + return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.')); + } + for (var i = 0; i < propValue.length; i++) { + var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']'); + if (error instanceof Error) { + return error; + } + } + return null; } - })(commonjsGlobal, function (exports, module) { - - 'use strict'; - - var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7; - - var ReactElement = {}; - - ReactElement.isValidElement = function (object) { - return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; - }; - - var ReactPropTypeLocationNames = { - prop: 'prop', - context: 'context', - childContext: 'child context' - }; + return createChainableTypeChecker(validate); + } - var emptyFunction = { - thatReturns: function thatReturns(what) { - return function () { - return what; - }; + function createElementTypeChecker() { + function validate(props, propName, componentName, location, propFullName) { + if (!ReactElement.isValidElement(props[propName])) { + var locationName = ReactPropTypeLocationNames[location]; + return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a single ReactElement.')); } - }; + return null; + } + return createChainableTypeChecker(validate); + } - var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; - var FAUX_ITERATOR_SYMBOL = '@@iterator'; - function getIteratorFn(maybeIterable) { - var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); - if (typeof iteratorFn === 'function') { - return iteratorFn; + function createInstanceTypeChecker(expectedClass) { + function validate(props, propName, componentName, location, propFullName) { + if (!(props[propName] instanceof expectedClass)) { + var locationName = ReactPropTypeLocationNames[location]; + var expectedClassName = expectedClass.name || ANONYMOUS; + var actualClassName = getClassName(props[propName]); + return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.')); } + return null; } + return createChainableTypeChecker(validate); + } - var ANONYMOUS = '<>'; - - var ReactPropTypes = { - array: createPrimitiveTypeChecker('array'), - bool: createPrimitiveTypeChecker('boolean'), - func: createPrimitiveTypeChecker('function'), - number: createPrimitiveTypeChecker('number'), - object: createPrimitiveTypeChecker('object'), - string: createPrimitiveTypeChecker('string'), - - any: createAnyTypeChecker(), - arrayOf: createArrayOfTypeChecker, - element: createElementTypeChecker(), - instanceOf: createInstanceTypeChecker, - node: createNodeChecker(), - objectOf: createObjectOfTypeChecker, - oneOf: createEnumTypeChecker, - oneOfType: createUnionTypeChecker, - shape: createShapeTypeChecker - }; + function createEnumTypeChecker(expectedValues) { + if (!Array.isArray(expectedValues)) { + return createChainableTypeChecker(function () { + return new Error('Invalid argument supplied to oneOf, expected an instance of array.'); + }); + } - function createChainableTypeChecker(validate) { - function checkType(isRequired, props, propName, componentName, location, propFullName) { - componentName = componentName || ANONYMOUS; - propFullName = propFullName || propName; - if (props[propName] == null) { - var locationName = ReactPropTypeLocationNames[location]; - if (isRequired) { - return new Error('Required ' + locationName + ' `' + propFullName + '` was not specified in ' + ('`' + componentName + '`.')); - } + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + for (var i = 0; i < expectedValues.length; i++) { + if (propValue === expectedValues[i]) { return null; - } else { - return validate(props, propName, componentName, location, propFullName); } } - var chainedCheckType = checkType.bind(null, false); - chainedCheckType.isRequired = checkType.bind(null, true); - - return chainedCheckType; + var locationName = ReactPropTypeLocationNames[location]; + var valuesString = JSON.stringify(expectedValues); + return new Error('Invalid ' + locationName + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); } + return createChainableTypeChecker(validate); + } - function createPrimitiveTypeChecker(expectedType) { - function validate(props, propName, componentName, location, propFullName) { - var propValue = props[propName]; - var propType = getPropType(propValue); - if (propType !== expectedType) { - var locationName = ReactPropTypeLocationNames[location]; - - var preciseType = getPreciseType(propValue); - - return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.')); - } - return null; + function createObjectOfTypeChecker(typeChecker) { + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== 'object') { + var locationName = ReactPropTypeLocationNames[location]; + return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); } - return createChainableTypeChecker(validate); - } - - function createAnyTypeChecker() { - return createChainableTypeChecker(emptyFunction.thatReturns(null)); - } - - function createArrayOfTypeChecker(typeChecker) { - function validate(props, propName, componentName, location, propFullName) { - var propValue = props[propName]; - if (!Array.isArray(propValue)) { - var locationName = ReactPropTypeLocationNames[location]; - var propType = getPropType(propValue); - return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.')); - } - for (var i = 0; i < propValue.length; i++) { - var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']'); + for (var key in propValue) { + if (propValue.hasOwnProperty(key)) { + var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key); if (error instanceof Error) { return error; } } - return null; } - return createChainableTypeChecker(validate); + return null; } + return createChainableTypeChecker(validate); + } - function createElementTypeChecker() { - function validate(props, propName, componentName, location, propFullName) { - if (!ReactElement.isValidElement(props[propName])) { - var locationName = ReactPropTypeLocationNames[location]; - return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a single ReactElement.')); - } - return null; - } - return createChainableTypeChecker(validate); + function createUnionTypeChecker(arrayOfTypeCheckers) { + if (!Array.isArray(arrayOfTypeCheckers)) { + return createChainableTypeChecker(function () { + return new Error('Invalid argument supplied to oneOfType, expected an instance of array.'); + }); } - function createInstanceTypeChecker(expectedClass) { - function validate(props, propName, componentName, location, propFullName) { - if (!(props[propName] instanceof expectedClass)) { - var locationName = ReactPropTypeLocationNames[location]; - var expectedClassName = expectedClass.name || ANONYMOUS; - var actualClassName = getClassName(props[propName]); - return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.')); - } - return null; - } - return createChainableTypeChecker(validate); - } - - function createEnumTypeChecker(expectedValues) { - if (!Array.isArray(expectedValues)) { - return createChainableTypeChecker(function () { - return new Error('Invalid argument supplied to oneOf, expected an instance of array.'); - }); - } - - function validate(props, propName, componentName, location, propFullName) { - var propValue = props[propName]; - for (var i = 0; i < expectedValues.length; i++) { - if (propValue === expectedValues[i]) { - return null; - } + function validate(props, propName, componentName, location, propFullName) { + for (var i = 0; i < arrayOfTypeCheckers.length; i++) { + var checker = arrayOfTypeCheckers[i]; + if (checker(props, propName, componentName, location, propFullName) == null) { + return null; } - - var locationName = ReactPropTypeLocationNames[location]; - var valuesString = JSON.stringify(expectedValues); - return new Error('Invalid ' + locationName + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); } - return createChainableTypeChecker(validate); - } - function createObjectOfTypeChecker(typeChecker) { - function validate(props, propName, componentName, location, propFullName) { - var propValue = props[propName]; - var propType = getPropType(propValue); - if (propType !== 'object') { - var locationName = ReactPropTypeLocationNames[location]; - return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); - } - for (var key in propValue) { - if (propValue.hasOwnProperty(key)) { - var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key); - if (error instanceof Error) { - return error; - } - } - } - return null; - } - return createChainableTypeChecker(validate); + var locationName = ReactPropTypeLocationNames[location]; + return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.')); } + return createChainableTypeChecker(validate); + } - function createUnionTypeChecker(arrayOfTypeCheckers) { - if (!Array.isArray(arrayOfTypeCheckers)) { - return createChainableTypeChecker(function () { - return new Error('Invalid argument supplied to oneOfType, expected an instance of array.'); - }); - } - - function validate(props, propName, componentName, location, propFullName) { - for (var i = 0; i < arrayOfTypeCheckers.length; i++) { - var checker = arrayOfTypeCheckers[i]; - if (checker(props, propName, componentName, location, propFullName) == null) { - return null; - } - } - + function createNodeChecker() { + function validate(props, propName, componentName, location, propFullName) { + if (!isNode(props[propName])) { var locationName = ReactPropTypeLocationNames[location]; - return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.')); + return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.')); } - return createChainableTypeChecker(validate); + return null; } + return createChainableTypeChecker(validate); + } - function createNodeChecker() { - function validate(props, propName, componentName, location, propFullName) { - if (!isNode(props[propName])) { - var locationName = ReactPropTypeLocationNames[location]; - return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.')); - } - return null; + function createShapeTypeChecker(shapeTypes) { + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== 'object') { + var locationName = ReactPropTypeLocationNames[location]; + return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); } - return createChainableTypeChecker(validate); - } - - function createShapeTypeChecker(shapeTypes) { - function validate(props, propName, componentName, location, propFullName) { - var propValue = props[propName]; - var propType = getPropType(propValue); - if (propType !== 'object') { - var locationName = ReactPropTypeLocationNames[location]; - return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); + for (var key in shapeTypes) { + var checker = shapeTypes[key]; + if (!checker) { + continue; } - for (var key in shapeTypes) { - var checker = shapeTypes[key]; - if (!checker) { - continue; - } - var error = checker(propValue, key, componentName, location, propFullName + '.' + key); - if (error) { - return error; - } + var error = checker(propValue, key, componentName, location, propFullName + '.' + key); + if (error) { + return error; } - return null; } - return createChainableTypeChecker(validate); + return null; } - - function isNode(propValue) { - switch (typeof propValue) { - case 'number': - case 'string': - case 'undefined': + return createChainableTypeChecker(validate); + } + + function isNode(propValue) { + switch (typeof propValue) { + case 'number': + case 'string': + case 'undefined': + return true; + case 'boolean': + return !propValue; + case 'object': + if (Array.isArray(propValue)) { + return propValue.every(isNode); + } + if (propValue === null || ReactElement.isValidElement(propValue)) { return true; - case 'boolean': - return !propValue; - case 'object': - if (Array.isArray(propValue)) { - return propValue.every(isNode); - } - if (propValue === null || ReactElement.isValidElement(propValue)) { - return true; - } + } - var iteratorFn = getIteratorFn(propValue); - if (iteratorFn) { - var iterator = iteratorFn.call(propValue); - var step; - if (iteratorFn !== propValue.entries) { - while (!(step = iterator.next()).done) { - if (!isNode(step.value)) { - return false; - } + var iteratorFn = getIteratorFn(propValue); + if (iteratorFn) { + var iterator = iteratorFn.call(propValue); + var step; + if (iteratorFn !== propValue.entries) { + while (!(step = iterator.next()).done) { + if (!isNode(step.value)) { + return false; } - } else { - while (!(step = iterator.next()).done) { - var entry = step.value; - if (entry) { - if (!isNode(entry[1])) { - return false; - } + } + } else { + while (!(step = iterator.next()).done) { + var entry = step.value; + if (entry) { + if (!isNode(entry[1])) { + return false; } } } - } else { - return false; } - - return true; - default: + } else { return false; - } - } + } - function getPropType(propValue) { - var propType = typeof propValue; - if (Array.isArray(propValue)) { - return 'array'; - } - if (propValue instanceof RegExp) { - return 'object'; - } - return propType; + return true; + default: + return false; } + } - function getPreciseType(propValue) { - var propType = getPropType(propValue); - if (propType === 'object') { - if (propValue instanceof Date) { - return 'date'; - } else if (propValue instanceof RegExp) { - return 'regexp'; - } - } - return propType; + function getPropType(propValue) { + var propType = typeof propValue; + if (Array.isArray(propValue)) { + return 'array'; } - - function getClassName(propValue) { - if (!propValue.constructor || !propValue.constructor.name) { - return ANONYMOUS; - } - return propValue.constructor.name; + if (propValue instanceof RegExp) { + return 'object'; } - - module.exports = ReactPropTypes; - }); - - }); - - var PropTypes = interopDefault(index$1); - - function unmountComponentAtNode(container) { - render(null, container); - return true; + return propType; } - function cloneElement(element, props) { - var children = [], len = arguments.length - 2; - while ( len-- > 0 ) children[ len ] = arguments[ len + 2 ]; - - return createElement.apply( - void 0, [ element.tag, - Object.assign({}, - element.attrs || {}, - props || {}, - element.className ? { className: element.className } : {}, - element.style ? { style: element.style } : {}, - element.key ? { key: element.key } : {}, - element.hooks || {}, - element.events || {} - ) ].concat( children ) - ); + function getPreciseType(propValue) { + var propType = getPropType(propValue); + if (propType === 'object') { + if (propValue instanceof Date) { + return 'date'; + } else if (propValue instanceof RegExp) { + return 'regexp'; + } + } + return propType; } - var ARR = []; - - var Children = { - map: function map(children, fn, ctx) { - children = Children.toArray(children); - if (ctx && ctx!==children) fn = fn.bind(ctx); - return children.map(fn); - }, - forEach: function forEach(children, fn, ctx) { - children = Children.toArray(children); - if (ctx && ctx!==children) fn = fn.bind(ctx); - children.forEach(fn); - }, - 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) { - return Array.isArray && Array.isArray(children) ? children : ARR.concat(children); - } - }; - - Component.prototype.isReactComponent = {}; - - var index = { - render: render, - createElement: createElement, - Component: Component, - unmountComponentAtNode: unmountComponentAtNode, - cloneElement: cloneElement, - PropTypes: PropTypes, - createClass: createClass, - findDOMNode: findDOMNode, - renderToString: renderToString, - renderToStaticMarkup: renderToStaticMarkup, - createBlueprint: createBlueprint, - createVNode: createVNode, - Children: Children - }; - - exports.render = render; - exports.createElement = createElement; - exports.Component = Component; - exports.unmountComponentAtNode = unmountComponentAtNode; - exports.cloneElement = cloneElement; - exports.PropTypes = PropTypes; - exports.createClass = createClass; - exports.findDOMNode = findDOMNode; - exports.renderToString = renderToString; - exports.renderToStaticMarkup = renderToStaticMarkup; - exports.createBlueprint = createBlueprint; - exports.createVNode = createVNode; - exports.Children = Children; - exports['default'] = index; - - Object.defineProperty(exports, '__esModule', { value: true }); - -})); \ No newline at end of file + function getClassName(propValue) { + if (!propValue.constructor || !propValue.constructor.name) { + return ANONYMOUS; + } + return propValue.constructor.name; + } + + module.exports = ReactPropTypes; +}); + +}); + +var PropTypes = interopDefault(index$1); + +function unmountComponentAtNode(container) { + render(null, container); + return true; +} + +function cloneElement(element, props) { + var children = [], len = arguments.length - 2; + while ( len-- > 0 ) children[ len ] = arguments[ len + 2 ]; + + return createElement.apply( + void 0, [ element.tag, + Object.assign({}, + element.attrs || {}, + props || {}, + element.className ? { className: element.className } : {}, + element.style ? { style: element.style } : {}, + element.key ? { key: element.key } : {}, + element.hooks || {}, + element.events || {} + ) ].concat( children ) + ); +} + +var ARR = []; + +var Children = { + map: function map(children, fn, ctx) { + children = Children.toArray(children); + if (ctx && ctx!==children) fn = fn.bind(ctx); + return children.map(fn); + }, + forEach: function forEach(children, fn, ctx) { + children = Children.toArray(children); + if (ctx && ctx!==children) fn = fn.bind(ctx); + children.forEach(fn); + }, + 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) { + return Array.isArray && Array.isArray(children) ? children : ARR.concat(children); + } +}; + +Component.prototype.isReactComponent = {}; + +var index = { + render: render, + createElement: createElement, + Component: Component, + unmountComponentAtNode: unmountComponentAtNode, + cloneElement: cloneElement, + PropTypes: PropTypes, + createClass: createClass, + findDOMNode: findDOMNode, + renderToString: renderToString, + renderToStaticMarkup: renderToStaticMarkup, + createBlueprint: createBlueprint, + createVNode: createVNode, + Children: Children +}; + +exports.render = render; +exports.createElement = createElement; +exports.Component = Component; +exports.unmountComponentAtNode = unmountComponentAtNode; +exports.cloneElement = cloneElement; +exports.PropTypes = PropTypes; +exports.createClass = createClass; +exports.findDOMNode = findDOMNode; +exports.renderToString = renderToString; +exports.renderToStaticMarkup = renderToStaticMarkup; +exports.createBlueprint = createBlueprint; +exports.createVNode = createVNode; +exports.Children = Children; +exports['default'] = index; + +Object.defineProperty(exports, '__esModule', { value: true }); + +}))); \ No newline at end of file diff --git a/packages/inferno/dist/inferno-compat.min.js b/packages/inferno/dist/inferno-compat.min.js index 43d803b01..87e58a383 100644 --- a/packages/inferno/dist/inferno-compat.min.js +++ b/packages/inferno/dist/inferno-compat.min.js @@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.InfernoCompat=e.InfernoCompat||{})}(this,function(e){"use strict";function t(e,t){if(!i(e)){var r=n(e);(r&&e.length>0||!r)&&(t=t?Object.assign({},t,{children:e}):{children:e})}return t}function n(e){return e instanceof Array}function r(e){return e.prototype&&void 0!==e.prototype.render}function o(e){return u(e)||c(e)}function i(e){return p(e)||d(e)}function l(e){return d(e)||e===!1||e===!0||p(e)}function a(e){return"function"==typeof e}function s(e){return"o"===e[0]&&"n"===e[1]&&e.length>3}function u(e){return"string"==typeof e}function c(e){return"number"==typeof e}function d(e){return null===e}function f(e){return e===!0}function p(e){return void 0===e}function h(e){return"onCreated"===e||"onAttached"===e||"onWillDetach"===e||"onWillUpdate"===e||"onDidUpdate"===e}function m(e){return"onComponentWillMount"===e||"onComponentDidMount"===e||"onComponentWillUnmount"===e||"onComponentShouldUpdate"===e||"onComponentWillUpdate"===e||"onComponentDidUpdate"===e}function v(e,t){if(!l(e))if(n(e))for(var r=0;r0)for(var l=0;l3}function N(e){return"onCreated"===e||"onAttached"===e||"onWillDetach"===e||"onWillUpdate"===e||"onDidUpdate"===e}function E(e){return"onComponentWillMount"===e||"onComponentDidMount"===e||"onComponentWillUnmount"===e||"onComponentShouldUpdate"===e||"onComponentWillUpdate"===e||"onComponentDidUpdate"===e}function O(e,t){var n=e.tag||null,r=!(!n||void 0===n.arg),o=i(e.children)?null:e.children,l=!(!o||void 0===o.arg),a=e.attrs||null,s=!(!a||void 0===a.arg),u=e.hooks||null,c=!(!u||void 0===u.arg),d=e.events||null,f=!(!d||void 0===d.arg),p=void 0===e.key?null:e.key,h=!i(p)&&!i(p.arg),m=e.style||null,v=!(!m||void 0===m.arg),y=void 0===e.className?null:e.className,g=!(!y||void 0===y.arg),b=void 0===e.spread?null:e.spread,k=void 0!==e.spread,w={lazy:e.lazy||!1,dom:null,pool:[],tag:r?null:n,className:""!==y&&y?y:null,style:""!==m&&m?m:null,isComponent:r,hasAttrs:s||!!a,hasHooks:c,hasEvents:f,hasStyle:v||!(""===m||!m),hasClassName:g||!(""===y||!y),childrenType:void 0===t?o?5:0:t,attrKeys:null,eventKeys:null,isSVG:e.isSVG||!1};return function(){var e=new C(w);if(r===!0&&(e.tag=arguments[n.arg]),l===!0&&(e.children=arguments[o.arg]),k){var t,i,x,S=arguments[b.arg],O=[],j=[];for(var U in S){var A=S[U];"className"===U||"class"===U&&!w.isSVG?(e.className=A,w.hasClassName=!0):"style"===U?(e.style=A,w.hasStyle=!0):"key"===U?e.key=A:N(U)||E(U)?(x||(x={}),x[U[2].toLowerCase()+U.substring(3)]=A):_(U)?(i||(i={}),j.push(U.toLowerCase()),i[U.toLowerCase()]=A):"children"===U?(e.children=A,w.childrenType=w.childrenType||5):(t||(t={}),O.push(U),t[U]=A)}t&&(e.attrs=t,w.attrKeys=O,w.hasAttrs=!0),i&&(e.events=i,w.eventKeys=j,w.hasEvents=!0),x&&(e.hooks=x,w.hasHooks=!0)}else s===!0?e.attrs=arguments[a.arg]:e.attrs=a,c===!0&&(e.hooks=arguments[u.arg]),f===!0&&(e.events=arguments[d.arg]),h===!0?e.key=arguments[p.arg]:e.key=p,v===!0?e.style=arguments[m.arg]:e.style=w.style,g===!0?e.className=arguments[y.arg]:e.className=w.className;return e}}function j(e){this.text=e,this.dom=null}function U(){this.placeholder=!0,this.dom=null}function A(e){this.dom=null,this.pointer=null,this.items=e}function M(e){return new j(e)}function D(){return new U}function T(e){return new A(e)}function W(e,t,n){e.split(",").forEach(function(e){return t[e]=n})}function I(e){return void 0!==e.text}function V(e){return e.placeholder===!0}function R(e){return void 0!==e.items}function G(e){return void 0!==e.tag||void 0!==e.bp}function K(e,t,n){i(n)?e.appendChild(t):e.insertBefore(t,n)}function L(e,t,n){var r=t.pointer;w(t,e,!1),z(e,n,r)}function H(e,t){var n;return n=t===!0?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e)}function P(e,t,n){if(null===t)return document.createTextNode(e);if(n){if(""!==e)return t.textContent=e,t.firstChild;var r=document.createTextNode("");return t.appendChild(r),r}var o=document.createTextNode(e);return t.appendChild(o),o}function Y(e,t,n,r,o,l,a){var s=null,u=e._lastNode;i(u)||(s=e,e=u),k(e,!1);var c=le(t,null,r,o,l,a);t.dom=c,z(n,c,e.dom),null!==s&&(s._lastNode=t)}function z(e,t,n){e.replaceChild(t,n)}function X(e){return o(e)?M(e):l(e)?D():n(e)?T(e):e}function q(e,t){var n=e[t];return e[t]=X(n)}function F(e,t){if(R(e))return k(e,t);var n=e.dom;n===t?n.innerHTML="":(B(t,n),Ct&&b(e)),k(e,!1)}function B(e,t){e.removeChild(t)}function $(e,t,n){for(var r=t||Object.keys(e),o=0;o5)for(var r=0;rs.screenHeight)&&setClipNode(C,b,e,t,a,s,u,c,n.isSVG))return;if(C.bottom0||w>0)if(5===w||5===k)_e(e,t,b,s,u,c);else{var S=e.children,_=t.children;0===k||l(S)?w>2?ve(_,b,s,u,c):le(_,b,s,u,c):0===w||l(_)?k>2?J(b,S):F(S,b):S!==_&&(4===k&&4===w?Re(S,_,b,s,u,c,o.isSVG,null):2===k&&2===w?xe(S,_,b,s,u,c,!0,o.isSVG):1===k&&1===w?Ce(b,S,_):_e(e,t,b,s,u,c,o.isSVG))}if(n.hasAttrs!==!0&&o.hasAttrs!==!0||je(e,t,n.attrKeys,o.attrKeys,b,c),n.hasEvents!==!0&&o.hasEvents!==!0||Ae(e.events,t.events,n.eventKeys,o.eventKeys,b),n.hasClassName===!0||o.hasClassName===!0){var N=t.className;e.className!==N&&(i(N)?b.removeAttribute("class"):b.className=N)}if(n.hasStyle===!0||o.hasStyle===!0){var E=t.style,O=e.style;O!==E&&Ue(O,E,b)}o.hasHooks!==!0||i(f.didUpdate)||f.didUpdate(b),ie(p,t)}}function Oe(e,t,n,o,l,s,u){var c=t.hooks,d=!i(c);d&&!i(c.willUpdate)&&c.willUpdate(e.dom);var f=t.tag||(i(t.bp)?null:t.bp.tag),p=e.tag||(i(e.bp)?null:e.bp.tag);if("svg"===f&&(u=!0),p!==f){var h=e.instance;a(p)?a(f)?Y(e,t,n,o,l,s,u):r(p)?(x(e,null,!0),Oe(h._lastNode,t,n,o,l,s,u)):(x(e,null,!0),Oe(h,t,n,o,l,s,u)):Y(h||e,t,n,o,l,s,u)}else if(i(p))t.dom=e.dom;else if(a(p)){if(a(f)){var m=e._instance;if(!i(m)&&m._unmounted){var v=ke(t,p,t.attrs||{},t.hooks,t.children,m,n,o,l);null!==n&&z(n,v,e.dom)}else t.instance=e.instance,t.dom=e.dom,De(!1,t,t.tag,null,null,t.instance,e.attrs||{},t.attrs||{},t.hooks,e.children,t.children,n,o,l)}}else{var y=e.dom,g=t.className,b=t.style;t.dom=y,_e(e,t,y,o,l,s,u),je(e,t,null,null,y,s),Ae(e.events,t.events,null,null,y),e.className!==g&&(i(g)?y.removeAttribute("class"):y.className=g),e.style!==b&&Ue(e.style,b,y),d&&!i(c.didUpdate)&&c.didUpdate(y),ie(f,t)}}function je(e,t,n,r,o,l){"select"===e.tag&&ne(t);var a=t.attrs,s=e.attrs,u=i(a),c=!i(s);if(!u)for(var d=r||Object.keys(a),f=d.length,p=0;pu?u:s,d=0;du)for(d=c;dd){if(h<=f)for(s=f+1f)for(;p<=d;)F(e[p++],n);else{var b,k=d-p+1,w=f-h+1,x=new Array(w);for(b=0;bC?S=!0:N=C,Ne(g,y,n,r,o,i,l,!1),O++,E=!1;break}E&&(F(g,n),_++)}else{var j=new Map;for(b=h;b<=f;b++)j.set(t[b].key,b);for(b=p;b<=d;b++)E=!0,g=e[b],OC?S=!0:N=C,Ne(g,y,n,r,o,i,l,!1),O++,E=!1)),E&&(F(g,n),_++)}var U;if(S){var A=Ge(x);for(C=A.length-1,b=w-1;b>=0;b--)x[b]===-1?(U=b+h,s=U+1=0;b--)x[b]===-1&&(U=b+h,s=U+10&&(t[r]=n[i-1]),n[i]=r)}for(i=n.length,l=n[i-1];i-- >0;)n[i]=l,l=t[l];return n}function Ke(){this._listeners=[],this.scrollX=null,this.scrollY=null,this.screenHeight=At,this.screenWidth=Ut}function Le(e,t,n){t.addListener(function(){var r=n.getBoundingClientRect();null===t.scrollY&&t.refresh(),e.clipData={top:r.top+t.scrollY,left:r.left+t.scrollX,bottom:r.bottom+t.scrollY,right:r.right+t.scrollX,pending:!1}})}function He(e,t,n,r,o,i,l){var a=t[n.i];if(I(e)){var s=e.text;if(e.dom=a,3===a.nodeType&&""!==s)a.nodeValue=s;else{var u=ue(s);z(r,u,a),t.splice(t.indexOf(a),1,u),e.dom=u}}else if(V(e))e.dom=a;else if(R(e)){var c=e.items;e.dom=document.createDocumentFragment();for(var d=0;d0?r.push(Ze(l)):r.push(null):r.push($e(l))}return r}return t&&"object"==typeof e&&void 0===e.dom?$e(e):e}function Je(e,t){for(var n=[],r=arguments.length-2;r-- >0;)n[r]=arguments[r+2];return $e({tag:e,attrs:t,children:n})}function Qe(){return document.activeElement}function et(e){e!==document.body&&document.activeElement!==e&&e.focus()}function tt(e,t,n){for(var r in t)e._pendingState[r]=t[r];e._pendingSetState?(e.state=Object.assign({},e.state,e._pendingState),e._pendingState={}):(e._pendingSetState=!0,nt(e,!1,n))}function nt(e,t,n){if((!e._deferSetState||t)&&!e._blockRender){e._pendingSetState=!1;var r=e._pendingState,o=e.state,l=Object.assign({},o,r),a=e.props;e._pendingState={};var s=e._updateComponent(o,l,a,a,t);s===wt?s=e._lastNode:i(s)&&(s=D());var u=e._lastNode,c=u.dom.parentNode,d=Qe(),f=new Ke;e._patch(u,s,c,f,e.context,e,null),e._lastNode=s,e._componentToDOMNodeMap.set(e,s.dom),e._parentNode.dom=s.dom,e.componentDidUpdate(a,o),f.trigger(),i(n)||n(),et(d)}}function rt(){}function ot(e,t,n){for(var r in t)n!==!0&&i(t[r])||(e[r]=t[r]);return e}function it(e){for(var t in e){var n=e[t];"function"!=typeof n||n.__bound||Kt.hasOwnProperty(t)||((e[t]=n.bind(e)).__bound=!0)}}function lt(e){function t(t){ot(this,e),Gt.call(this,t),it(this),this.getInitialState&&(this.state=this.getInitialState())}return rt.prototype=Gt.prototype,t.prototype=new rt,t.prototype.constructor=t,t.displayName=e.displayName||"Component",t}function at(e){return(e+"").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}function st(e){return(e+"").replace(/&/g,"&").replace(/"/g,""")}function ut(e){return e.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase()}function ct(e){return!!Lt[e]}function dt(e,n,o,l,a){if(n=t(o,n),r(e)){var s=new e(n,l),u=s.getChildContext();i(u)||(l=Object.assign({},l,u)),s.context=l,s._pendingSetState=!0,s.componentWillMount();var c=s.render();return s._pendingSetState=!1,ht(c,l,a)}return ht(e(n,l),l,a)}function ft(e,t){if(e&&n(e)){for(var r=[],i=!1,a=0;a"):r.push("")),u&&r.push(at(s)),i=!0):n(s)?(r.push(""),r.push(ft(s)),r.push(""),i=!0):(i=!1,r.push(ht(s,t,!1)))}return r.join("")}return l(e)?"":o(e)?at(e):ht(e,t,!1)||""}function pt(e){if(o(e))return e;for(var t=[],n=Object.keys(e),r=0;r0?" "+u.join(" "):"")+">":"<"+s+(u.length>0?" "+u.join(" "):"")+">"+(m||ft(e.children,t))+""}}function mt(e){return ht(e,null,!1)}function vt(e){return ht(e,null,!0)}function yt(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function gt(e,t){return t={exports:{}},e(t,t.exports),t.exports}function bt(e){return Fe(null,e),!0}function kt(e,t){for(var n=[],r=arguments.length-2;r-- >0;)n[r]=arguments[r+2];return Je.apply(void 0,[e.tag,Object.assign({},e.attrs||{},t||{},e.className?{className:e.className}:{},e.style?{style:e.style}:{},e.key?{key:e.key}:{},e.hooks||{},e.events||{})].concat(n))}var wt="NO_RENDER",xt="undefined"!=typeof window&&window.document,Ct=!0;C.prototype={setAttrs:function(e){return this.attrs=e,this},setTag:function(e){return this.tag=e,this},setStyle:function(e){return this.style=e,this},setClassName:function(e){return this.className=e,this},setChildren:function(e){return this.children=e,this},setHooks:function(e){return this.hooks=e,this},setEvents:function(e){return this.events=e,this},setKey:function(e){return this.key=e,this}};var St="http://www.w3.org/1999/xlink",_t="http://www.w3.org/XML/1998/namespace",Nt={},Et={},Ot={},jt={};W("xlink:href,xlink:arcrole,xlink:actuate,xlink:role,xlink:titlef,xlink:type",Ot,St),W("xml:base,xml:lang,xml:space",Ot,_t),W("volume,value",Nt,!0),W("muted,scoped,loop,open,checked,default,capture,disabled,selected,readonly,multiple,required,autoplay,controls,seamless,reversed,allowfullscreen,novalidate",Et,!0),W("animationIterationCount,borderImageOutset,borderImageSlice,borderImageWidth,boxFlex,boxFlexGroup,boxOrdinalGroup,columnCount,flex,flexGrow,flexPositive,flexShrink,flexNegative,flexOrder,gridRow,gridColumn,fontWeight,lineClamp,lineHeight,opacity,order,orphans,tabSize,widows,zIndex,zoom,fillOpacity,floodOpacity,stopOpacity,strokeDasharray,strokeDashoffset,strokeMiterlimit,strokeOpacity,strokeWidth,",jt,!0);var Ut=xt&&window.screen.width,At=xt&&window.screen.height,Mt=0,Dt=0,Tt=0;xt&&(window.onscroll=function(){Mt=window.scrollX,Dt=window.scrollY,Tt=performance.now()},window.resize=function(){Mt=window.scrollX,Dt=window.scrollY,Ut=window.screen.width,At=window.screen.height,Tt=performance.now()}),Ke.prototype={refresh:function(){this.scrollX=xt&&window.scrollX,this.scrollY=xt&&window.scrollY},addListener:function(e){this._listeners.push(e)},trigger:function(){for(var e=this,t=0;t0||!r)&&(t=t?Object.assign({},t,{children:e}):{children:e})}return t}function n(e){return e instanceof Array}function r(e){return e.prototype&&void 0!==e.prototype.render}function o(e){return u(e)||c(e)}function i(e){return p(e)||d(e)}function l(e){return d(e)||e===!1||e===!0||p(e)}function a(e){return"function"==typeof e}function s(e){return"o"===e[0]&&"n"===e[1]&&e.length>3}function u(e){return"string"==typeof e}function c(e){return"number"==typeof e}function d(e){return null===e}function f(e){return e===!0}function p(e){return void 0===e}function h(e){return"onCreated"===e||"onAttached"===e||"onWillDetach"===e||"onWillUpdate"===e||"onDidUpdate"===e}function m(e){return"onComponentWillMount"===e||"onComponentDidMount"===e||"onComponentWillUnmount"===e||"onComponentShouldUpdate"===e||"onComponentWillUpdate"===e||"onComponentDidUpdate"===e}function v(e,t){if(!l(e))if(n(e))for(var r=0;r0)for(var l=0;l3}function N(e){return"onCreated"===e||"onAttached"===e||"onWillDetach"===e||"onWillUpdate"===e||"onDidUpdate"===e}function E(e){return"onComponentWillMount"===e||"onComponentDidMount"===e||"onComponentWillUnmount"===e||"onComponentShouldUpdate"===e||"onComponentWillUpdate"===e||"onComponentDidUpdate"===e}function O(e,t){var n=e.tag||null,r=!(!n||void 0===n.arg),o=i(e.children)?null:e.children,l=!(!o||void 0===o.arg),a=e.attrs||null,s=!(!a||void 0===a.arg),u=e.hooks||null,c=!(!u||void 0===u.arg),d=e.events||null,f=!(!d||void 0===d.arg),p=void 0===e.key?null:e.key,h=!i(p)&&!i(p.arg),m=e.style||null,v=!(!m||void 0===m.arg),y=void 0===e.className?null:e.className,g=!(!y||void 0===y.arg),b=void 0===e.spread?null:e.spread,k=void 0!==e.spread,w={lazy:e.lazy||!1,dom:null,pool:[],tag:r?null:n,className:""!==y&&y?y:null,style:""!==m&&m?m:null,isComponent:r,hasAttrs:s||!!a,hasHooks:c,hasEvents:f,hasStyle:v||!(""===m||!m),hasClassName:g||!(""===y||!y),childrenType:void 0===t?o?5:0:t,attrKeys:null,eventKeys:null,isSVG:e.isSVG||!1};return function(){var e=new C(w);if(r===!0&&(e.tag=arguments[n.arg]),l===!0&&(e.children=arguments[o.arg]),k){var t,i,x,S=arguments[b.arg],O=[],j=[];for(var U in S){var A=S[U];"className"===U||"class"===U&&!w.isSVG?(e.className=A,w.hasClassName=!0):"style"===U?(e.style=A,w.hasStyle=!0):"key"===U?e.key=A:N(U)||E(U)?(x||(x={}),x[U[2].toLowerCase()+U.substring(3)]=A):_(U)?(i||(i={}),j.push(U.toLowerCase()),i[U.toLowerCase()]=A):"children"===U?(e.children=A,w.childrenType=w.childrenType||5):(t||(t={}),O.push(U),t[U]=A)}t&&(e.attrs=t,w.attrKeys=O,w.hasAttrs=!0),i&&(e.events=i,w.eventKeys=j,w.hasEvents=!0),x&&(e.hooks=x,w.hasHooks=!0)}else s===!0?e.attrs=arguments[a.arg]:e.attrs=a,c===!0&&(e.hooks=arguments[u.arg]),f===!0&&(e.events=arguments[d.arg]),h===!0?e.key=arguments[p.arg]:e.key=p,v===!0?e.style=arguments[m.arg]:e.style=w.style,g===!0?e.className=arguments[y.arg]:e.className=w.className;return e}}function j(e){this.text=e,this.dom=null}function U(){this.placeholder=!0,this.dom=null}function A(e){this.dom=null,this.pointer=null,this.items=e}function M(e){return new j(e)}function D(){return new U}function T(e){return new A(e)}function W(e,t,n){e.split(",").forEach(function(e){return t[e]=n})}function I(e){return void 0!==e.text}function V(e){return e.placeholder===!0}function R(e){return void 0!==e.items}function G(e){return void 0!==e.tag||void 0!==e.bp}function K(e,t,n){i(n)?e.appendChild(t):e.insertBefore(t,n)}function L(e,t,n){var r=t.pointer;w(t,e,!1),z(e,n,r)}function H(e,t){var n;return n=t===!0?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e)}function P(e,t,n){if(null===t)return document.createTextNode(e);if(n){if(""!==e)return t.textContent=e,t.firstChild;var r=document.createTextNode("");return t.appendChild(r),r}var o=document.createTextNode(e);return t.appendChild(o),o}function Y(e,t,n,r,o,l,a){var s=null,u=e._lastNode;i(u)||(s=e,e=u),k(e,!1);var c=le(t,null,r,o,l,a);t.dom=c,z(n,c,e.dom),null!==s&&(s._lastNode=t)}function z(e,t,n){e.replaceChild(t,n)}function X(e){return o(e)?M(e):l(e)?D():n(e)?T(e):e}function q(e,t){var n=e[t];return e[t]=X(n)}function F(e,t){if(R(e))return k(e,t);var n=e.dom;n===t?n.innerHTML="":(B(t,n),Ct&&b(e)),k(e,!1)}function B(e,t){e.removeChild(t)}function $(e,t,n){for(var r=t||Object.keys(e),o=0;o5)for(var r=0;rs.screenHeight)&&setClipNode(C,b,e,t,a,s,u,c,n.isSVG))return;if(C.bottom0||w>0)if(5===w||5===k)_e(e,t,b,s,u,c);else{var S=e.children,_=t.children;0===k||l(S)?w>2?ve(_,b,s,u,c):le(_,b,s,u,c):0===w||l(_)?k>2?J(b,S):F(S,b):S!==_&&(4===k&&4===w?Re(S,_,b,s,u,c,o.isSVG,null):2===k&&2===w?xe(S,_,b,s,u,c,!0,o.isSVG):1===k&&1===w?Ce(b,S,_):_e(e,t,b,s,u,c,o.isSVG))}if(n.hasAttrs!==!0&&o.hasAttrs!==!0||je(e,t,n.attrKeys,o.attrKeys,b,c),n.hasEvents!==!0&&o.hasEvents!==!0||Ae(e.events,t.events,n.eventKeys,o.eventKeys,b),n.hasClassName===!0||o.hasClassName===!0){var N=t.className;e.className!==N&&(i(N)?b.removeAttribute("class"):b.className=N)}if(n.hasStyle===!0||o.hasStyle===!0){var E=t.style,O=e.style;O!==E&&Ue(O,E,b)}o.hasHooks!==!0||i(f.didUpdate)||f.didUpdate(b),ie(p,t)}}function Oe(e,t,n,o,l,s,u){var c=t.hooks,d=!i(c);d&&!i(c.willUpdate)&&c.willUpdate(e.dom);var f=t.tag||(i(t.bp)?null:t.bp.tag),p=e.tag||(i(e.bp)?null:e.bp.tag);if("svg"===f&&(u=!0),p!==f){var h=e.instance;a(p)?a(f)?Y(e,t,n,o,l,s,u):r(p)?(x(e,null,!0),Oe(h._lastNode,t,n,o,l,s,u)):(x(e,null,!0),Oe(h,t,n,o,l,s,u)):Y(h||e,t,n,o,l,s,u)}else if(i(p))t.dom=e.dom;else if(a(p)){if(a(f)){var m=e._instance;if(!i(m)&&m._unmounted){var v=ke(t,p,t.attrs||{},t.hooks,t.children,m,n,o,l);null!==n&&z(n,v,e.dom)}else t.instance=e.instance,t.dom=e.dom,De(!1,t,t.tag,null,null,t.instance,e.attrs||{},t.attrs||{},t.hooks,e.children,t.children,n,o,l)}}else{var y=e.dom,g=t.className,b=t.style;t.dom=y,_e(e,t,y,o,l,s,u),je(e,t,null,null,y,s),Ae(e.events,t.events,null,null,y),e.className!==g&&(i(g)?y.removeAttribute("class"):y.className=g),e.style!==b&&Ue(e.style,b,y),d&&!i(c.didUpdate)&&c.didUpdate(y),ie(f,t)}}function je(e,t,n,r,o,l){"select"===e.tag&&ne(t);var a=t.attrs,s=e.attrs,u=i(a),c=!i(s);if(!u)for(var d=r||Object.keys(a),f=d.length,p=0;pu?u:s,d=0;du)for(d=c;dd){if(h<=f)for(s=f+1f)for(;p<=d;)F(e[p++],n);else{var b,k=d-p+1,w=f-h+1,x=new Array(w);for(b=0;bC?S=!0:N=C,Ne(g,y,n,r,o,i,l,!1),O++,E=!1;break}E&&(F(g,n),_++)}else{var j=new Map;for(b=h;b<=f;b++)j.set(t[b].key,b);for(b=p;b<=d;b++)E=!0,g=e[b],OC?S=!0:N=C,Ne(g,y,n,r,o,i,l,!1),O++,E=!1)),E&&(F(g,n),_++)}var U;if(S){var A=Ge(x);for(C=A.length-1,b=w-1;b>=0;b--)x[b]===-1?(U=b+h,s=U+1=0;b--)x[b]===-1&&(U=b+h,s=U+10&&(t[r]=n[i-1]),n[i]=r)}for(i=n.length,l=n[i-1];i-- >0;)n[i]=l,l=t[l];return n}function Ke(){this._listeners=[],this.scrollX=null,this.scrollY=null,this.screenHeight=At,this.screenWidth=Ut}function Le(e,t,n){t.addListener(function(){var r=n.getBoundingClientRect();null===t.scrollY&&t.refresh(),e.clipData={top:r.top+t.scrollY,left:r.left+t.scrollX,bottom:r.bottom+t.scrollY,right:r.right+t.scrollX,pending:!1}})}function He(e,t,n,r,o,i,l){var a=t[n.i];if(I(e)){var s=e.text;if(e.dom=a,3===a.nodeType&&""!==s)a.nodeValue=s;else{var u=ue(s);z(r,u,a),t.splice(t.indexOf(a),1,u),e.dom=u}}else if(V(e))e.dom=a;else if(R(e)){var c=e.items;e.dom=document.createDocumentFragment();for(var d=0;d0?r.push(Ze(l)):r.push(null):r.push($e(l))}return r}return t&&"object"==typeof e&&void 0===e.dom?$e(e):e}function Je(e,t){for(var n=[],r=arguments.length-2;r-- >0;)n[r]=arguments[r+2];return $e({tag:e,attrs:t,children:n})}function Qe(){return document.activeElement}function et(e){e!==document.body&&document.activeElement!==e&&e.focus()}function tt(e,t,n){for(var r in t)e._pendingState[r]=t[r];e._pendingSetState?(e.state=Object.assign({},e.state,e._pendingState),e._pendingState={}):(e._pendingSetState=!0,nt(e,!1,n))}function nt(e,t,n){if((!e._deferSetState||t)&&!e._blockRender){e._pendingSetState=!1;var r=e._pendingState,o=e.state,l=Object.assign({},o,r),a=e.props;e._pendingState={};var s=e._updateComponent(o,l,a,a,t);s===wt?s=e._lastNode:i(s)&&(s=D());var u=e._lastNode,c=u.dom.parentNode,d=Qe(),f=new Ke;e._patch(u,s,c,f,e.context,e,null),e._lastNode=s,e._componentToDOMNodeMap.set(e,s.dom),e._parentNode.dom=s.dom,e.componentDidUpdate(a,o),f.trigger(),i(n)||n(),et(d)}}function rt(){}function ot(e,t,n){for(var r in t)n!==!0&&i(t[r])||(e[r]=t[r]);return e}function it(e){for(var t in e){var n=e[t];"function"!=typeof n||n.__bound||Kt.hasOwnProperty(t)||((e[t]=n.bind(e)).__bound=!0)}}function lt(e){function t(t){ot(this,e),Gt.call(this,t),it(this),this.getInitialState&&(this.state=this.getInitialState())}return rt.prototype=Gt.prototype,t.prototype=new rt,t.prototype.constructor=t,t.displayName=e.displayName||"Component",t}function at(e){return(e+"").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}function st(e){return(e+"").replace(/&/g,"&").replace(/"/g,""")}function ut(e){return e.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase()}function ct(e){return!!Lt[e]}function dt(e,n,o,l,a){if(n=t(o,n),r(e)){var s=new e(n,l),u=s.getChildContext();i(u)||(l=Object.assign({},l,u)),s.context=l,s._pendingSetState=!0,s.componentWillMount();var c=s.render();return s._pendingSetState=!1,ht(c,l,a)}return ht(e(n,l),l,a)}function ft(e,t){if(e&&n(e)){for(var r=[],i=!1,a=0;a"):r.push("")),u&&r.push(at(s)),i=!0):n(s)?(r.push(""),r.push(ft(s)),r.push(""),i=!0):(i=!1,r.push(ht(s,t,!1)))}return r.join("")}return l(e)?"":o(e)?at(e):ht(e,t,!1)||""}function pt(e){if(o(e))return e;for(var t=[],n=Object.keys(e),r=0;r0?" "+u.join(" "):"")+">":"<"+s+(u.length>0?" "+u.join(" "):"")+">"+(m||ft(e.children,t))+""}}function mt(e){return ht(e,null,!1)}function vt(e){return ht(e,null,!0)}function yt(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function gt(e,t){return t={exports:{}},e(t,t.exports),t.exports}function bt(e){return Fe(null,e),!0}function kt(e,t){for(var n=[],r=arguments.length-2;r-- >0;)n[r]=arguments[r+2];return Je.apply(void 0,[e.tag,Object.assign({},e.attrs||{},t||{},e.className?{className:e.className}:{},e.style?{style:e.style}:{},e.key?{key:e.key}:{},e.hooks||{},e.events||{})].concat(n))}var wt="NO_RENDER",xt="undefined"!=typeof window&&window.document,Ct=!0;C.prototype={setAttrs:function(e){return this.attrs=e,this},setTag:function(e){return this.tag=e,this},setStyle:function(e){return this.style=e,this},setClassName:function(e){return this.className=e,this},setChildren:function(e){return this.children=e,this},setHooks:function(e){return this.hooks=e,this},setEvents:function(e){return this.events=e,this},setKey:function(e){return this.key=e,this}};var St="http://www.w3.org/1999/xlink",_t="http://www.w3.org/XML/1998/namespace",Nt={},Et={},Ot={},jt={};W("xlink:href,xlink:arcrole,xlink:actuate,xlink:role,xlink:titlef,xlink:type",Ot,St),W("xml:base,xml:lang,xml:space",Ot,_t),W("volume,value",Nt,!0),W("muted,scoped,loop,open,checked,default,capture,disabled,selected,readonly,multiple,required,autoplay,controls,seamless,reversed,allowfullscreen,novalidate",Et,!0),W("animationIterationCount,borderImageOutset,borderImageSlice,borderImageWidth,boxFlex,boxFlexGroup,boxOrdinalGroup,columnCount,flex,flexGrow,flexPositive,flexShrink,flexNegative,flexOrder,gridRow,gridColumn,fontWeight,lineClamp,lineHeight,opacity,order,orphans,tabSize,widows,zIndex,zoom,fillOpacity,floodOpacity,stopOpacity,strokeDasharray,strokeDashoffset,strokeMiterlimit,strokeOpacity,strokeWidth,",jt,!0);var Ut=xt&&window.screen.width,At=xt&&window.screen.height,Mt=0,Dt=0,Tt=0;xt&&(window.onscroll=function(){Mt=window.scrollX,Dt=window.scrollY,Tt=performance.now()},window.resize=function(){Mt=window.scrollX,Dt=window.scrollY,Ut=window.screen.width,At=window.screen.height,Tt=performance.now()}),Ke.prototype={refresh:function(){this.scrollX=xt&&window.scrollX,this.scrollY=xt&&window.scrollY},addListener:function(e){this._listeners.push(e)},trigger:function(){for(var e=this,t=0;t 3; - } - - function isNull(obj) { - return obj === null; +}(this, (function () { 'use strict'; + +function isArray(obj) { + return obj instanceof Array; +} + +function isNullOrUndefined(obj) { + return isUndefined(obj) || isNull(obj); +} + +function isInvalidNode(obj) { + return isNull(obj) || obj === false || obj === true || isUndefined(obj); +} + +function isFunction(obj) { + return typeof obj === 'function'; +} + +function isAttrAnEvent$1(attr) { + return attr[0] === 'o' && attr[1] === 'n' && attr.length > 3; +} + +function isNull(obj) { + return obj === null; +} + +function isUndefined(obj) { + return obj === undefined; +} + +function isAttrAHook$1(hook) { + return hook === 'onCreated' + || hook === 'onAttached' + || hook === 'onWillDetach' + || hook === 'onWillUpdate' + || hook === 'onDidUpdate'; +} + +function isAttrAComponentHook$1(hook) { + return hook === 'onComponentWillMount' + || hook === 'onComponentDidMount' + || hook === 'onComponentWillUnmount' + || hook === 'onComponentShouldUpdate' + || hook === 'onComponentWillUpdate' + || hook === 'onComponentDidUpdate'; +} + +function VNode(blueprint) { + this.bp = blueprint; + this.dom = null; + this.instance = null; + this.tag = null; + this.children = null; + this.style = null; + this.className = null; + this.attrs = null; + this.events = null; + this.hooks = null; + this.key = null; + this.clipData = null; +} + +VNode.prototype = { + setAttrs: function setAttrs(attrs) { + this.attrs = attrs; + return this; + }, + setTag: function setTag(tag) { + this.tag = tag; + return this; + }, + setStyle: function setStyle(style) { + this.style = style; + return this; + }, + setClassName: function setClassName(className) { + this.className = className; + return this; + }, + setChildren: function setChildren(children) { + this.children = children; + return this; + }, + setHooks: function setHooks(hooks) { + this.hooks = hooks; + return this; + }, + setEvents: function setEvents(events) { + this.events = events; + return this; + }, + setKey: function setKey(key) { + this.key = key; + return this; } - - function isUndefined(obj) { - return obj === undefined; - } - - function isAttrAHook$1(hook) { - return hook === 'onCreated' - || hook === 'onAttached' - || hook === 'onWillDetach' - || hook === 'onWillUpdate' - || hook === 'onDidUpdate'; - } - - function isAttrAComponentHook$1(hook) { - return hook === 'onComponentWillMount' - || hook === 'onComponentDidMount' - || hook === 'onComponentWillUnmount' - || hook === 'onComponentShouldUpdate' - || hook === 'onComponentWillUpdate' - || hook === 'onComponentDidUpdate'; - } - - function VNode(blueprint) { - this.bp = blueprint; - this.dom = null; - this.instance = null; - this.tag = null; - this.children = null; - this.style = null; - this.className = null; - this.attrs = null; - this.events = null; - this.hooks = null; - this.key = null; - this.clipData = null; - } - - VNode.prototype = { - setAttrs: function setAttrs(attrs) { - this.attrs = attrs; - return this; - }, - setTag: function setTag(tag) { - this.tag = tag; - return this; - }, - setStyle: function setStyle(style) { - this.style = style; - return this; - }, - setClassName: function setClassName(className) { - this.className = className; - return this; - }, - setChildren: function setChildren(children) { - this.children = children; - return this; - }, - setHooks: function setHooks(hooks) { - this.hooks = hooks; - return this; - }, - setEvents: function setEvents(events) { - this.events = events; - return this; - }, - setKey: function setKey(key) { - this.key = key; - return this; +}; + +function createVNode(bp) { + return new VNode(bp); +} + +function createAttrsAndEvents(props, tag) { + var events = null; + var hooks = null; + var attrs = null; + var className = null; + var style = null; + + if (!isNullOrUndefined(props)) { + if (isArray(props)) { + return props; } - }; - - function createVNode(bp) { - return new VNode(bp); - } - - function createAttrsAndEvents(props, tag) { - var events = null; - var hooks = null; - var attrs = null; - var className = null; - var style = null; - - if (!isNullOrUndefined(props)) { - if (isArray(props)) { - return props; - } - for (var prop in props) { - if (prop === 'className') { - className = props[prop]; - } else if (prop === 'style') { - style = props[prop]; - } else if (isAttrAHook$1(prop) && !isFunction(tag)) { - if (isNullOrUndefined(hooks)) { - hooks = {}; - } - hooks[prop.substring(2).toLowerCase()] = props[prop]; - delete props[prop]; - } else if (isAttrAnEvent$1(prop) && !isFunction(tag)) { - if (isNullOrUndefined(events)) { - events = {}; - } - events[prop.toLowerCase()] = props[prop]; - delete props[prop]; - } else if (isAttrAComponentHook$1(prop) && isFunction(tag)) { - if (isNullOrUndefined(hooks)) { - hooks = {}; - } - hooks['c' + prop.substring(3)] = props[prop]; - delete props[prop]; - } else if (!isFunction(tag)) { - if (isNullOrUndefined(attrs)) { - attrs = {}; - } - attrs[prop] = props[prop]; - } else { - attrs = props; + for (var prop in props) { + if (prop === 'className') { + className = props[prop]; + } else if (prop === 'style') { + style = props[prop]; + } else if (isAttrAHook$1(prop) && !isFunction(tag)) { + if (isNullOrUndefined(hooks)) { + hooks = {}; + } + hooks[prop.substring(2).toLowerCase()] = props[prop]; + delete props[prop]; + } else if (isAttrAnEvent$1(prop) && !isFunction(tag)) { + if (isNullOrUndefined(events)) { + events = {}; } + events[prop.toLowerCase()] = props[prop]; + delete props[prop]; + } else if (isAttrAComponentHook$1(prop) && isFunction(tag)) { + if (isNullOrUndefined(hooks)) { + hooks = {}; + } + hooks['c' + prop.substring(3)] = props[prop]; + delete props[prop]; + } else if (!isFunction(tag)) { + if (isNullOrUndefined(attrs)) { + attrs = {}; + } + attrs[prop] = props[prop]; + } else { + attrs = props; } } - return { attrs: attrs, events: events, className: className, style: style, hooks: hooks }; } + return { attrs: attrs, events: events, className: className, style: style, hooks: hooks }; +} + +function createChild(ref) { + var tag = ref.tag; + var attrs = ref.attrs; + var children = ref.children; + var className = ref.className; + var style = ref.style; + var events = ref.events; + var hooks = ref.hooks; + + if (tag === undefined && !isNullOrUndefined(attrs) && !attrs.tpl && !isNullOrUndefined(children) && children.length === 0) { + return null; + } + var key = !isNullOrUndefined(attrs) && !isNullOrUndefined(attrs.key) ? attrs.key : undefined; - function createChild(ref) { - var tag = ref.tag; - var attrs = ref.attrs; - var children = ref.children; - var className = ref.className; - var style = ref.style; - var events = ref.events; - var hooks = ref.hooks; - - if (tag === undefined && !isNullOrUndefined(attrs) && !attrs.tpl && !isNullOrUndefined(children) && children.length === 0) { - return null; - } - var key = !isNullOrUndefined(attrs) && !isNullOrUndefined(attrs.key) ? attrs.key : undefined; - - if (!isNullOrUndefined(children) && children.length === 0) { - children = null; - } else if (!isInvalidNode(children)) { - children = isArray(children) && children.length === 1 ? createChildren(children[0]) : createChildren(children); - } - - if (key !== undefined) { - delete attrs.key; - } - var attrsAndEvents = createAttrsAndEvents(attrs, tag); - var vNode = createVNode(); - - className = className || attrsAndEvents.className; - style = style || attrsAndEvents.style; - - vNode.tag = tag || null; - vNode.attrs = attrsAndEvents.attrs || null; - vNode.events = attrsAndEvents.events || events; - vNode.hooks = attrsAndEvents.hooks || hooks; - vNode.children = children === undefined ? null : children; - vNode.key = key === undefined ? null : key; - vNode.className = className === undefined ? null : className; - vNode.style = style === undefined ? null : style; - - return vNode; + if (!isNullOrUndefined(children) && children.length === 0) { + children = null; + } else if (!isInvalidNode(children)) { + children = isArray(children) && children.length === 1 ? createChildren(children[0]) : createChildren(children); } - function createChildren(children) { - var childrenDefined = !isNullOrUndefined(children); - if (childrenDefined && isArray(children)) { - var newChildren = []; - - for (var i = 0; i < children.length; i++) { - var child = children[i]; - if (!isNullOrUndefined(child) && typeof child === 'object') { - if (isArray(child)) { - if (child.length > 0) { - newChildren.push(createChildren(child)); - } else { - newChildren.push(null); - } + if (key !== undefined) { + delete attrs.key; + } + var attrsAndEvents = createAttrsAndEvents(attrs, tag); + var vNode = createVNode(); + + className = className || attrsAndEvents.className; + style = style || attrsAndEvents.style; + + vNode.tag = tag || null; + vNode.attrs = attrsAndEvents.attrs || null; + vNode.events = attrsAndEvents.events || events; + vNode.hooks = attrsAndEvents.hooks || hooks; + vNode.children = children === undefined ? null : children; + vNode.key = key === undefined ? null : key; + vNode.className = className === undefined ? null : className; + vNode.style = style === undefined ? null : style; + + return vNode; +} + +function createChildren(children) { + var childrenDefined = !isNullOrUndefined(children); + if (childrenDefined && isArray(children)) { + var newChildren = []; + + for (var i = 0; i < children.length; i++) { + var child = children[i]; + if (!isNullOrUndefined(child) && typeof child === 'object') { + if (isArray(child)) { + if (child.length > 0) { + newChildren.push(createChildren(child)); } else { - newChildren.push(createChild(child)); + newChildren.push(null); } } else { - newChildren.push(child); + newChildren.push(createChild(child)); } + } else { + newChildren.push(child); } - return newChildren; - } else if (childrenDefined && typeof children === 'object') { - return children.dom === undefined ? createChild(children) : children; } - return children; + return newChildren; + } else if (childrenDefined && typeof children === 'object') { + return children.dom === undefined ? createChild(children) : children; } + return children; +} - function createElement(tag, props) { - var children = [], len = arguments.length - 2; - while ( len-- > 0 ) children[ len ] = arguments[ len + 2 ]; +function createElement(tag, props) { + var children = [], len = arguments.length - 2; + while ( len-- > 0 ) children[ len ] = arguments[ len + 2 ]; - return createChild({ tag: tag, attrs: props, children: children }); - } + return createChild({ tag: tag, attrs: props, children: children }); +} - return createElement; +return createElement; -})); \ No newline at end of file +}))); \ No newline at end of file diff --git a/packages/inferno/dist/inferno-dom.js b/packages/inferno/dist/inferno-dom.js index 077271598..f9eeb69f0 100644 --- a/packages/inferno/dist/inferno-dom.js +++ b/packages/inferno/dist/inferno-dom.js @@ -1,5 +1,5 @@ /*! - * inferno-dom v0.7.25 + * inferno-dom v0.7.26 * (c) 2016 Dominic Gannaway * Released under the MIT License. */ @@ -7,1598 +7,1565 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global.InfernoDOM = factory()); -}(this, function () { 'use strict'; - - function addChildrenToProps(children, props) { - if (!isNullOrUndefined(children)) { - var isChildrenArray = isArray(children); - if (isChildrenArray && children.length > 0 || !isChildrenArray) { - if (props) { - props = Object.assign({}, props, { children: children }); - } else { - props = { - children: children - }; - } +}(this, (function () { 'use strict'; + +function addChildrenToProps(children, props) { + if (!isNullOrUndefined(children)) { + var isChildrenArray = isArray(children); + if (isChildrenArray && children.length > 0 || !isChildrenArray) { + if (props) { + props = Object.assign({}, props, { children: children }); + } else { + props = { + children: children + }; } } - return props; } + return props; +} - var NO_RENDER = 'NO_RENDER'; +var NO_RENDER = 'NO_RENDER'; - // Runs only once in applications lifetime - var isBrowser = typeof window !== 'undefined' && window.document; +// Runs only once in applications lifetime +var isBrowser = typeof window !== 'undefined' && window.document; - function isArray(obj) { - return obj instanceof Array; - } +function isArray(obj) { + return obj instanceof Array; +} - function isStatefulComponent(obj) { - return obj.prototype && obj.prototype.render !== undefined; - } +function isStatefulComponent(obj) { + return obj.prototype && obj.prototype.render !== undefined; +} - function isStringOrNumber(obj) { - return isString(obj) || isNumber(obj); - } - - function isNullOrUndefined(obj) { - return isUndefined(obj) || isNull(obj); - } +function isStringOrNumber(obj) { + return isString(obj) || isNumber(obj); +} - function isInvalidNode(obj) { - return isNull(obj) || obj === false || obj === true || isUndefined(obj); - } +function isNullOrUndefined(obj) { + return isUndefined(obj) || isNull(obj); +} - function isFunction(obj) { - return typeof obj === 'function'; - } +function isInvalidNode(obj) { + return isNull(obj) || obj === false || obj === true || isUndefined(obj); +} - function isString(obj) { - return typeof obj === 'string'; - } +function isFunction(obj) { + return typeof obj === 'function'; +} - function isNumber(obj) { - return typeof obj === 'number'; - } +function isString(obj) { + return typeof obj === 'string'; +} - function isNull(obj) { - return obj === null; - } +function isNumber(obj) { + return typeof obj === 'number'; +} - function isTrue(obj) { - return obj === true; - } +function isNull(obj) { + return obj === null; +} - function isUndefined(obj) { - return obj === undefined; - } +function isTrue(obj) { + return obj === true; +} - function deepScanChildrenForNode(children, node) { - if (!isInvalidNode(children)) { - if (isArray(children)) { - for (var i = 0; i < children.length; i++) { - var child = children[i]; +function isUndefined(obj) { + return obj === undefined; +} - if (!isInvalidNode(child)) { - if (child === node) { - return true; - } else if (child.children) { - return deepScanChildrenForNode(child.children, node); - } +function deepScanChildrenForNode(children, node) { + if (!isInvalidNode(children)) { + if (isArray(children)) { + for (var i = 0; i < children.length; i++) { + var child = children[i]; + + if (!isInvalidNode(child)) { + if (child === node) { + return true; + } else if (child.children) { + return deepScanChildrenForNode(child.children, node); } } - } else { - if (children === node) { - return true; - } else if (children.children) { - return deepScanChildrenForNode(children.children, node); - } + } + } else { + if (children === node) { + return true; + } else if (children.children) { + return deepScanChildrenForNode(children.children, node); } } - return false; } + return false; +} - function getRefInstance$1(node, instance) { - var children = instance.props.children; +function getRefInstance$1(node, instance) { + var children = instance.props.children; - if (deepScanChildrenForNode(children, node)) { - return getRefInstance$1(node, instance._parentComponent); - } - return instance; + if (deepScanChildrenForNode(children, node)) { + return getRefInstance$1(node, instance._parentComponent); } + return instance; +} - var recyclingEnabled = true; +var recyclingEnabled = true; - function recycle(node, bp, lifecycle, context, instance) { - if (bp !== undefined) { - var pool = bp.pool; - var recycledNode = pool.pop(); +function recycle(node, bp, lifecycle, context, instance) { + if (bp !== undefined) { + var pool = bp.pool; + var recycledNode = pool.pop(); - if (!isNullOrUndefined(recycledNode)) { - patch(recycledNode, node, null, lifecycle, context, instance, bp.isSVG); - return node.dom; - } + if (!isNullOrUndefined(recycledNode)) { + patch(recycledNode, node, null, lifecycle, context, instance, bp.isSVG); + return node.dom; } - return null; } + return null; +} - function pool(node) { - var bp = node.bp; +function pool(node) { + var bp = node.bp; - if (!isNullOrUndefined(bp)) { - bp.pool.push(node); - return true; - } - return false; + if (!isNullOrUndefined(bp)) { + bp.pool.push(node); + return true; } + return false; +} - function unmount(input, parentDom) { - if (isVList(input)) { - unmountVList(input, parentDom, true); - } else if (isVNode(input)) { - unmountVNode(input, parentDom, false); - } +function unmount(input, parentDom) { + if (isVList(input)) { + unmountVList(input, parentDom, true); + } else if (isVNode(input)) { + unmountVNode(input, parentDom, false); } +} - function unmountVList(vList, parentDom, removePointer) { - var items = vList.items; - var itemsLength = items.length; - var pointer = vList.pointer; +function unmountVList(vList, parentDom, removePointer) { + var items = vList.items; + var itemsLength = items.length; + var pointer = vList.pointer; - if (itemsLength > 0) { - for (var i = 0; i < itemsLength; i++) { - var item = items[i]; + if (itemsLength > 0) { + for (var i = 0; i < itemsLength; i++) { + var item = items[i]; - if (isVList(item)) { - unmountVList(item, parentDom, true); - } else { - if (parentDom) { - removeChild(parentDom, item.dom); - } - unmount(item, null); + if (isVList(item)) { + unmountVList(item, parentDom, true); + } else { + if (parentDom) { + removeChild(parentDom, item.dom); } + unmount(item, null); } } - if (parentDom && removePointer) { - removeChild(parentDom, pointer); - } } + if (parentDom && removePointer) { + removeChild(parentDom, pointer); + } +} - function unmountVNode(node, parentDom, shallow) { - var instance = node.instance; - var instanceHooks = null; - var instanceChildren = null; +function unmountVNode(node, parentDom, shallow) { + var instance = node.instance; + var instanceHooks = null; + var instanceChildren = null; - if (!isNullOrUndefined(instance)) { - instanceHooks = instance.hooks; - instanceChildren = instance.children; + if (!isNullOrUndefined(instance)) { + instanceHooks = instance.hooks; + instanceChildren = instance.children; - if (instance.render !== undefined) { - instance.componentWillUnmount(); - instance._unmounted = true; - componentToDOMNodeMap.delete(instance); - !shallow && unmount(instance._lastNode, null); - } + if (instance.render !== undefined) { + instance.componentWillUnmount(); + instance._unmounted = true; + componentToDOMNodeMap.delete(instance); + !shallow && unmount(instance._lastNode, null); } - var hooks = node.hooks || instanceHooks; + } + var hooks = node.hooks || instanceHooks; - if (!isNullOrUndefined(hooks)) { - if (!isNullOrUndefined(hooks.willDetach)) { - hooks.willDetach(node.dom); - } - if (!isNullOrUndefined(hooks.componentWillUnmount)) { - hooks.componentWillUnmount(node.dom, hooks); - } + if (!isNullOrUndefined(hooks)) { + if (!isNullOrUndefined(hooks.willDetach)) { + hooks.willDetach(node.dom); } - var children = (isNullOrUndefined(instance) ? node.children : null) || instanceChildren; - - if (!isNullOrUndefined(children)) { - if (isArray(children)) { - for (var i = 0; i < children.length; i++) { - unmount(children[i], null); - } - } else { - unmount(children, null); - } + if (!isNullOrUndefined(hooks.componentWillUnmount)) { + hooks.componentWillUnmount(node.dom, hooks); } } + var children = (isNullOrUndefined(instance) ? node.children : null) || instanceChildren; - function VText(text) { - this.text = text; - this.dom = null; - } - - function VPlaceholder() { - this.placeholder = true; - this.dom = null; - } + if (!isNullOrUndefined(children)) { + if (isArray(children)) { + for (var i = 0; i < children.length; i++) { + unmount(children[i], null); + } + } else { + unmount(children, null); + } + } +} + +function VText(text) { + this.text = text; + this.dom = null; +} + +function VPlaceholder() { + this.placeholder = true; + this.dom = null; +} + +function VList(items) { + this.dom = null; + this.pointer = null; + this.items = items; +} + +function createVText(text) { + return new VText(text); +} + +function createVPlaceholder() { + return new VPlaceholder(); +} + +function createVList(items) { + return new VList(items); +} + +function constructDefaults(string, object, value) { + /* eslint no-return-assign: 0 */ + string.split(',').forEach(function (i) { return object[i] = value; }); +} + +var xlinkNS = 'http://www.w3.org/1999/xlink'; +var xmlNS = 'http://www.w3.org/XML/1998/namespace'; +var strictProps = {}; +var booleanProps = {}; +var namespaces = {}; +var isUnitlessNumber = {}; + +constructDefaults('xlink:href,xlink:arcrole,xlink:actuate,xlink:role,xlink:titlef,xlink:type', namespaces, xlinkNS); +constructDefaults('xml:base,xml:lang,xml:space', namespaces, xmlNS); +constructDefaults('volume,value', strictProps, true); +constructDefaults('muted,scoped,loop,open,checked,default,capture,disabled,selected,readonly,multiple,required,autoplay,controls,seamless,reversed,allowfullscreen,novalidate', booleanProps, true); +constructDefaults('animationIterationCount,borderImageOutset,borderImageSlice,borderImageWidth,boxFlex,boxFlexGroup,boxOrdinalGroup,columnCount,flex,flexGrow,flexPositive,flexShrink,flexNegative,flexOrder,gridRow,gridColumn,fontWeight,lineClamp,lineHeight,opacity,order,orphans,tabSize,widows,zIndex,zoom,fillOpacity,floodOpacity,stopOpacity,strokeDasharray,strokeDashoffset,strokeMiterlimit,strokeOpacity,strokeWidth,', isUnitlessNumber, true); + +function isVText(o) { + return o.text !== undefined; +} + +function isVPlaceholder(o) { + return o.placeholder === true; +} + +function isVList(o) { + return o.items !== undefined; +} + +function isVNode(o) { + return o.tag !== undefined || o.bp !== undefined; +} + +function insertOrAppend(parentDom, newNode, nextNode) { + if (isNullOrUndefined(nextNode)) { + parentDom.appendChild(newNode); + } else { + parentDom.insertBefore(newNode, nextNode); + } +} + +function replaceVListWithNode(parentDom, vList, dom) { + var pointer = vList.pointer; + + unmountVList(vList, parentDom, false); + replaceNode(parentDom, dom, pointer); +} + +function documentCreateElement(tag, isSVG) { + var dom; + + if (isSVG === true) { + dom = document.createElementNS('http://www.w3.org/2000/svg', tag); + } else { + dom = document.createElement(tag); + } + return dom; +} + +function appendText(text, parentDom, singleChild) { + if (parentDom === null) { + return document.createTextNode(text); + } else { + if (singleChild) { + if (text !== '') { + parentDom.textContent = text; + return parentDom.firstChild; + } else { + var textNode = document.createTextNode(''); - function VList(items) { - this.dom = null; - this.pointer = null; - this.items = items; - } + parentDom.appendChild(textNode); + return textNode; + } + } else { + var textNode$1 = document.createTextNode(text); - function createVText(text) { - return new VText(text); + parentDom.appendChild(textNode$1); + return textNode$1; + } } +} - function createVPlaceholder() { - return new VPlaceholder(); - } +function replaceWithNewNode(lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG) { + var lastInstance = null; + var instanceLastNode = lastNode._lastNode; - function createVList(items) { - return new VList(items); + if (!isNullOrUndefined(instanceLastNode)) { + lastInstance = lastNode; + lastNode = instanceLastNode; } + unmount(lastNode, false); + var dom = mount(nextNode, null, lifecycle, context, instance, isSVG); - function constructDefaults(string, object, value) { - /* eslint no-return-assign: 0 */ - string.split(',').forEach(function (i) { return object[i] = value; }); + nextNode.dom = dom; + replaceNode(parentDom, dom, lastNode.dom); + if (lastInstance !== null) { + lastInstance._lastNode = nextNode; } +} - var xlinkNS = 'http://www.w3.org/1999/xlink'; - var xmlNS = 'http://www.w3.org/XML/1998/namespace'; - var strictProps = {}; - var booleanProps = {}; - var namespaces = {}; - var isUnitlessNumber = {}; - - constructDefaults('xlink:href,xlink:arcrole,xlink:actuate,xlink:role,xlink:titlef,xlink:type', namespaces, xlinkNS); - constructDefaults('xml:base,xml:lang,xml:space', namespaces, xmlNS); - constructDefaults('volume,value', strictProps, true); - constructDefaults('muted,scoped,loop,open,checked,default,capture,disabled,selected,readonly,multiple,required,autoplay,controls,seamless,reversed,allowfullscreen,novalidate', booleanProps, true); - constructDefaults('animationIterationCount,borderImageOutset,borderImageSlice,borderImageWidth,boxFlex,boxFlexGroup,boxOrdinalGroup,columnCount,flex,flexGrow,flexPositive,flexShrink,flexNegative,flexOrder,gridRow,gridColumn,fontWeight,lineClamp,lineHeight,opacity,order,orphans,tabSize,widows,zIndex,zoom,fillOpacity,floodOpacity,stopOpacity,strokeDasharray,strokeDashoffset,strokeMiterlimit,strokeOpacity,strokeWidth,', isUnitlessNumber, true); +function replaceNode(parentDom, nextDom, lastDom) { + parentDom.replaceChild(nextDom, lastDom); +} - function isVText(o) { - return o.text !== undefined; +function normalise(object) { + if (isStringOrNumber(object)) { + return createVText(object); + } else if (isInvalidNode(object)) { + return createVPlaceholder(); + } else if (isArray(object)) { + return createVList(object); } + return object; +} - function isVPlaceholder(o) { - return o.placeholder === true; - } +function normaliseChild(children, i) { + var child = children[i]; - function isVList(o) { - return o.items !== undefined; - } + return children[i] = normalise(child); +} - function isVNode(o) { - return o.tag !== undefined || o.bp !== undefined; +function remove(node, parentDom) { + if (isVList(node)) { + return unmount(node, parentDom); } - - function insertOrAppend(parentDom, newNode, nextNode) { - if (isNullOrUndefined(nextNode)) { - parentDom.appendChild(newNode); - } else { - parentDom.insertBefore(newNode, nextNode); + var dom = node.dom; + if (dom === parentDom) { + dom.innerHTML = ''; + } else { + removeChild(parentDom, dom); + if (recyclingEnabled) { + pool(node); } } + unmount(node, false); +} - function replaceVListWithNode(parentDom, vList, dom) { - var pointer = vList.pointer; +function removeChild(parentDom, dom) { + parentDom.removeChild(dom); +} - unmountVList(vList, parentDom, false); - replaceNode(parentDom, dom, pointer); - } +function removeEvents(events, lastEventKeys, dom) { + var eventKeys = lastEventKeys || Object.keys(events); - function documentCreateElement(tag, isSVG) { - var dom; + for (var i = 0; i < eventKeys.length; i++) { + var event = eventKeys[i]; - if (isSVG === true) { - dom = document.createElementNS('http://www.w3.org/2000/svg', tag); - } else { - dom = document.createElement(tag); - } - return dom; + dom[event] = null; } +} - function appendText(text, parentDom, singleChild) { - if (parentDom === null) { - return document.createTextNode(text); - } else { - if (singleChild) { - if (text !== '') { - parentDom.textContent = text; - return parentDom.firstChild; - } else { - var textNode = document.createTextNode(''); +// TODO: for node we need to check if document is valid +function getActiveNode() { + return document.activeElement; +} - parentDom.appendChild(textNode); - return textNode; - } - } else { - var textNode$1 = document.createTextNode(text); +function removeAllChildren(dom, children) { + if (recyclingEnabled) { + var childrenLength = children.length; - parentDom.appendChild(textNode$1); - return textNode$1; + if (childrenLength > 5) { + for (var i = 0; i < childrenLength; i++) { + var child = children[i]; + + if (!isInvalidNode(child)) { + pool(child); + } } } } + dom.textContent = ''; +} - function replaceWithNewNode(lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG) { - var lastInstance = null; - var instanceLastNode = lastNode._lastNode; - - if (!isNullOrUndefined(instanceLastNode)) { - lastInstance = lastNode; - lastNode = instanceLastNode; - } - unmount(lastNode, false); - var dom = mount(nextNode, null, lifecycle, context, instance, isSVG); - - nextNode.dom = dom; - replaceNode(parentDom, dom, lastNode.dom); - if (lastInstance !== null) { - lastInstance._lastNode = nextNode; - } +function resetActiveNode(activeNode) { + if (activeNode !== null && activeNode !== document.body && document.activeElement !== activeNode) { + activeNode.focus(); // TODO: verify are we doing new focus event, if user has focus listener this might trigger it } +} - function replaceNode(parentDom, nextDom, lastDom) { - parentDom.replaceChild(nextDom, lastDom); +function isKeyed(lastChildren, nextChildren) { + if (lastChildren.complex) { + return false; } + return nextChildren.length && !isNullOrUndefined(nextChildren[0]) && !isNullOrUndefined(nextChildren[0].key) + && lastChildren.length && !isNullOrUndefined(lastChildren[0]) && !isNullOrUndefined(lastChildren[0].key); +} - function normalise(object) { - if (isStringOrNumber(object)) { - return createVText(object); - } else if (isInvalidNode(object)) { - return createVPlaceholder(); - } else if (isArray(object)) { - return createVList(object); +function selectOptionValueIfNeeded(vdom, values) { + if (vdom.tag !== 'option') { + for (var i = 0, len = vdom.children.length; i < len; i++) { + selectOptionValueIfNeeded(vdom.children[i], values); } - return object; + // NOTE! Has to be a return here to catch optGroup elements + return; } - function normaliseChild(children, i) { - var child = children[i]; + var value = vdom.attrs && vdom.attrs.value; - return children[i] = normalise(child); + if (values[value]) { + vdom.attrs = vdom.attrs || {}; + vdom.attrs.selected = 'selected'; + vdom.dom.selected = true; + } else { + vdom.dom.selected = false; } +} - function remove(node, parentDom) { - if (isVList(node)) { - return unmount(node, parentDom); - } - var dom = node.dom; - if (dom === parentDom) { - dom.innerHTML = ''; - } else { - removeChild(parentDom, dom); - if (recyclingEnabled) { - pool(node); - } +function selectValue(vdom) { + var value = vdom.attrs && vdom.attrs.value; + + var values = {}; + if (isArray(value)) { + for (var i = 0, len = value.length; i < len; i++) { + values[value[i]] = value[i]; } - unmount(node, false); + } else { + values[value] = value; + } + for (var i$1 = 0, len$1 = vdom.children.length; i$1 < len$1; i$1++) { + selectOptionValueIfNeeded(vdom.children[i$1], values); } - function removeChild(parentDom, dom) { - parentDom.removeChild(dom); + if (vdom.attrs && vdom.attrs[value]) { + delete vdom.attrs.value; // TODO! Avoid deletion here. Set to null or undef. Not sure what you want to usev } +} - function removeEvents(events, lastEventKeys, dom) { - var eventKeys = lastEventKeys || Object.keys(events); +function handleAttachedHooks(hooks, lifecycle, dom) { + if (!isNullOrUndefined(hooks.created)) { + hooks.created(dom); + } + if (!isNullOrUndefined(hooks.attached)) { + lifecycle.addListener(function () { + hooks.attached(dom); + }); + } +} - for (var i = 0; i < eventKeys.length; i++) { - var event = eventKeys[i]; +function setValueProperty(nextNode) { + var value = nextNode.attrs.value; + if (!isNullOrUndefined(value)) { + nextNode.dom.value = value; + } +} - dom[event] = null; +function setFormElementProperties(nextTag, nextNode) { + if (nextTag === 'input' && nextNode.attrs) { + var inputType = nextNode.attrs.type; + if (inputType === 'text') { + setValueProperty(nextNode); + } else if (inputType === 'checkbox' || inputType === 'radio') { + var checked = nextNode.attrs.checked; + nextNode.dom.checked = !!checked; + } + } else if (nextTag === 'textarea') { + setValueProperty(nextNode); + } +} + +function mount(input, parentDom, lifecycle, context, instance, isSVG) { + if (isVPlaceholder(input)) { + return mountVPlaceholder(input, parentDom); + } else if (isVText(input)) { + return mountVText(input, parentDom); + } else if (isVList(input)) { + return mountVList(input, parentDom, lifecycle, context, instance, isSVG); + } else if (isVNode(input)) { + return mountVNode$1(input, parentDom, lifecycle, context, instance, isSVG); + } else { + var normalisedInput = normalise(input); + + if (input !== normalisedInput) { + return mount(normalisedInput, parentDom, lifecycle, context, instance, isSVG); + } else { + throw new Error(("Inferno Error: invalid object \"" + (typeof input) + "\" passed to mount()")); } } +} - // TODO: for node we need to check if document is valid - function getActiveNode() { - return document.activeElement; - } +function mountVNode$1(vNode, parentDom, lifecycle, context, instance, isSVG) { + var bp = vNode.bp; - function removeAllChildren(dom, children) { + if (isUndefined(bp)) { + return mountVNodeWithoutBlueprint(vNode, parentDom, lifecycle, context, instance, isSVG); + } else { if (recyclingEnabled) { - var childrenLength = children.length; + var dom = recycle(vNode, bp, lifecycle, context, instance); - if (childrenLength > 5) { - for (var i = 0; i < childrenLength; i++) { - var child = children[i]; - - if (!isInvalidNode(child)) { - pool(child); - } + if (!isNull(dom)) { + if (!isNull(parentDom)) { + parentDom.appendChild(dom); } + return dom; } } - dom.textContent = ''; + return mountVNodeWithBlueprint(vNode, bp, parentDom, lifecycle, context, instance); } +} - function resetActiveNode(activeNode) { - if (activeNode !== null && activeNode !== document.body && document.activeElement !== activeNode) { - activeNode.focus(); // TODO: verify are we doing new focus event, if user has focus listener this might trigger it - } - } +function mountVList(vList, parentDom, lifecycle, context, instance, isSVG) { + var items = vList.items; + var pointer = document.createTextNode(''); + var dom = document.createDocumentFragment(); - function isKeyed(lastChildren, nextChildren) { - if (lastChildren.complex) { - return false; - } - return nextChildren.length && !isNullOrUndefined(nextChildren[0]) && !isNullOrUndefined(nextChildren[0].key) - && lastChildren.length && !isNullOrUndefined(lastChildren[0]) && !isNullOrUndefined(lastChildren[0].key); + mountArrayChildren(items, dom, lifecycle, context, instance, isSVG); + vList.pointer = pointer; + vList.dom = dom; + dom.appendChild(pointer); + if (parentDom) { + insertOrAppend(parentDom, dom); } + return dom; +} - function selectOptionValueIfNeeded(vdom, values) { - if (vdom.tag !== 'option') { - for (var i = 0, len = vdom.children.length; i < len; i++) { - selectOptionValueIfNeeded(vdom.children[i], values); - } - // NOTE! Has to be a return here to catch optGroup elements - return; - } +function mountVText(vText, parentDom) { + var dom = document.createTextNode(vText.text); - var value = vdom.attrs && vdom.attrs.value; - - if (values[value]) { - vdom.attrs = vdom.attrs || {}; - vdom.attrs.selected = 'selected'; - vdom.dom.selected = true; - } else { - vdom.dom.selected = false; - } + vText.dom = dom; + if (parentDom) { + insertOrAppend(parentDom, dom); } + return dom; +} - function selectValue(vdom) { - var value = vdom.attrs && vdom.attrs.value; - - var values = {}; - if (isArray(value)) { - for (var i = 0, len = value.length; i < len; i++) { - values[value[i]] = value[i]; - } - } else { - values[value] = value; - } - for (var i$1 = 0, len$1 = vdom.children.length; i$1 < len$1; i$1++) { - selectOptionValueIfNeeded(vdom.children[i$1], values); - } +function mountVPlaceholder(vPlaceholder, parentDom) { + var dom = document.createTextNode(''); - if (vdom.attrs && vdom.attrs[value]) { - delete vdom.attrs.value; // TODO! Avoid deletion here. Set to null or undef. Not sure what you want to usev - } + vPlaceholder.dom = dom; + if (parentDom) { + insertOrAppend(parentDom, dom); } + return dom; +} - function handleAttachedHooks(hooks, lifecycle, dom) { - if (!isNullOrUndefined(hooks.created)) { - hooks.created(dom); - } - if (!isNullOrUndefined(hooks.attached)) { - lifecycle.addListener(function () { - hooks.attached(dom); - }); - } +function handleSelects(node) { + if (node.tag === 'select') { + selectValue(node); } +} - function setValueProperty(nextNode) { - var value = nextNode.attrs.value; - if (!isNullOrUndefined(value)) { - nextNode.dom.value = value; - } - } +function mountBlueprintAttrs(node, bp, dom, instance) { + handleSelects(node); + var attrs = node.attrs; - function setFormElementProperties(nextTag, nextNode) { - if (nextTag === 'input' && nextNode.attrs) { - var inputType = nextNode.attrs.type; - if (inputType === 'text') { - setValueProperty(nextNode); - } else if (inputType === 'checkbox' || inputType === 'radio') { - var checked = nextNode.attrs.checked; - nextNode.dom.checked = !!checked; - } - } else if (nextTag === 'textarea') { - setValueProperty(nextNode); - } + if (isNull(bp.attrKeys)) { + var newKeys = Object.keys(attrs); + bp.attrKeys = bp.attrKeys ? bp.attrKeys.concat(newKeys) : newKeys; } + var attrKeys = bp.attrKeys; - function mount(input, parentDom, lifecycle, context, instance, isSVG) { - if (isVPlaceholder(input)) { - return mountVPlaceholder(input, parentDom); - } else if (isVText(input)) { - return mountVText(input, parentDom); - } else if (isVList(input)) { - return mountVList(input, parentDom, lifecycle, context, instance, isSVG); - } else if (isVNode(input)) { - return mountVNode$1(input, parentDom, lifecycle, context, instance, isSVG); - } else { - var normalisedInput = normalise(input); + mountAttributes(node, attrs, attrKeys, dom, instance); +} - if (input !== normalisedInput) { - return mount(normalisedInput, parentDom, lifecycle, context, instance, isSVG); - } else { - throw new Error(("Inferno Error: invalid object \"" + (typeof input) + "\" passed to mount()")); - } - } +function mountBlueprintEvents(node, bp, dom) { + var events = node.events; + + if (isNull(bp.eventKeys)) { + bp.eventKeys = Object.keys(events); } + var eventKeys = bp.eventKeys; - function mountVNode$1(vNode, parentDom, lifecycle, context, instance, isSVG) { - var bp = vNode.bp; + mountEvents(events, eventKeys, dom); +} - if (isUndefined(bp)) { - return mountVNodeWithoutBlueprint(vNode, parentDom, lifecycle, context, instance, isSVG); - } else { - if (recyclingEnabled) { - var dom = recycle(vNode, bp, lifecycle, context, instance); +function mountVNodeWithBlueprint(node, bp, parentDom, lifecycle, context, instance) { + var tag = node.tag; - if (!isNull(dom)) { - if (!isNull(parentDom)) { - parentDom.appendChild(dom); - } - return dom; - } - } - return mountVNodeWithBlueprint(vNode, bp, parentDom, lifecycle, context, instance); - } + if (isTrue(bp.isComponent)) { + return mountComponent(node, tag, node.attrs || {}, node.hooks, node.children, instance, parentDom, lifecycle, context); } + var dom = documentCreateElement(bp.tag, bp.isSVG); - function mountVList(vList, parentDom, lifecycle, context, instance, isSVG) { - var items = vList.items; - var pointer = document.createTextNode(''); - var dom = document.createDocumentFragment(); - - mountArrayChildren(items, dom, lifecycle, context, instance, isSVG); - vList.pointer = pointer; - vList.dom = dom; - dom.appendChild(pointer); - if (parentDom) { - insertOrAppend(parentDom, dom); - } - return dom; + node.dom = dom; + if (isTrue(bp.hasHooks)) { + handleAttachedHooks(node.hooks, lifecycle, dom); + } + if (isTrue(bp.lazy)) { + handleLazyAttached(node, lifecycle, dom); } + var children = node.children; + // bp.childrenType: + // 0: no children + // 1: text node + // 2: single child + // 3: multiple children + // 4: multiple children (keyed) + // 5: variable children (defaults to no optimisation) - function mountVText(vText, parentDom) { - var dom = document.createTextNode(vText.text); + switch (bp.childrenType) { + case 1: + appendText(children, dom, true); + break; + case 2: + mount(node.children, dom, lifecycle, context, instance, bp.isSVG); + break; + case 3: + mountArrayChildren(children, dom, lifecycle, context, instance, bp.isSVG); + break; + case 4: + for (var i = 0; i < children.length; i++) { + mount(children[i], dom, lifecycle, context, instance, bp.isSVG); + } + break; + case 5: + mountChildren(node, children, dom, lifecycle, context, instance, bp.isSVG); + break; + default: + break; + } - vText.dom = dom; - if (parentDom) { - insertOrAppend(parentDom, dom); - } - return dom; + if (isTrue(bp.hasAttrs)) { + mountBlueprintAttrs(node, bp, dom, instance); + } + if (isTrue(bp.hasClassName)) { + dom.className = node.className; + } + if (isTrue(bp.hasStyle)) { + patchStyle(null, node.style, dom); + } + if (isTrue(bp.hasEvents)) { + mountBlueprintEvents(node, bp, dom); + } + if (!isNull(parentDom)) { + parentDom.appendChild(dom); } + return dom; +} - function mountVPlaceholder(vPlaceholder, parentDom) { - var dom = document.createTextNode(''); +function mountVNodeWithoutBlueprint(node, parentDom, lifecycle, context, instance, isSVG) { + var tag = node.tag; - vPlaceholder.dom = dom; - if (parentDom) { - insertOrAppend(parentDom, dom); - } - return dom; + if (isFunction(tag)) { + return mountComponent(node, tag, node.attrs || {}, node.hooks, node.children, instance, parentDom, lifecycle, context); } - - function handleSelects(node) { - if (node.tag === 'select') { - selectValue(node); - } + if (!isString(tag) || tag === '') { + throw Error('Inferno Error: Expected function or string for element tag type'); + } + if (tag === 'svg') { + isSVG = true; } + var dom = documentCreateElement(tag, isSVG); + var children = node.children; + var attrs = node.attrs; + var events = node.events; + var hooks = node.hooks; + var className = node.className; + var style = node.style; - function mountBlueprintAttrs(node, bp, dom, instance) { + node.dom = dom; + if (!isNullOrUndefined(hooks)) { + handleAttachedHooks(hooks, lifecycle, dom); + } + if (!isInvalidNode(children)) { + mountChildren(node, children, dom, lifecycle, context, instance, isSVG); + } + if (!isNullOrUndefined(attrs)) { handleSelects(node); - var attrs = node.attrs; - - if (isNull(bp.attrKeys)) { - var newKeys = Object.keys(attrs); - bp.attrKeys = bp.attrKeys ? bp.attrKeys.concat(newKeys) : newKeys; - } - var attrKeys = bp.attrKeys; - - mountAttributes(node, attrs, attrKeys, dom, instance); + mountAttributes(node, attrs, Object.keys(attrs), dom, instance); + } + if (!isNullOrUndefined(className)) { + dom.className = className; + } + if (!isNullOrUndefined(style)) { + patchStyle(null, style, dom); + } + if (!isNullOrUndefined(events)) { + mountEvents(events, Object.keys(events), dom); + } + if (!isNull(parentDom)) { + parentDom.appendChild(dom); } + return dom; +} - function mountBlueprintEvents(node, bp, dom) { - var events = node.events; +function mountArrayChildren(children, parentDom, lifecycle, context, instance, isSVG) { + children.complex = false; + for (var i = 0; i < children.length; i++) { + var child = normaliseChild(children, i); - if (isNull(bp.eventKeys)) { - bp.eventKeys = Object.keys(events); + if (isVText(child)) { + mountVText(child, parentDom); + children.complex = true; + } else if (isVPlaceholder(child)) { + mountVPlaceholder(child, parentDom); + children.complex = true; + } else if (isVList(child)) { + mountVList(child, parentDom, lifecycle, context, instance, isSVG); + children.complex = true; + } else { + mount(child, parentDom, lifecycle, context, instance, isSVG); } - var eventKeys = bp.eventKeys; - - mountEvents(events, eventKeys, dom); } +} - function mountVNodeWithBlueprint(node, bp, parentDom, lifecycle, context, instance) { - var tag = node.tag; - - if (isTrue(bp.isComponent)) { - return mountComponent(node, tag, node.attrs || {}, node.hooks, node.children, instance, parentDom, lifecycle, context); - } - var dom = documentCreateElement(bp.tag, bp.isSVG); +function mountChildren(node, children, parentDom, lifecycle, context, instance, isSVG) { + if (isArray(children)) { + mountArrayChildren(children, parentDom, lifecycle, context, instance, isSVG); + } else if (isStringOrNumber(children)) { + appendText(children, parentDom, true); + } else if (!isInvalidNode(children)) { + mount(children, parentDom, lifecycle, context, instance, isSVG); + } +} - node.dom = dom; - if (isTrue(bp.hasHooks)) { - handleAttachedHooks(node.hooks, lifecycle, dom); - } - if (isTrue(bp.lazy)) { - handleLazyAttached(node, lifecycle, dom); - } - var children = node.children; - // bp.childrenType: - // 0: no children - // 1: text node - // 2: single child - // 3: multiple children - // 4: multiple children (keyed) - // 5: variable children (defaults to no optimisation) +function mountRef(instance, value, refValue) { + if (!isInvalidNode(instance) && isString(value)) { + instance.refs[value] = refValue; + } +} - switch (bp.childrenType) { - case 1: - appendText(children, dom, true); - break; - case 2: - mount(node.children, dom, lifecycle, context, instance, bp.isSVG); - break; - case 3: - mountArrayChildren(children, dom, lifecycle, context, instance, bp.isSVG); - break; - case 4: - for (var i = 0; i < children.length; i++) { - mount(children[i], dom, lifecycle, context, instance, bp.isSVG); - } - break; - case 5: - mountChildren(node, children, dom, lifecycle, context, instance, bp.isSVG); - break; - default: - break; - } +function mountEvents(events, eventKeys, dom) { + for (var i = 0; i < eventKeys.length; i++) { + var event = eventKeys[i]; - if (isTrue(bp.hasAttrs)) { - mountBlueprintAttrs(node, bp, dom, instance); - } - if (isTrue(bp.hasClassName)) { - dom.className = node.className; - } - if (isTrue(bp.hasStyle)) { - patchStyle(null, node.style, dom); - } - if (isTrue(bp.hasEvents)) { - mountBlueprintEvents(node, bp, dom); - } - if (!isNull(parentDom)) { - parentDom.appendChild(dom); - } - return dom; + dom[event] = events[event]; } +} - function mountVNodeWithoutBlueprint(node, parentDom, lifecycle, context, instance, isSVG) { - var tag = node.tag; +function mountComponent(parentNode, Component, props, hooks, children, lastInstance, parentDom, lifecycle, context) { + props = addChildrenToProps(children, props); - if (isFunction(tag)) { - return mountComponent(node, tag, node.attrs || {}, node.hooks, node.children, instance, parentDom, lifecycle, context); - } - if (!isString(tag) || tag === '') { - throw Error('Inferno Error: Expected function or string for element tag type'); - } - if (tag === 'svg') { - isSVG = true; - } - var dom = documentCreateElement(tag, isSVG); - var children = node.children; - var attrs = node.attrs; - var events = node.events; - var hooks = node.hooks; - var className = node.className; - var style = node.style; + var dom; + if (isStatefulComponent(Component)) { + var instance = new Component(props, context); - node.dom = dom; - if (!isNullOrUndefined(hooks)) { - handleAttachedHooks(hooks, lifecycle, dom); - } - if (!isInvalidNode(children)) { - mountChildren(node, children, dom, lifecycle, context, instance, isSVG); + instance._patch = patch; + instance._componentToDOMNodeMap = componentToDOMNodeMap; + if (!isNullOrUndefined(lastInstance) && props.ref) { + mountRef(lastInstance, props.ref, instance); } - if (!isNullOrUndefined(attrs)) { - handleSelects(node); - mountAttributes(node, attrs, Object.keys(attrs), dom, instance); - } - if (!isNullOrUndefined(className)) { - dom.className = className; + var childContext = instance.getChildContext(); + + if (!isNullOrUndefined(childContext)) { + context = Object.assign({}, context, childContext); } - if (!isNullOrUndefined(style)) { - patchStyle(null, style, dom); + instance.context = context; + instance._unmounted = false; + instance._parentNode = parentNode; + if (lastInstance) { + instance._parentComponent = lastInstance; } - if (!isNullOrUndefined(events)) { - mountEvents(events, Object.keys(events), dom); + instance._pendingSetState = true; + instance.componentWillMount(); + var node = instance.render(); + + if (isInvalidNode(node)) { + node = createVPlaceholder(); } - if (!isNull(parentDom)) { + instance._pendingSetState = false; + dom = mount(node, null, lifecycle, context, instance, false); + instance._lastNode = node; + instance.componentDidMount(); + if (parentDom !== null && !isInvalidNode(dom)) { parentDom.appendChild(dom); } - return dom; - } - - function mountArrayChildren(children, parentDom, lifecycle, context, instance, isSVG) { - children.complex = false; - for (var i = 0; i < children.length; i++) { - var child = normaliseChild(children, i); - - if (isVText(child)) { - mountVText(child, parentDom); - children.complex = true; - } else if (isVPlaceholder(child)) { - mountVPlaceholder(child, parentDom); - children.complex = true; - } else if (isVList(child)) { - mountVList(child, parentDom, lifecycle, context, instance, isSVG); - children.complex = true; - } else { - mount(child, parentDom, lifecycle, context, instance, isSVG); + componentToDOMNodeMap.set(instance, dom); + parentNode.dom = dom; + parentNode.instance = instance; + } else { + if (!isNullOrUndefined(hooks)) { + if (!isNullOrUndefined(hooks.componentWillMount)) { + hooks.componentWillMount(null, props); + } + if (!isNullOrUndefined(hooks.componentDidMount)) { + lifecycle.addListener(function () { + hooks.componentDidMount(dom, props); + }); } } - } - function mountChildren(node, children, parentDom, lifecycle, context, instance, isSVG) { - if (isArray(children)) { - mountArrayChildren(children, parentDom, lifecycle, context, instance, isSVG); - } else if (isStringOrNumber(children)) { - appendText(children, parentDom, true); - } else if (!isInvalidNode(children)) { - mount(children, parentDom, lifecycle, context, instance, isSVG); - } - } + /* eslint new-cap: 0 */ + var node$1 = Component(props, context); - function mountRef(instance, value, refValue) { - if (!isInvalidNode(instance) && isString(value)) { - instance.refs[value] = refValue; + if (isInvalidNode(node$1)) { + node$1 = createVPlaceholder(); } - } + dom = mount(node$1, null, lifecycle, context, null, false); - function mountEvents(events, eventKeys, dom) { - for (var i = 0; i < eventKeys.length; i++) { - var event = eventKeys[i]; + parentNode.instance = node$1; - dom[event] = events[event]; + if (parentDom !== null && !isInvalidNode(dom)) { + parentDom.appendChild(dom); } + parentNode.dom = dom; } + return dom; +} - function mountComponent(parentNode, Component, props, hooks, children, lastInstance, parentDom, lifecycle, context) { - props = addChildrenToProps(children, props); +function mountAttributes(node, attrs, attrKeys, dom, instance) { + for (var i = 0; i < attrKeys.length; i++) { + var attr = attrKeys[i]; - var dom; - if (isStatefulComponent(Component)) { - var instance = new Component(props, context); - - instance._patch = patch; - instance._componentToDOMNodeMap = componentToDOMNodeMap; - if (!isNullOrUndefined(lastInstance) && props.ref) { - mountRef(lastInstance, props.ref, instance); - } - var childContext = instance.getChildContext(); - - if (!isNullOrUndefined(childContext)) { - context = Object.assign({}, context, childContext); - } - instance.context = context; - instance._unmounted = false; - instance._parentNode = parentNode; - if (lastInstance) { - instance._parentComponent = lastInstance; - } - instance._pendingSetState = true; - instance.componentWillMount(); - var node = instance.render(); - - if (isInvalidNode(node)) { - node = createVPlaceholder(); - } - instance._pendingSetState = false; - dom = mount(node, null, lifecycle, context, instance, false); - instance._lastNode = node; - instance.componentDidMount(); - if (parentDom !== null && !isInvalidNode(dom)) { - parentDom.appendChild(dom); - } - componentToDOMNodeMap.set(instance, dom); - parentNode.dom = dom; - parentNode.instance = instance; + if (attr === 'ref') { + mountRef(getRefInstance$1(node, instance), attrs[attr], dom); } else { - if (!isNullOrUndefined(hooks)) { - if (!isNullOrUndefined(hooks.componentWillMount)) { - hooks.componentWillMount(null, props); - } - if (!isNullOrUndefined(hooks.componentDidMount)) { - lifecycle.addListener(function () { - hooks.componentDidMount(dom, props); - }); - } - } - - /* eslint new-cap: 0 */ - var node$1 = Component(props, context); - - if (isInvalidNode(node$1)) { - node$1 = createVPlaceholder(); - } - dom = mount(node$1, null, lifecycle, context, null, false); - - parentNode.instance = node$1; - - if (parentDom !== null && !isInvalidNode(dom)) { - parentDom.appendChild(dom); - } - parentNode.dom = dom; + patchAttribute(attr, null, attrs[attr], dom); } - return dom; } +} - function mountAttributes(node, attrs, attrKeys, dom, instance) { - for (var i = 0; i < attrKeys.length; i++) { - var attr = attrKeys[i]; - - if (attr === 'ref') { - mountRef(getRefInstance$1(node, instance), attrs[attr], dom); +function patch(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG) { + if (lastInput !== nextInput) { + if (isInvalidNode(lastInput)) { + mount(nextInput, parentDom, lifecycle, context, instance, isSVG); + } else if (isInvalidNode(nextInput)) { + remove(lastInput, parentDom); + } else if (isStringOrNumber(lastInput)) { + if (isStringOrNumber(nextInput)) { + parentDom.firstChild.nodeValue = nextInput; } else { - patchAttribute(attr, null, attrs[attr], dom); - } - } - } + var dom = mount(nextInput, null, lifecycle, context, instance, isSVG); - function patch(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG) { - if (lastInput !== nextInput) { - if (isInvalidNode(lastInput)) { - mount(nextInput, parentDom, lifecycle, context, instance, isSVG); - } else if (isInvalidNode(nextInput)) { - remove(lastInput, parentDom); - } else if (isStringOrNumber(lastInput)) { - if (isStringOrNumber(nextInput)) { - parentDom.firstChild.nodeValue = nextInput; + nextInput.dom = dom; + replaceNode(parentDom, dom, parentDom.firstChild); + } + } else if (isStringOrNumber(nextInput)) { + replaceNode(parentDom, document.createTextNode(nextInput), lastInput.dom); + } else { + if (isVList(nextInput)) { + if (isVList(lastInput)) { + patchVList(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG); } else { - var dom = mount(nextInput, null, lifecycle, context, instance, isSVG); - - nextInput.dom = dom; - replaceNode(parentDom, dom, parentDom.firstChild); + replaceNode(parentDom, mountVList(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); + unmount(lastInput, null); } - } else if (isStringOrNumber(nextInput)) { - replaceNode(parentDom, document.createTextNode(nextInput), lastInput.dom); - } else { - if (isVList(nextInput)) { - if (isVList(lastInput)) { - patchVList(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG); - } else { - replaceNode(parentDom, mountVList(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); - unmount(lastInput, null); - } - } else if (isVList(lastInput)) { - replaceVListWithNode(parentDom, lastInput, mount(nextInput, null, lifecycle, context, instance, isSVG)); - } else if (isVPlaceholder(nextInput)) { - if (isVPlaceholder(lastInput)) { - patchVFragment(lastInput, nextInput); - } else { - replaceNode(parentDom, mountVPlaceholder(nextInput, null), lastInput.dom); - unmount(lastInput, null); - } - } else if (isVPlaceholder(lastInput)) { - replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); - } else if (isVText(nextInput)) { - if (isVText(lastInput)) { - patchVText(lastInput, nextInput); - } else { - replaceNode(parentDom, mountVText(nextInput, null), lastInput.dom); - unmount(lastInput, null); - } - } else if (isVText(lastInput)) { - replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); - } else if (isVNode(nextInput)) { - if (isVNode(lastInput)) { - patchVNode(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG, false); - } else { - replaceNode(parentDom, mountVNode(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); - unmount(lastInput, null); - } - } else if (isVNode(lastInput)) { - replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); + } else if (isVList(lastInput)) { + replaceVListWithNode(parentDom, lastInput, mount(nextInput, null, lifecycle, context, instance, isSVG)); + } else if (isVPlaceholder(nextInput)) { + if (isVPlaceholder(lastInput)) { + patchVFragment(lastInput, nextInput); + } else { + replaceNode(parentDom, mountVPlaceholder(nextInput, null), lastInput.dom); unmount(lastInput, null); + } + } else if (isVPlaceholder(lastInput)) { + replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); + } else if (isVText(nextInput)) { + if (isVText(lastInput)) { + patchVText(lastInput, nextInput); } else { - return patch(lastInput, normalise(nextInput), parentDom, lifecycle, context, instance, isSVG); + replaceNode(parentDom, mountVText(nextInput, null), lastInput.dom); + unmount(lastInput, null); + } + } else if (isVText(lastInput)) { + replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); + } else if (isVNode(nextInput)) { + if (isVNode(lastInput)) { + patchVNode(lastInput, nextInput, parentDom, lifecycle, context, instance, isSVG, false); + } else { + replaceNode(parentDom, mountVNode(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); + unmount(lastInput, null); } + } else if (isVNode(lastInput)) { + replaceNode(parentDom, mount(nextInput, null, lifecycle, context, instance, isSVG), lastInput.dom); + unmount(lastInput, null); + } else { + return patch(lastInput, normalise(nextInput), parentDom, lifecycle, context, instance, isSVG); } } - return nextInput; } + return nextInput; +} - function patchTextNode(dom, lastChildren, nextChildren) { - if (isStringOrNumber(lastChildren)) { - dom.firstChild.nodeValue = nextChildren; - } else { - dom.textContent = nextChildren; - } +function patchTextNode(dom, lastChildren, nextChildren) { + if (isStringOrNumber(lastChildren) && lastChildren !== '') { + dom.firstChild.nodeValue = nextChildren; + } else { + dom.textContent = nextChildren; } +} - function patchRef(instance, lastValue, nextValue, dom) { - if (instance) { - if (isString(lastValue)) { - delete instance.refs[lastValue]; - } - if (isString(nextValue)) { - instance.refs[nextValue] = dom; - } +function patchRef(instance, lastValue, nextValue, dom) { + if (instance) { + if (isString(lastValue)) { + delete instance.refs[lastValue]; + } + if (isString(nextValue)) { + instance.refs[nextValue] = dom; } } +} - function patchChildren(lastNode, nextNode, dom, lifecycle, context, instance, isSVG) { - var nextChildren = nextNode.children; - var lastChildren = lastNode.children; +function patchChildren(lastNode, nextNode, dom, lifecycle, context, instance, isSVG) { + var nextChildren = nextNode.children; + var lastChildren = lastNode.children; - if (lastChildren === nextChildren) { - return; - } - if (isInvalidNode(lastChildren)) { - if (isStringOrNumber(nextChildren)) { - patchTextNode(dom, lastChildren, nextChildren); - } else if (!isInvalidNode(nextChildren)) { - if (isArray(nextChildren)) { - mountArrayChildren(nextChildren, dom, lifecycle, context, instance, isSVG); - } else { - mount(nextChildren, dom, lifecycle, context, instance, isSVG); - } + if (lastChildren === nextChildren) { + return; + } + if (isInvalidNode(lastChildren)) { + if (isStringOrNumber(nextChildren)) { + patchTextNode(dom, lastChildren, nextChildren); + } else if (!isInvalidNode(nextChildren)) { + if (isArray(nextChildren)) { + mountArrayChildren(nextChildren, dom, lifecycle, context, instance, isSVG); + } else { + mount(nextChildren, dom, lifecycle, context, instance, isSVG); } + } + } else { + if (isInvalidNode(nextChildren)) { + removeAllChildren(dom, lastChildren); } else { - if (isInvalidNode(nextChildren)) { - removeAllChildren(dom, lastChildren); - } else { - if (isArray(lastChildren)) { - if (isArray(nextChildren)) { - nextChildren.complex = lastChildren.complex; - if (isKeyed(lastChildren, nextChildren)) { - patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, null); - } else { - patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, null); - } + if (isArray(lastChildren)) { + if (isArray(nextChildren)) { + nextChildren.complex = lastChildren.complex; + if (isKeyed(lastChildren, nextChildren)) { + patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, null); } else { - patchNonKeyedChildren(lastChildren, [nextChildren], dom, lifecycle, context, instance, isSVG, null); + patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, null); } } else { - if (isArray(nextChildren)) { - var lastChild = lastChildren; + patchNonKeyedChildren(lastChildren, [nextChildren], dom, lifecycle, context, instance, isSVG, null); + } + } else { + if (isArray(nextChildren)) { + var lastChild = lastChildren; - if (isStringOrNumber(lastChildren)) { - lastChild = createVText(lastChild); - lastChild.dom = dom.firstChild; - } - patchNonKeyedChildren([lastChild], nextChildren, dom, lifecycle, context, instance, isSVG, null); - } else if (isStringOrNumber(nextChildren)) { - patchTextNode(dom, lastChildren, nextChildren); - } else if (isStringOrNumber(lastChildren)) { - patch(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG); - } else { - patchVNode(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, false); + if (isStringOrNumber(lastChildren)) { + lastChild = createVText(lastChild); + lastChild.dom = dom.firstChild; } + patchNonKeyedChildren([lastChild], nextChildren, dom, lifecycle, context, instance, isSVG, null); + } else if (isStringOrNumber(nextChildren)) { + patchTextNode(dom, lastChildren, nextChildren); + } else if (isStringOrNumber(lastChildren)) { + patch(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG); + } else { + patchVNode(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, false); } } } } +} - function patchVNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, isSVG, skipLazyCheck) { - var lastBp = lastVNode.bp; - var nextBp = nextVNode.bp; +function patchVNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, isSVG, skipLazyCheck) { + var lastBp = lastVNode.bp; + var nextBp = nextVNode.bp; - if (lastBp === undefined || nextBp === undefined) { - patchVNodeWithoutBlueprint(lastVNode, nextVNode, parentDom, lifecycle, context, instance, isSVG); - } else { - patchVNodeWithBlueprint(lastVNode, nextVNode, lastBp, nextBp, parentDom, lifecycle, context, instance, skipLazyCheck); - } + if (lastBp === undefined || nextBp === undefined) { + patchVNodeWithoutBlueprint(lastVNode, nextVNode, parentDom, lifecycle, context, instance, isSVG); + } else { + patchVNodeWithBlueprint(lastVNode, nextVNode, lastBp, nextBp, parentDom, lifecycle, context, instance, skipLazyCheck); } +} - function patchVNodeWithBlueprint(lastVNode, nextVNode, lastBp, nextBp, parentDom, lifecycle, context, instance, skipLazyCheck) { - var nextHooks; +function patchVNodeWithBlueprint(lastVNode, nextVNode, lastBp, nextBp, parentDom, lifecycle, context, instance, skipLazyCheck) { + var nextHooks; - if (nextBp.hasHooks === true) { - nextHooks = nextVNode.hooks; - if (nextHooks && !isNullOrUndefined(nextHooks.willUpdate)) { - nextHooks.willUpdate(lastVNode.dom); - } + if (nextBp.hasHooks === true) { + nextHooks = nextVNode.hooks; + if (nextHooks && !isNullOrUndefined(nextHooks.willUpdate)) { + nextHooks.willUpdate(lastVNode.dom); } - var nextTag = nextVNode.tag || nextBp.tag; - var lastTag = lastVNode.tag || lastBp.tag; + } + var nextTag = nextVNode.tag || nextBp.tag; + var lastTag = lastVNode.tag || lastBp.tag; - if (lastTag !== nextTag) { - if (lastBp.isComponent === true) { - var lastNodeInstance = lastVNode.instance; + if (lastTag !== nextTag) { + if (lastBp && lastBp.isComponent === true) { + var lastNodeInstance = lastVNode.instance; - if (nextBp.isComponent === true) { - replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, false); - } else if (isStatefulComponent(lastTag)) { - unmountVNode(lastVNode, null, true); - var lastNode = lastNodeInstance._lastNode; - patchVNodeWithBlueprint(lastNode, nextVNode, lastNode.bp, nextBp, parentDom, lifecycle, context, instance, nextBp.isSVG); - } else { - unmountVNode(lastVNode, null, true); - patchVNodeWithBlueprint(lastNodeInstance, nextVNode, lastNodeInstance.bp, nextBp, parentDom, lifecycle, context, instance, nextBp.isSVG); - } + if (nextBp.isComponent === true) { + replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, false); + } else if (isStatefulComponent(lastTag)) { + unmountVNode(lastVNode, null, true); + var lastNode = lastNodeInstance._lastNode; + patchVNodeWithBlueprint(lastNode, nextVNode, lastNode.bp, nextBp, parentDom, lifecycle, context, instance, nextBp.isSVG); } else { - replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, nextBp.isSVG); + unmountVNode(lastVNode, null, true); + patchVNodeWithBlueprint(lastNodeInstance, nextVNode, lastNodeInstance.bp, nextBp, parentDom, lifecycle, context, instance, nextBp.isSVG); } - } else if (isNullOrUndefined(lastTag)) { - nextVNode.dom = lastVNode.dom; } else { - if (lastBp.isComponent === true) { - if (nextBp.isComponent === true) { - var instance$1 = lastVNode.instance; - - if (!isNullOrUndefined(instance$1) && instance$1._unmounted) { - var newDom = mountComponent(nextVNode, lastTag, nextVNode.attrs || {}, nextVNode.hooks, nextVNode.children, instance$1, parentDom, lifecycle, context); - if (parentDom !== null) { - replaceNode(parentDom, newDom, lastVNode.dom); - } - } else { - nextVNode.instance = instance$1; - nextVNode.dom = lastVNode.dom; - patchComponent(true, nextVNode, nextVNode.tag, lastBp, nextBp, instance$1, lastVNode.attrs || {}, nextVNode.attrs || {}, nextVNode.hooks, lastVNode.children, nextVNode.children, parentDom, lifecycle, context); - } - } - } else { - var dom = lastVNode.dom; - var lastChildrenType = lastBp.childrenType; - var nextChildrenType = nextBp.childrenType; - nextVNode.dom = dom; - - if (nextBp.lazy === true && skipLazyCheck === false) { - var clipData = lastVNode.clipData; - - if (lifecycle.scrollY === null) { - lifecycle.refresh(); - } - - nextVNode.clipData = clipData; - if (clipData.pending === true || clipData.top - lifecycle.scrollY > lifecycle.screenHeight) { - if (setClipNode(clipData, dom, lastVNode, nextVNode, parentDom, lifecycle, context, instance, lastBp.isSVG)) { - return; - } - } - if (clipData.bottom < lifecycle.scrollY) { - if (setClipNode(clipData, dom, lastVNode, nextVNode, parentDom, lifecycle, context, instance, lastBp.isSVG)) { - return; - } + replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, instance, nextBp.isSVG); + } + } else if (isNullOrUndefined(lastTag)) { + nextVNode.dom = lastVNode.dom; + } else { + if (lastBp && lastBp.isComponent === true) { + if (nextBp.isComponent === true) { + var instance$1 = lastVNode.instance; + + if (!isNullOrUndefined(instance$1) && instance$1._unmounted) { + var newDom = mountComponent(nextVNode, lastTag, nextVNode.attrs || {}, nextVNode.hooks, nextVNode.children, instance$1, parentDom, lifecycle, context); + if (parentDom !== null) { + replaceNode(parentDom, newDom, lastVNode.dom); } + } else { + nextVNode.instance = instance$1; + nextVNode.dom = lastVNode.dom; + patchComponent(true, nextVNode, nextVNode.tag, lastBp, nextBp, instance$1, lastVNode.attrs || {}, nextVNode.attrs || {}, nextVNode.hooks, lastVNode.children, nextVNode.children, parentDom, lifecycle, context); } - - if (lastChildrenType > 0 || nextChildrenType > 0) { - if (nextChildrenType === 5 || lastChildrenType === 5) { - patchChildren(lastVNode, nextVNode, dom, lifecycle, context, instance); - } else { - var lastChildren = lastVNode.children; - var nextChildren = nextVNode.children; - - if (lastChildrenType === 0 || isInvalidNode(lastChildren)) { - if (nextChildrenType > 2) { - mountArrayChildren(nextChildren, dom, lifecycle, context, instance); - } else { - mount(nextChildren, dom, lifecycle, context, instance); - } - } else if (nextChildrenType === 0 || isInvalidNode(nextChildren)) { - if (lastChildrenType > 2) { - removeAllChildren(dom, lastChildren); - } else { - remove(lastChildren, dom); - } - } else { - if (lastChildren !== nextChildren) { - if (lastChildrenType === 4 && nextChildrenType === 4) { - patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, nextBp.isSVG, null); - } else if (lastChildrenType === 2 && nextChildrenType === 2) { - patch(lastChildren, nextChildren, dom, lifecycle, context, instance, true, nextBp.isSVG); - } else if (lastChildrenType === 1 && nextChildrenType === 1) { - patchTextNode(dom, lastChildren, nextChildren); - } else { - patchChildren(lastVNode, nextVNode, dom, lifecycle, context, instance, nextBp.isSVG); - } - } - } - } + } + } else { + var dom = lastVNode.dom; + var lastChildrenType = lastBp.childrenType; + var nextChildrenType = nextBp.childrenType; + nextVNode.dom = dom; + + if (nextBp.lazy === true && skipLazyCheck === false) { + var clipData = lastVNode.clipData; + + if (lifecycle.scrollY === null) { + lifecycle.refresh(); } - if (lastBp.hasAttrs === true || nextBp.hasAttrs === true) { - patchAttributes(lastVNode, nextVNode, lastBp.attrKeys, nextBp.attrKeys, dom, instance); + + nextVNode.clipData = clipData; + if (clipData.pending === true || clipData.top - lifecycle.scrollY > lifecycle.screenHeight) { + if (setClipNode(clipData, dom, lastVNode, nextVNode, parentDom, lifecycle, context, instance, lastBp.isSVG)) { + return; + } } - if (lastBp.hasEvents === true || nextBp.hasEvents === true) { - patchEvents(lastVNode.events, nextVNode.events, lastBp.eventKeys, nextBp.eventKeys, dom); + if (clipData.bottom < lifecycle.scrollY) { + if (setClipNode(clipData, dom, lastVNode, nextVNode, parentDom, lifecycle, context, instance, lastBp.isSVG)) { + return; + } } - if (lastBp.hasClassName === true || nextBp.hasClassName === true) { - var nextClassName = nextVNode.className; + } + + if (lastChildrenType > 0 || nextChildrenType > 0) { + if (nextChildrenType === 5 || lastChildrenType === 5) { + patchChildren(lastVNode, nextVNode, dom, lifecycle, context, instance); + } else { + var lastChildren = lastVNode.children; + var nextChildren = nextVNode.children; - if (lastVNode.className !== nextClassName) { - if (isNullOrUndefined(nextClassName)) { - dom.removeAttribute('class'); + if (lastChildrenType === 0 || isInvalidNode(lastChildren)) { + if (nextChildrenType > 2) { + mountArrayChildren(nextChildren, dom, lifecycle, context, instance); } else { - dom.className = nextClassName; + mount(nextChildren, dom, lifecycle, context, instance); + } + } else if (nextChildrenType === 0 || isInvalidNode(nextChildren)) { + if (lastChildrenType > 2) { + removeAllChildren(dom, lastChildren); + } else { + remove(lastChildren, dom); + } + } else { + if (lastChildren !== nextChildren) { + if (lastChildrenType === 4 && nextChildrenType === 4) { + patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, nextBp.isSVG, null); + } else if (lastChildrenType === 2 && nextChildrenType === 2) { + patch(lastChildren, nextChildren, dom, lifecycle, context, instance, true, nextBp.isSVG); + } else if (lastChildrenType === 1 && nextChildrenType === 1) { + patchTextNode(dom, lastChildren, nextChildren); + } else { + patchChildren(lastVNode, nextVNode, dom, lifecycle, context, instance, nextBp.isSVG); + } } } } - if (lastBp.hasStyle === true || nextBp.hasStyle === true) { - var nextStyle = nextVNode.style; - var lastStyle = lastVNode.style; + } + if (lastBp.hasAttrs === true || nextBp.hasAttrs === true) { + patchAttributes(lastVNode, nextVNode, lastBp.attrKeys, nextBp.attrKeys, dom, instance); + } + if (lastBp.hasEvents === true || nextBp.hasEvents === true) { + patchEvents(lastVNode.events, nextVNode.events, lastBp.eventKeys, nextBp.eventKeys, dom); + } + if (lastBp.hasClassName === true || nextBp.hasClassName === true) { + var nextClassName = nextVNode.className; - if (lastStyle !== nextStyle) { - patchStyle(lastStyle, nextStyle, dom); + if (lastVNode.className !== nextClassName) { + if (isNullOrUndefined(nextClassName)) { + dom.removeAttribute('class'); + } else { + dom.className = nextClassName; } } - if (nextBp.hasHooks === true && !isNullOrUndefined(nextHooks.didUpdate)) { - nextHooks.didUpdate(dom); + } + if (lastBp.hasStyle === true || nextBp.hasStyle === true) { + var nextStyle = nextVNode.style; + var lastStyle = lastVNode.style; + + if (lastStyle !== nextStyle) { + patchStyle(lastStyle, nextStyle, dom); } - setFormElementProperties(nextTag, nextVNode); } + if (nextBp.hasHooks === true && !isNullOrUndefined(nextHooks.didUpdate)) { + nextHooks.didUpdate(dom); + } + setFormElementProperties(nextTag, nextVNode); } } +} - function patchVNodeWithoutBlueprint(lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG) { - var nextHooks = nextNode.hooks; - var nextHooksDefined = !isNullOrUndefined(nextHooks); +function patchVNodeWithoutBlueprint(lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG) { + var nextHooks = nextNode.hooks; + var nextHooksDefined = !isNullOrUndefined(nextHooks); - if (nextHooksDefined && !isNullOrUndefined(nextHooks.willUpdate)) { - nextHooks.willUpdate(lastNode.dom); - } - var nextTag = nextNode.tag || ((isNullOrUndefined(nextNode.bp)) ? null : nextNode.bp.tag); - var lastTag = lastNode.tag || ((isNullOrUndefined(lastNode.bp)) ? null : lastNode.bp.tag); + if (nextHooksDefined && !isNullOrUndefined(nextHooks.willUpdate)) { + nextHooks.willUpdate(lastNode.dom); + } + var nextTag = nextNode.tag || ((isNullOrUndefined(nextNode.bp)) ? null : nextNode.bp.tag); + var lastTag = lastNode.tag || ((isNullOrUndefined(lastNode.bp)) ? null : lastNode.bp.tag); - if (nextTag === 'svg') { - isSVG = true; - } - if (lastTag !== nextTag) { - var lastNodeInstance = lastNode.instance; + if (nextTag === 'svg') { + isSVG = true; + } + if (lastTag !== nextTag) { + var lastNodeInstance = lastNode.instance; - if (isFunction(lastTag)) { - if (isFunction(nextTag)) { - replaceWithNewNode(lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); - } else if (isStatefulComponent(lastTag)) { - unmountVNode(lastNode, null, true); - patchVNodeWithoutBlueprint(lastNodeInstance._lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); - } else { - unmountVNode(lastNode, null, true); - patchVNodeWithoutBlueprint(lastNodeInstance, nextNode, parentDom, lifecycle, context, instance, isSVG); - } + if (isFunction(lastTag)) { + if (isFunction(nextTag)) { + replaceWithNewNode(lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); + } else if (isStatefulComponent(lastTag)) { + unmountVNode(lastNode, null, true); + patchVNodeWithoutBlueprint(lastNodeInstance._lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); } else { - replaceWithNewNode(lastNodeInstance || lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); + unmountVNode(lastNode, null, true); + patchVNodeWithoutBlueprint(lastNodeInstance, nextNode, parentDom, lifecycle, context, instance, isSVG); } - } else if (isNullOrUndefined(lastTag)) { - nextNode.dom = lastNode.dom; } else { - if (isFunction(lastTag)) { - if (isFunction(nextTag)) { - var instance$1 = lastNode._instance; - - if (!isNullOrUndefined(instance$1) && instance$1._unmounted) { - var newDom = mountComponent(nextNode, lastTag, nextNode.attrs || {}, nextNode.hooks, nextNode.children, instance$1, parentDom, lifecycle, context); - if (parentDom !== null) { - replaceNode(parentDom, newDom, lastNode.dom); - } - } else { - nextNode.instance = lastNode.instance; - nextNode.dom = lastNode.dom; - patchComponent(false, nextNode, nextNode.tag, null, null, nextNode.instance, lastNode.attrs || {}, nextNode.attrs || {}, nextNode.hooks, lastNode.children, nextNode.children, parentDom, lifecycle, context); + replaceWithNewNode(lastNodeInstance || lastNode, nextNode, parentDom, lifecycle, context, instance, isSVG); + } + } else if (isNullOrUndefined(lastTag)) { + nextNode.dom = lastNode.dom; + } else { + if (isFunction(lastTag)) { + if (isFunction(nextTag)) { + var instance$1 = lastNode._instance; + + if (!isNullOrUndefined(instance$1) && instance$1._unmounted) { + var newDom = mountComponent(nextNode, lastTag, nextNode.attrs || {}, nextNode.hooks, nextNode.children, instance$1, parentDom, lifecycle, context); + if (parentDom !== null) { + replaceNode(parentDom, newDom, lastNode.dom); } + } else { + nextNode.instance = lastNode.instance; + nextNode.dom = lastNode.dom; + patchComponent(false, nextNode, nextNode.tag, null, null, nextNode.instance, lastNode.attrs || {}, nextNode.attrs || {}, nextNode.hooks, lastNode.children, nextNode.children, parentDom, lifecycle, context); } - } else { - var dom = lastNode.dom; - var nextClassName = nextNode.className; - var nextStyle = nextNode.style; + } + } else { + var dom = lastNode.dom; + var nextClassName = nextNode.className; + var nextStyle = nextNode.style; - nextNode.dom = dom; + nextNode.dom = dom; - patchChildren(lastNode, nextNode, dom, lifecycle, context, instance, isSVG); - patchAttributes(lastNode, nextNode, null, null, dom, instance); - patchEvents(lastNode.events, nextNode.events, null, null, dom); + patchChildren(lastNode, nextNode, dom, lifecycle, context, instance, isSVG); + patchAttributes(lastNode, nextNode, null, null, dom, instance); + patchEvents(lastNode.events, nextNode.events, null, null, dom); - if (lastNode.className !== nextClassName) { - if (isNullOrUndefined(nextClassName)) { - dom.removeAttribute('class'); - } else { - dom.className = nextClassName; - } - } - if (lastNode.style !== nextStyle) { - patchStyle(lastNode.style, nextStyle, dom); - } - if (nextHooksDefined && !isNullOrUndefined(nextHooks.didUpdate)) { - nextHooks.didUpdate(dom); + if (lastNode.className !== nextClassName) { + if (isNullOrUndefined(nextClassName)) { + dom.removeAttribute('class'); + } else { + dom.className = nextClassName; } - setFormElementProperties(nextTag, nextNode); } + if (lastNode.style !== nextStyle) { + patchStyle(lastNode.style, nextStyle, dom); + } + if (nextHooksDefined && !isNullOrUndefined(nextHooks.didUpdate)) { + nextHooks.didUpdate(dom); + } + setFormElementProperties(nextTag, nextNode); } } +} - function patchAttributes(lastNode, nextNode, lastAttrKeys, nextAttrKeys, dom, instance) { - if (lastNode.tag === 'select') { - selectValue(nextNode); - } - var nextAttrs = nextNode.attrs; - var lastAttrs = lastNode.attrs; - var nextAttrsIsUndef = isNullOrUndefined(nextAttrs); - var lastAttrsIsNotUndef = !isNullOrUndefined(lastAttrs); +function patchAttributes(lastNode, nextNode, lastAttrKeys, nextAttrKeys, dom, instance) { + if (lastNode.tag === 'select') { + selectValue(nextNode); + } + var nextAttrs = nextNode.attrs; + var lastAttrs = lastNode.attrs; + var nextAttrsIsUndef = isNullOrUndefined(nextAttrs); + var lastAttrsIsNotUndef = !isNullOrUndefined(lastAttrs); - if (!nextAttrsIsUndef) { - var nextAttrsKeys = nextAttrKeys || Object.keys(nextAttrs); - var attrKeysLength = nextAttrsKeys.length; + if (!nextAttrsIsUndef) { + var nextAttrsKeys = nextAttrKeys || Object.keys(nextAttrs); + var attrKeysLength = nextAttrsKeys.length; - for (var i = 0; i < attrKeysLength; i++) { - var attr = nextAttrsKeys[i]; - var lastAttrVal = lastAttrsIsNotUndef && lastAttrs[attr]; - var nextAttrVal = nextAttrs[attr]; + for (var i = 0; i < attrKeysLength; i++) { + var attr = nextAttrsKeys[i]; + var lastAttrVal = lastAttrsIsNotUndef && lastAttrs[attr]; + var nextAttrVal = nextAttrs[attr]; - if (lastAttrVal !== nextAttrVal) { - if (attr === 'ref') { - patchRef(instance, lastAttrVal, nextAttrVal, dom); - } else { - patchAttribute(attr, lastAttrVal, nextAttrVal, dom); - } + if (lastAttrVal !== nextAttrVal) { + if (attr === 'ref') { + patchRef(instance, lastAttrVal, nextAttrVal, dom); + } else { + patchAttribute(attr, lastAttrVal, nextAttrVal, dom); } } } - if (lastAttrsIsNotUndef) { - var lastAttrsKeys = lastAttrKeys || Object.keys(lastAttrs); - var attrKeysLength$1 = lastAttrsKeys.length; + } + if (lastAttrsIsNotUndef) { + var lastAttrsKeys = lastAttrKeys || Object.keys(lastAttrs); + var attrKeysLength$1 = lastAttrsKeys.length; - for (var i$1 = 0; i$1 < attrKeysLength$1; i$1++) { - var attr$1 = lastAttrsKeys[i$1]; + for (var i$1 = 0; i$1 < attrKeysLength$1; i$1++) { + var attr$1 = lastAttrsKeys[i$1]; - if (nextAttrsIsUndef || isNullOrUndefined(nextAttrs[attr$1])) { - if (attr$1 === 'ref') { - patchRef(getRefInstance(node, instance), lastAttrs[attr$1], null, dom); - } else { - dom.removeAttribute(attr$1); - } + if (nextAttrsIsUndef || isNullOrUndefined(nextAttrs[attr$1])) { + if (attr$1 === 'ref') { + patchRef(getRefInstance(node, instance), lastAttrs[attr$1], null, dom); + } else { + dom.removeAttribute(attr$1); } } } } +} - function patchStyle(lastAttrValue, nextAttrValue, dom) { - if (isString(nextAttrValue)) { - dom.style.cssText = nextAttrValue; - } else if (isNullOrUndefined(lastAttrValue)) { - if (!isNullOrUndefined(nextAttrValue)) { - var styleKeys = Object.keys(nextAttrValue); +function patchStyle(lastAttrValue, nextAttrValue, dom) { + if (isString(nextAttrValue)) { + dom.style.cssText = nextAttrValue; + } else if (isNullOrUndefined(lastAttrValue)) { + if (!isNullOrUndefined(nextAttrValue)) { + var styleKeys = Object.keys(nextAttrValue); - for (var i = 0; i < styleKeys.length; i++) { - var style = styleKeys[i]; - var value = nextAttrValue[style]; + for (var i = 0; i < styleKeys.length; i++) { + var style = styleKeys[i]; + var value = nextAttrValue[style]; - if (isNumber(value) && !isUnitlessNumber[style]) { - dom.style[style] = value + 'px'; - } else { - dom.style[style] = value; - } + if (isNumber(value) && !isUnitlessNumber[style]) { + dom.style[style] = value + 'px'; + } else { + dom.style[style] = value; } } - } else if (isNullOrUndefined(nextAttrValue)) { - dom.removeAttribute('style'); - } else { - var styleKeys$1 = Object.keys(nextAttrValue); + } + } else if (isNullOrUndefined(nextAttrValue)) { + dom.removeAttribute('style'); + } else { + var styleKeys$1 = Object.keys(nextAttrValue); - for (var i$1 = 0; i$1 < styleKeys$1.length; i$1++) { - var style$1 = styleKeys$1[i$1]; - var value$1 = nextAttrValue[style$1]; + for (var i$1 = 0; i$1 < styleKeys$1.length; i$1++) { + var style$1 = styleKeys$1[i$1]; + var value$1 = nextAttrValue[style$1]; - if (isNumber(value$1) && !isUnitlessNumber[style$1]) { - dom.style[style$1] = value$1 + 'px'; - } else { - dom.style[style$1] = value$1; - } + if (isNumber(value$1) && !isUnitlessNumber[style$1]) { + dom.style[style$1] = value$1 + 'px'; + } else { + dom.style[style$1] = value$1; } - var lastStyleKeys = Object.keys(lastAttrValue); + } + var lastStyleKeys = Object.keys(lastAttrValue); - for (var i$2 = 0; i$2 < lastStyleKeys.length; i$2++) { - var style$2 = lastStyleKeys[i$2]; - if (isNullOrUndefined(nextAttrValue[style$2])) { - dom.style[style$2] = ''; - } + for (var i$2 = 0; i$2 < lastStyleKeys.length; i$2++) { + var style$2 = lastStyleKeys[i$2]; + if (isNullOrUndefined(nextAttrValue[style$2])) { + dom.style[style$2] = ''; } } } +} - function patchEvents(lastEvents, nextEvents, _lastEventKeys, _nextEventKeys, dom) { - var nextEventsDefined = !isNullOrUndefined(nextEvents); - var lastEventsDefined = !isNullOrUndefined(lastEvents); - var lastEventKeys; +function patchEvents(lastEvents, nextEvents, _lastEventKeys, _nextEventKeys, dom) { + var nextEventsDefined = !isNullOrUndefined(nextEvents); + var lastEventsDefined = !isNullOrUndefined(lastEvents); + var lastEventKeys; - if (lastEventsDefined) { - lastEventKeys = _lastEventKeys || Object.keys(lastEvents); - } - if (nextEventsDefined) { - var nextEventKeys = _nextEventKeys || Object.keys(nextEvents); + if (lastEventsDefined) { + lastEventKeys = _lastEventKeys || Object.keys(lastEvents); + } + if (nextEventsDefined) { + var nextEventKeys = _nextEventKeys || Object.keys(nextEvents); - if (lastEventsDefined) { - for (var i = 0; i < nextEventKeys.length; i++) { - var event = nextEventKeys[i]; - var lastEvent = lastEvents[event]; - var nextEvent = nextEvents[event]; + if (lastEventsDefined) { + for (var i = 0; i < nextEventKeys.length; i++) { + var event = nextEventKeys[i]; + var lastEvent = lastEvents[event]; + var nextEvent = nextEvents[event]; - if (lastEvent !== nextEvent) { - dom[event] = nextEvent; - } + if (lastEvent !== nextEvent) { + dom[event] = nextEvent; } - for (var i$1 = 0; i$1 < lastEventKeys.length; i$1++) { - var event$1 = lastEventKeys[i$1]; + } + for (var i$1 = 0; i$1 < lastEventKeys.length; i$1++) { + var event$1 = lastEventKeys[i$1]; - if (isNullOrUndefined(nextEvents[event$1])) { - dom[event$1] = null; - } + if (isNullOrUndefined(nextEvents[event$1])) { + dom[event$1] = null; } - } else { - mountEvents(nextEvents, nextEventKeys, dom); } - } else if (lastEventsDefined) { - removeEvents(lastEvents, lastEventKeys, dom); + } else { + mountEvents(nextEvents, nextEventKeys, dom); } + } else if (lastEventsDefined) { + removeEvents(lastEvents, lastEventKeys, dom); } +} - function patchAttribute(attrName, lastAttrValue, nextAttrValue, dom) { - if (attrName === 'dangerouslySetInnerHTML') { - var lastHtml = lastAttrValue && lastAttrValue.__html; - var nextHtml = nextAttrValue && nextAttrValue.__html; +function patchAttribute(attrName, lastAttrValue, nextAttrValue, dom) { + if (attrName === 'dangerouslySetInnerHTML') { + var lastHtml = lastAttrValue && lastAttrValue.__html; + var nextHtml = nextAttrValue && nextAttrValue.__html; - if (isNullOrUndefined(nextHtml)) { - throw new Error('Inferno Error: dangerouslySetInnerHTML requires an object with a __html propety containing the innerHTML content'); - } - if (lastHtml !== nextHtml) { - dom.innerHTML = nextHtml; - } - } else if (attrName === 'eventData') { - dom.eventData = nextAttrValue; - } else if (strictProps[attrName]) { - dom[attrName] = nextAttrValue === null ? '' : nextAttrValue; + if (isNullOrUndefined(nextHtml)) { + throw new Error('Inferno Error: dangerouslySetInnerHTML requires an object with a __html propety containing the innerHTML content'); + } + if (lastHtml !== nextHtml) { + dom.innerHTML = nextHtml; + } + } else if (attrName === 'eventData') { + dom.eventData = nextAttrValue; + } else if (strictProps[attrName]) { + dom[attrName] = nextAttrValue === null ? '' : nextAttrValue; + } else { + if (booleanProps[attrName]) { + dom[attrName] = nextAttrValue ? true : false; } else { - if (booleanProps[attrName]) { - dom[attrName] = nextAttrValue ? true : false; - } else { - var ns = namespaces[attrName]; + var ns = namespaces[attrName]; - if (nextAttrValue === false || isNullOrUndefined(nextAttrValue)) { - if (ns !== undefined) { - dom.removeAttributeNS(ns, attrName); - } else { - dom.removeAttribute(attrName); - } + if (nextAttrValue === false || isNullOrUndefined(nextAttrValue)) { + if (ns !== undefined) { + dom.removeAttributeNS(ns, attrName); } else { - if (ns !== undefined) { - dom.setAttributeNS(ns, attrName, nextAttrValue === true ? attrName : nextAttrValue); - } else { - dom.setAttribute(attrName, nextAttrValue === true ? attrName : nextAttrValue); - } + dom.removeAttribute(attrName); + } + } else { + if (ns !== undefined) { + dom.setAttributeNS(ns, attrName, nextAttrValue === true ? attrName : nextAttrValue); + } else { + dom.setAttribute(attrName, nextAttrValue === true ? attrName : nextAttrValue); } } } } +} - function patchComponent(hasBlueprint, lastNode, Component, lastBp, nextBp, instance, lastProps, nextProps, nextHooks, lastChildren, nextChildren, parentDom, lifecycle, context) { - nextProps = addChildrenToProps(nextChildren, nextProps); +function patchComponent(hasBlueprint, lastNode, Component, lastBp, nextBp, instance, lastProps, nextProps, nextHooks, lastChildren, nextChildren, parentDom, lifecycle, context) { + nextProps = addChildrenToProps(nextChildren, nextProps); - if (isStatefulComponent(Component)) { - var prevProps = instance.props; - var prevState = instance.state; - var nextState = instance.state; + if (isStatefulComponent(Component)) { + var prevProps = instance.props; + var prevState = instance.state; + var nextState = instance.state; - var childContext = instance.getChildContext(); - if (!isNullOrUndefined(childContext)) { - context = Object.assign({}, context, childContext); - } - instance.context = context; - var nextNode = instance._updateComponent(prevState, nextState, prevProps, nextProps); + var childContext = instance.getChildContext(); + if (!isNullOrUndefined(childContext)) { + context = Object.assign({}, context, childContext); + } + instance.context = context; + var nextNode = instance._updateComponent(prevState, nextState, prevProps, nextProps); - if (nextNode === NO_RENDER) { - nextNode = instance._lastNode; - } else if (isNullOrUndefined(nextNode)) { - nextNode = createVPlaceholder(); - } - patch(instance._lastNode, nextNode, parentDom, lifecycle, context, instance, null, false); - lastNode.dom = nextNode.dom; - instance._lastNode = nextNode; - instance.componentDidUpdate(prevProps, prevState); - componentToDOMNodeMap.set(instance, nextNode.dom); - } else { - var shouldUpdate = true; - var nextHooksDefined = (hasBlueprint && nextBp.hasHooks === true) || !isNullOrUndefined(nextHooks); + if (nextNode === NO_RENDER) { + nextNode = instance._lastNode; + } else if (isNullOrUndefined(nextNode)) { + nextNode = createVPlaceholder(); + } + patch(instance._lastNode, nextNode, parentDom, lifecycle, context, instance, null, false); + lastNode.dom = nextNode.dom; + instance._lastNode = nextNode; + instance.componentDidUpdate(prevProps, prevState); + componentToDOMNodeMap.set(instance, nextNode.dom); + } else { + var shouldUpdate = true; + var nextHooksDefined = (hasBlueprint && nextBp.hasHooks === true) || !isNullOrUndefined(nextHooks); - lastProps = addChildrenToProps(lastChildren, lastProps); - if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentShouldUpdate)) { - shouldUpdate = nextHooks.componentShouldUpdate(lastNode.dom, lastProps, nextProps); + lastProps = addChildrenToProps(lastChildren, lastProps); + if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentShouldUpdate)) { + shouldUpdate = nextHooks.componentShouldUpdate(lastNode.dom, lastProps, nextProps); + } + if (shouldUpdate !== false) { + if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentWillUpdate)) { + nextHooks.componentWillUpdate(lastNode.dom, lastProps, nextProps); } - if (shouldUpdate !== false) { - if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentWillUpdate)) { - nextHooks.componentWillUpdate(lastNode.dom, lastProps, nextProps); - } - var nextNode$1 = Component(nextProps, context); + var nextNode$1 = Component(nextProps, context); - if (isInvalidNode(nextNode$1)) { - nextNode$1 = createVPlaceholder(); - } - nextNode$1.dom = lastNode.dom; - patch(instance, nextNode$1, parentDom, lifecycle, context, null, null, false); - lastNode.instance = nextNode$1; - if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentDidUpdate)) { - nextHooks.componentDidUpdate(lastNode.dom, lastProps, nextProps); - } + if (isInvalidNode(nextNode$1)) { + nextNode$1 = createVPlaceholder(); + } + nextNode$1.dom = lastNode.dom; + patch(instance, nextNode$1, parentDom, lifecycle, context, null, null, false); + lastNode.instance = nextNode$1; + if (nextHooksDefined && !isNullOrUndefined(nextHooks.componentDidUpdate)) { + nextHooks.componentDidUpdate(lastNode.dom, lastProps, nextProps); } } } +} - function patchVList(lastVList, nextVList, parentDom, lifecycle, context, instance, isSVG) { - var lastItems = lastVList.items; - var nextItems = nextVList.items; - var pointer = lastVList.pointer; +function patchVList(lastVList, nextVList, parentDom, lifecycle, context, instance, isSVG) { + var lastItems = lastVList.items; + var nextItems = nextVList.items; + var pointer = lastVList.pointer; - nextVList.dom = lastVList.dom; - nextVList.pointer = pointer; - if (!lastItems !== nextItems) { - if (isKeyed(lastItems, nextItems)) { - patchKeyedChildren(lastItems, nextItems, parentDom, lifecycle, context, instance, isSVG, nextVList); - } else { - patchNonKeyedChildren(lastItems, nextItems, parentDom, lifecycle, context, instance, isSVG, nextVList); - } + nextVList.dom = lastVList.dom; + nextVList.pointer = pointer; + if (!lastItems !== nextItems) { + if (isKeyed(lastItems, nextItems)) { + patchKeyedChildren(lastItems, nextItems, parentDom, lifecycle, context, instance, isSVG, nextVList); + } else { + patchNonKeyedChildren(lastItems, nextItems, parentDom, lifecycle, context, instance, isSVG, nextVList); } } +} - function patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, parentVList) { - var lastChildrenLength = lastChildren.length; - var nextChildrenLength = nextChildren.length; - var commonLength = lastChildrenLength > nextChildrenLength ? nextChildrenLength : lastChildrenLength; - var i = 0; +function patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, parentVList) { + var lastChildrenLength = lastChildren.length; + var nextChildrenLength = nextChildren.length; + var commonLength = lastChildrenLength > nextChildrenLength ? nextChildrenLength : lastChildrenLength; + var i = 0; - for (; i < commonLength; i++) { - var lastChild = lastChildren[i]; - var nextChild = normaliseChild(nextChildren, i); + for (; i < commonLength; i++) { + var lastChild = lastChildren[i]; + var nextChild = normaliseChild(nextChildren, i); - patch(lastChild, nextChild, dom, lifecycle, context, instance, isSVG); - } - if (lastChildrenLength < nextChildrenLength) { - for (i = commonLength; i < nextChildrenLength; i++) { - var child = normaliseChild(nextChildren, i); + patch(lastChild, nextChild, dom, lifecycle, context, instance, isSVG); + } + if (lastChildrenLength < nextChildrenLength) { + for (i = commonLength; i < nextChildrenLength; i++) { + var child = normaliseChild(nextChildren, i); - insertOrAppend(dom, mount(child, null, lifecycle, context, instance, isSVG), parentVList && parentVList.pointer); - } - } else if (lastChildrenLength > nextChildrenLength) { - for (i = commonLength; i < lastChildrenLength; i++) { - remove(lastChildren[i], dom); - } + insertOrAppend(dom, mount(child, null, lifecycle, context, instance, isSVG), parentVList && parentVList.pointer); + } + } else if (lastChildrenLength > nextChildrenLength) { + for (i = commonLength; i < lastChildrenLength; i++) { + remove(lastChildren[i], dom); } } +} - function patchVFragment(lastVFragment, nextVFragment) { - nextVFragment.dom = lastVFragment.dom; - } +function patchVFragment(lastVFragment, nextVFragment) { + nextVFragment.dom = lastVFragment.dom; +} - function patchVText(lastVText, nextVText) { - var nextText = nextVText.text; - var dom = lastVText.dom; +function patchVText(lastVText, nextVText) { + var nextText = nextVText.text; + var dom = lastVText.dom; - nextVText.dom = dom; - if (lastVText.text !== nextText) { - dom.nodeValue = nextText; - } + nextVText.dom = dom; + if (lastVText.text !== nextText) { + dom.nodeValue = nextText; } +} - function patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, parentVList) { - var lastChildrenLength = lastChildren.length; - var nextChildrenLength = nextChildren.length; - var lastEndIndex = lastChildrenLength - 1; - var nextEndIndex = nextChildrenLength - 1; - var lastStartIndex = 0; - var nextStartIndex = 0; - var lastStartNode = null; - var nextStartNode = null; - var nextEndNode = null; - var lastEndNode = null; - var nextNode; +function patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, instance, isSVG, parentVList) { + var lastChildrenLength = lastChildren.length; + var nextChildrenLength = nextChildren.length; + var lastEndIndex = lastChildrenLength - 1; + var nextEndIndex = nextChildrenLength - 1; + var lastStartIndex = 0; + var nextStartIndex = 0; + var lastStartNode = null; + var nextStartNode = null; + var nextEndNode = null; + var lastEndNode = null; + var nextNode; - while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { - nextStartNode = nextChildren[nextStartIndex]; - lastStartNode = lastChildren[lastStartIndex]; + while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { + nextStartNode = nextChildren[nextStartIndex]; + lastStartNode = lastChildren[lastStartIndex]; - if (nextStartNode.key !== lastStartNode.key) { - break; - } - patchVNode(lastStartNode, nextStartNode, dom, lifecycle, context, instance, isSVG, false); - nextStartIndex++; - lastStartIndex++; + if (nextStartNode.key !== lastStartNode.key) { + break; } - while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { - nextEndNode = nextChildren[nextEndIndex]; - lastEndNode = lastChildren[lastEndIndex]; + patchVNode(lastStartNode, nextStartNode, dom, lifecycle, context, instance, isSVG, false); + nextStartIndex++; + lastStartIndex++; + } + while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { + nextEndNode = nextChildren[nextEndIndex]; + lastEndNode = lastChildren[lastEndIndex]; - if (nextEndNode.key !== lastEndNode.key) { - break; - } - patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); - nextEndIndex--; - lastEndIndex--; + if (nextEndNode.key !== lastEndNode.key) { + break; } - while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { - nextEndNode = nextChildren[nextEndIndex]; - lastStartNode = lastChildren[lastStartIndex]; + patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); + nextEndIndex--; + lastEndIndex--; + } + while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { + nextEndNode = nextChildren[nextEndIndex]; + lastStartNode = lastChildren[lastStartIndex]; - if (nextEndNode.key !== lastStartNode.key) { - break; - } - nextNode = (nextEndIndex + 1 < nextChildrenLength) ? nextChildren[nextEndIndex + 1].dom : null; - patchVNode(lastStartNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); - insertOrAppend(dom, nextEndNode.dom, nextNode); - nextEndIndex--; - lastStartIndex++; - } - while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { - nextStartNode = nextChildren[nextStartIndex]; - lastEndNode = lastChildren[lastEndIndex]; - - if (nextStartNode.key !== lastEndNode.key) { - break; - } - nextNode = lastChildren[lastStartIndex].dom; - patchVNode(lastEndNode, nextStartNode, dom, lifecycle, context, instance, isSVG, false); - insertOrAppend(dom, nextStartNode.dom, nextNode); - nextStartIndex++; - lastEndIndex--; - } - - if (lastStartIndex > lastEndIndex) { - if (nextStartIndex <= nextEndIndex) { - nextNode = (nextEndIndex + 1 < nextChildrenLength) ? nextChildren[nextEndIndex + 1].dom : parentVList && parentVList.pointer; - for (; nextStartIndex <= nextEndIndex; nextStartIndex++) { - insertOrAppend(dom, mount(nextChildren[nextStartIndex], null, lifecycle, context, instance, isSVG), nextNode); - } - } - } else if (nextStartIndex > nextEndIndex) { - while (lastStartIndex <= lastEndIndex) { - remove(lastChildren[lastStartIndex++], dom); - } - } else { - var aLength = lastEndIndex - lastStartIndex + 1; - var bLength = nextEndIndex - nextStartIndex + 1; - var sources = new Array(bLength); - - // Mark all nodes as inserted. - var i; - for (i = 0; i < bLength; i++) { - sources[i] = -1; - } - var moved = false; - var removeOffset = 0; - var lastTarget = 0; - var index; - var removed = true; - var k = 0; - - if ((bLength <= 4) || (aLength * bLength <= 16)) { - for (i = lastStartIndex; i <= lastEndIndex; i++) { - removed = true; - lastEndNode = lastChildren[i]; - if (k < bLength) { - for (index = nextStartIndex; index <= nextEndIndex; index++) { - nextEndNode = nextChildren[index]; - if (lastEndNode.key === nextEndNode.key) { - sources[index - nextStartIndex] = i; - - if (lastTarget > index) { - moved = true; - } else { - lastTarget = index; - } - patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); - k++; - removed = false; - break; - } - } - } - if (removed) { - remove(lastEndNode, dom); - removeOffset++; - } - } - } else { - var prevItemsMap = new Map(); + if (nextEndNode.key !== lastStartNode.key) { + break; + } + nextNode = (nextEndIndex + 1 < nextChildrenLength) ? nextChildren[nextEndIndex + 1].dom : null; + patchVNode(lastStartNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); + insertOrAppend(dom, nextEndNode.dom, nextNode); + nextEndIndex--; + lastStartIndex++; + } + while (lastStartIndex <= lastEndIndex && nextStartIndex <= nextEndIndex) { + nextStartNode = nextChildren[nextStartIndex]; + lastEndNode = lastChildren[lastEndIndex]; - for (i = nextStartIndex; i <= nextEndIndex; i++) { - prevItemsMap.set(nextChildren[i].key, i); - } - for (i = lastStartIndex; i <= lastEndIndex; i++) { - removed = true; - lastEndNode = lastChildren[i]; + if (nextStartNode.key !== lastEndNode.key) { + break; + } + nextNode = lastChildren[lastStartIndex].dom; + patchVNode(lastEndNode, nextStartNode, dom, lifecycle, context, instance, isSVG, false); + insertOrAppend(dom, nextStartNode.dom, nextNode); + nextStartIndex++; + lastEndIndex--; + } - if (k < nextChildrenLength) { - index = prevItemsMap.get(lastEndNode.key); + if (lastStartIndex > lastEndIndex) { + if (nextStartIndex <= nextEndIndex) { + nextNode = (nextEndIndex + 1 < nextChildrenLength) ? nextChildren[nextEndIndex + 1].dom : parentVList && parentVList.pointer; + for (; nextStartIndex <= nextEndIndex; nextStartIndex++) { + insertOrAppend(dom, mount(nextChildren[nextStartIndex], null, lifecycle, context, instance, isSVG), nextNode); + } + } + } else if (nextStartIndex > nextEndIndex) { + while (lastStartIndex <= lastEndIndex) { + remove(lastChildren[lastStartIndex++], dom); + } + } else { + var aLength = lastEndIndex - lastStartIndex + 1; + var bLength = nextEndIndex - nextStartIndex + 1; + var sources = new Array(bLength); - if (index !== undefined) { - nextEndNode = nextChildren[index]; + // Mark all nodes as inserted. + var i; + for (i = 0; i < bLength; i++) { + sources[i] = -1; + } + var moved = false; + var removeOffset = 0; + var lastTarget = 0; + var index; + var removed = true; + var k = 0; + + if ((bLength <= 4) || (aLength * bLength <= 16)) { + for (i = lastStartIndex; i <= lastEndIndex; i++) { + removed = true; + lastEndNode = lastChildren[i]; + if (k < bLength) { + for (index = nextStartIndex; index <= nextEndIndex; index++) { + nextEndNode = nextChildren[index]; + if (lastEndNode.key === nextEndNode.key) { sources[index - nextStartIndex] = i; + if (lastTarget > index) { moved = true; } else { @@ -1607,435 +1574,468 @@ patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); k++; removed = false; + break; } } - if (removed) { - remove(lastEndNode, dom); - removeOffset++; - } + } + if (removed) { + remove(lastEndNode, dom); + removeOffset++; } } + } else { + var prevItemsMap = new Map(); - var pos; - if (moved) { - var seq = lis_algorithm(sources); - index = seq.length - 1; - for (i = bLength - 1; i >= 0; i--) { - if (sources[i] === -1) { - pos = i + nextStartIndex; - nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; - insertOrAppend(dom, mount(nextChildren[pos], null, lifecycle, context, instance, isSVG), nextNode); - } else { - if (index < 0 || i !== seq[index]) { - pos = i + nextStartIndex; - nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; - insertOrAppend(dom, nextChildren[pos].dom, nextNode); + for (i = nextStartIndex; i <= nextEndIndex; i++) { + prevItemsMap.set(nextChildren[i].key, i); + } + for (i = lastStartIndex; i <= lastEndIndex; i++) { + removed = true; + lastEndNode = lastChildren[i]; + + if (k < nextChildrenLength) { + index = prevItemsMap.get(lastEndNode.key); + + if (index !== undefined) { + nextEndNode = nextChildren[index]; + sources[index - nextStartIndex] = i; + if (lastTarget > index) { + moved = true; } else { - index--; + lastTarget = index; } + patchVNode(lastEndNode, nextEndNode, dom, lifecycle, context, instance, isSVG, false); + k++; + removed = false; } } - } else if (aLength - removeOffset !== bLength) { - for (i = bLength - 1; i >= 0; i--) { - if (sources[i] === -1) { + if (removed) { + remove(lastEndNode, dom); + removeOffset++; + } + } + } + + var pos; + if (moved) { + var seq = lis_algorithm(sources); + index = seq.length - 1; + for (i = bLength - 1; i >= 0; i--) { + if (sources[i] === -1) { + pos = i + nextStartIndex; + nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; + insertOrAppend(dom, mount(nextChildren[pos], null, lifecycle, context, instance, isSVG), nextNode); + } else { + if (index < 0 || i !== seq[index]) { pos = i + nextStartIndex; nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; - insertOrAppend(dom, mount(nextChildren[pos], null, lifecycle, context, instance, isSVG), nextNode); + insertOrAppend(dom, nextChildren[pos].dom, nextNode); + } else { + index--; } } } + } else if (aLength - removeOffset !== bLength) { + for (i = bLength - 1; i >= 0; i--) { + if (sources[i] === -1) { + pos = i + nextStartIndex; + nextNode = (pos + 1 < nextChildrenLength) ? nextChildren[pos + 1].dom : parentVList && parentVList.pointer; + insertOrAppend(dom, mount(nextChildren[pos], null, lifecycle, context, instance, isSVG), nextNode); + } + } } } +} - // https://en.wikipedia.org/wiki/Longest_increasing_subsequence - function lis_algorithm(a) { - var p = a.slice(0); - var result = []; - result.push(0); - var i; - var j; - var u; - var v; - var c; - - for (i = 0; i < a.length; i++) { - if (a[i] === -1) { - continue; - } +// https://en.wikipedia.org/wiki/Longest_increasing_subsequence +function lis_algorithm(a) { + var p = a.slice(0); + var result = []; + result.push(0); + var i; + var j; + var u; + var v; + var c; - j = result[result.length - 1]; - if (a[j] < a[i]) { - p[i] = j; - result.push(i); - continue; - } + for (i = 0; i < a.length; i++) { + if (a[i] === -1) { + continue; + } - u = 0; - v = result.length - 1; + j = result[result.length - 1]; + if (a[j] < a[i]) { + p[i] = j; + result.push(i); + continue; + } - while (u < v) { - c = ((u + v) / 2) | 0; - if (a[result[c]] < a[i]) { - u = c + 1; - } else { - v = c; - } - } + u = 0; + v = result.length - 1; - if (a[i] < a[result[u]]) { - if (u > 0) { - p[i] = result[u - 1]; - } - result[u] = i; + while (u < v) { + c = ((u + v) / 2) | 0; + if (a[result[c]] < a[i]) { + u = c + 1; + } else { + v = c; } } - u = result.length; - v = result[u - 1]; - - while (u-- > 0) { - result[u] = v; - v = p[v]; + if (a[i] < a[result[u]]) { + if (u > 0) { + p[i] = result[u - 1]; + } + result[u] = i; } - - return result; } - var screenWidth = isBrowser && window.screen.width; - var screenHeight = isBrowser && window.screen.height; - var scrollX = 0; - var scrollY = 0; - var lastScrollTime = 0; + u = result.length; + v = result[u - 1]; - if (isBrowser) { - window.onscroll = function () { - scrollX = window.scrollX; - scrollY = window.scrollY; - lastScrollTime = performance.now(); - }; - - window.resize = function () { - scrollX = window.scrollX; - scrollY = window.scrollY; - screenWidth = window.screen.width; - screenHeight = window.screen.height; - lastScrollTime = performance.now(); - }; + while (u-- > 0) { + result[u] = v; + v = p[v]; } - function Lifecycle() { - this._listeners = []; - this.scrollX = null; - this.scrollY = null; - this.screenHeight = screenHeight; - this.screenWidth = screenWidth; - } + return result; +} - Lifecycle.prototype = { - refresh: function refresh() { - this.scrollX = isBrowser && window.scrollX; - this.scrollY = isBrowser && window.scrollY; - }, - addListener: function addListener(callback) { - this._listeners.push(callback); - }, - trigger: function trigger() { - var this$1 = this; +var screenWidth = isBrowser && window.screen.width; +var screenHeight = isBrowser && window.screen.height; +var scrollX = 0; +var scrollY = 0; +var lastScrollTime = 0; - for (var i = 0; i < this._listeners.length; i++) { - this$1._listeners[i](); - } - } +if (isBrowser) { + window.onscroll = function () { + scrollX = window.scrollX; + scrollY = window.scrollY; + lastScrollTime = performance.now(); }; - function handleLazyAttached(node, lifecycle, dom) { - lifecycle.addListener(function () { - var rect = dom.getBoundingClientRect(); - - if (lifecycle.scrollY === null) { - lifecycle.refresh(); - } - node.clipData = { - top: rect.top + lifecycle.scrollY, - left: rect.left + lifecycle.scrollX, - bottom: rect.bottom + lifecycle.scrollY, - right: rect.right + lifecycle.scrollX, - pending: false - }; - }); - } - - function hydrateChild(child, childNodes, counter, parentDom, lifecycle, context, instance) { - var domNode = childNodes[counter.i]; + window.resize = function () { + scrollX = window.scrollX; + scrollY = window.scrollY; + screenWidth = window.screen.width; + screenHeight = window.screen.height; + lastScrollTime = performance.now(); + }; +} + +function Lifecycle() { + this._listeners = []; + this.scrollX = null; + this.scrollY = null; + this.screenHeight = screenHeight; + this.screenWidth = screenWidth; +} + +Lifecycle.prototype = { + refresh: function refresh() { + this.scrollX = isBrowser && window.scrollX; + this.scrollY = isBrowser && window.scrollY; + }, + addListener: function addListener(callback) { + this._listeners.push(callback); + }, + trigger: function trigger() { + var this$1 = this; + + for (var i = 0; i < this._listeners.length; i++) { + this$1._listeners[i](); + } + } +}; + +function handleLazyAttached(node, lifecycle, dom) { + lifecycle.addListener(function () { + var rect = dom.getBoundingClientRect(); + + if (lifecycle.scrollY === null) { + lifecycle.refresh(); + } + node.clipData = { + top: rect.top + lifecycle.scrollY, + left: rect.left + lifecycle.scrollX, + bottom: rect.bottom + lifecycle.scrollY, + right: rect.right + lifecycle.scrollX, + pending: false + }; + }); +} - if (isVText(child)) { - var text = child.text; +function hydrateChild(child, childNodes, counter, parentDom, lifecycle, context, instance) { + var domNode = childNodes[counter.i]; - child.dom = domNode; - if (domNode.nodeType === 3 && text !== '') { - domNode.nodeValue = text; - } else { - var newDomNode = mountVText(text); + if (isVText(child)) { + var text = child.text; - replaceNode(parentDom, newDomNode, domNode); - childNodes.splice(childNodes.indexOf(domNode), 1, newDomNode); - child.dom = newDomNode; - } - } else if (isVPlaceholder(child)) { - child.dom = domNode; - } else if (isVList(child)) { - var items = child.items; + child.dom = domNode; + if (domNode.nodeType === 3 && text !== '') { + domNode.nodeValue = text; + } else { + var newDomNode = mountVText(text); - // this doesn't really matter, as it won't be used again, but it's what it should be given the purpose of VList - child.dom = document.createDocumentFragment(); - for (var i = 0; i < items.length; i++) { - var rebuild = hydrateChild(normaliseChild(items, i), childNodes, counter, parentDom, lifecycle, context, instance); + replaceNode(parentDom, newDomNode, domNode); + childNodes.splice(childNodes.indexOf(domNode), 1, newDomNode); + child.dom = newDomNode; + } + } else if (isVPlaceholder(child)) { + child.dom = domNode; + } else if (isVList(child)) { + var items = child.items; - if (rebuild) { - return true; - } - } - // at the end of every VList, there should be a "pointer". It's an empty TextNode used for tracking the VList - var pointer = childNodes[counter.i++]; + // this doesn't really matter, as it won't be used again, but it's what it should be given the purpose of VList + child.dom = document.createDocumentFragment(); + for (var i = 0; i < items.length; i++) { + var rebuild = hydrateChild(normaliseChild(items, i), childNodes, counter, parentDom, lifecycle, context, instance); - if (pointer && pointer.nodeType === 3) { - child.pointer = pointer; - } else { - // there is a problem, we need to rebuild this tree + if (rebuild) { return true; } + } + // at the end of every VList, there should be a "pointer". It's an empty TextNode used for tracking the VList + var pointer = childNodes[counter.i++]; + + if (pointer && pointer.nodeType === 3) { + child.pointer = pointer; } else { - var rebuild$1 = hydrateNode(child, domNode, parentDom, lifecycle, context, instance, false); + // there is a problem, we need to rebuild this tree + return true; + } + } else { + var rebuild$1 = hydrateNode(child, domNode, parentDom, lifecycle, context, instance, false); - if (rebuild$1) { - return true; - } + if (rebuild$1) { + return true; } - counter.i++; } + counter.i++; +} - function getChildNodesWithoutComments(domNode) { - var childNodes = []; - var rawChildNodes = domNode.childNodes; - var length = rawChildNodes.length; - var i = 0; +function getChildNodesWithoutComments(domNode) { + var childNodes = []; + var rawChildNodes = domNode.childNodes; + var length = rawChildNodes.length; + var i = 0; - while (i < length) { - var rawChild = rawChildNodes[i]; + while (i < length) { + var rawChild = rawChildNodes[i]; - if (rawChild.nodeType === 8) { - if (rawChild.data === '!') { - var placeholder = document.createTextNode(''); + if (rawChild.nodeType === 8) { + if (rawChild.data === '!') { + var placeholder = document.createTextNode(''); - domNode.replaceChild(placeholder, rawChild); - childNodes.push(placeholder); - i++; - } else { - domNode.removeChild(rawChild); - length--; - } - } else { - childNodes.push(rawChild); + domNode.replaceChild(placeholder, rawChild); + childNodes.push(placeholder); i++; + } else { + domNode.removeChild(rawChild); + length--; } + } else { + childNodes.push(rawChild); + i++; } - return childNodes; } + return childNodes; +} - function hydrateComponent(node, Component, props, hooks, children, domNode, parentDom, lifecycle, context, lastInstance, isRoot) { - props = addChildrenToProps(children, props); +function hydrateComponent(node, Component, props, hooks, children, domNode, parentDom, lifecycle, context, lastInstance, isRoot) { + props = addChildrenToProps(children, props); - if (isStatefulComponent(Component)) { - var instance = node.instance = new Component(props); + if (isStatefulComponent(Component)) { + var instance = node.instance = new Component(props); - instance._patch = patch; - if (!isNullOrUndefined(lastInstance) && props.ref) { - mountRef(lastInstance, props.ref, instance); - } - var childContext = instance.getChildContext(); + instance._patch = patch; + if (!isNullOrUndefined(lastInstance) && props.ref) { + mountRef(lastInstance, props.ref, instance); + } + var childContext = instance.getChildContext(); - if (!isNullOrUndefined(childContext)) { - context = Object.assign({}, context, childContext); - } - instance.context = context; - instance._unmounted = false; - instance._parentNode = node; - if (lastInstance) { - instance._parentComponent = lastInstance; - } - instance._pendingSetState = true; - instance.componentWillMount(); - var nextNode = instance.render(); + if (!isNullOrUndefined(childContext)) { + context = Object.assign({}, context, childContext); + } + instance.context = context; + instance._unmounted = false; + instance._parentNode = node; + if (lastInstance) { + instance._parentComponent = lastInstance; + } + instance._pendingSetState = true; + instance.componentWillMount(); + var nextNode = instance.render(); - instance._pendingSetState = false; - if (isInvalidNode(nextNode)) { - nextNode = createVPlaceholder(); - } - hydrateNode(nextNode, domNode, parentDom, lifecycle, context, instance, isRoot); - instance._lastNode = nextNode; - instance.componentDidMount(); + instance._pendingSetState = false; + if (isInvalidNode(nextNode)) { + nextNode = createVPlaceholder(); + } + hydrateNode(nextNode, domNode, parentDom, lifecycle, context, instance, isRoot); + instance._lastNode = nextNode; + instance.componentDidMount(); - } else { - var instance$1 = node.instance = Component(props); + } else { + var instance$1 = node.instance = Component(props); - if (!isNullOrUndefined(hooks)) { - if (!isNullOrUndefined(hooks.componentWillMount)) { - hooks.componentWillMount(null, props); - } - if (!isNullOrUndefined(hooks.componentDidMount)) { - lifecycle.addListener(function () { - hooks.componentDidMount(domNode, props); - }); - } + if (!isNullOrUndefined(hooks)) { + if (!isNullOrUndefined(hooks.componentWillMount)) { + hooks.componentWillMount(null, props); + } + if (!isNullOrUndefined(hooks.componentDidMount)) { + lifecycle.addListener(function () { + hooks.componentDidMount(domNode, props); + }); } - return hydrateNode(instance$1, domNode, parentDom, lifecycle, context, instance$1, isRoot); } + return hydrateNode(instance$1, domNode, parentDom, lifecycle, context, instance$1, isRoot); } +} - function hydrateNode(node, domNode, parentDom, lifecycle, context, instance, isRoot) { - var bp = node.bp; - var tag = node.tag || bp.tag; +function hydrateNode(node, domNode, parentDom, lifecycle, context, instance, isRoot) { + var bp = node.bp; + var tag = node.tag || bp.tag; - if (isFunction(tag)) { - node.dom = domNode; - hydrateComponent(node, tag, node.attrs || {}, node.hooks, node.children, domNode, parentDom, lifecycle, context, instance, isRoot); + if (isFunction(tag)) { + node.dom = domNode; + hydrateComponent(node, tag, node.attrs || {}, node.hooks, node.children, domNode, parentDom, lifecycle, context, instance, isRoot); + } else { + if ( + domNode.nodeType !== 1 || + tag !== domNode.tagName.toLowerCase() + ) { + // TODO remake node } else { - if ( - domNode.nodeType !== 1 || - tag !== domNode.tagName.toLowerCase() - ) { - // TODO remake node - } else { - node.dom = domNode; - var hooks = node.hooks; + node.dom = domNode; + var hooks = node.hooks; - if ((bp && bp.hasHooks === true) || !isNullOrUndefined(hooks)) { - handleAttachedHooks(hooks, lifecycle, domNode); - } - var children = node.children; + if ((bp && bp.hasHooks === true) || !isNullOrUndefined(hooks)) { + handleAttachedHooks(hooks, lifecycle, domNode); + } + var children = node.children; - if (!isNullOrUndefined(children)) { - if (isStringOrNumber(children)) { - if (domNode.textContent !== children) { - domNode.textContent = children; - } - } else { - var childNodes = getChildNodesWithoutComments(domNode); - var counter = { i: 0 }; - var rebuild = false; + if (!isNullOrUndefined(children)) { + if (isStringOrNumber(children)) { + if (domNode.textContent !== children) { + domNode.textContent = children; + } + } else { + var childNodes = getChildNodesWithoutComments(domNode); + var counter = { i: 0 }; + var rebuild = false; - if (isArray(children)) { - for (var i = 0; i < children.length; i++) { - rebuild = hydrateChild(normaliseChild(children, i), childNodes, counter, domNode, lifecycle, context, instance); + if (isArray(children)) { + for (var i = 0; i < children.length; i++) { + rebuild = hydrateChild(normaliseChild(children, i), childNodes, counter, domNode, lifecycle, context, instance); - if (rebuild) { - break; - } + if (rebuild) { + break; } + } + } else { + if (childNodes.length === 1) { + rebuild = hydrateChild(children, childNodes, counter, domNode, lifecycle, context, instance); } else { - if (childNodes.length === 1) { - rebuild = hydrateChild(children, childNodes, counter, domNode, lifecycle, context, instance); - } else { - rebuild = true; - } + rebuild = true; } + } - if (rebuild) { - // TODO scrap children and rebuild again - } + if (rebuild) { + // TODO scrap children and rebuild again } } - var className = node.className; - var style = node.style; + } + var className = node.className; + var style = node.style; - if (!isNullOrUndefined(className)) { - domNode.className = className; - } - if (!isNullOrUndefined(style)) { - patchStyle(null, style, domNode); - } - if (bp && bp.hasAttrs === true) { - mountBlueprintAttrs(node, bp, domNode, instance); - } else { - var attrs = node.attrs; + if (!isNullOrUndefined(className)) { + domNode.className = className; + } + if (!isNullOrUndefined(style)) { + patchStyle(null, style, domNode); + } + if (bp && bp.hasAttrs === true) { + mountBlueprintAttrs(node, bp, domNode, instance); + } else { + var attrs = node.attrs; - if (!isNullOrUndefined(attrs)) { - handleSelects(node); - mountAttributes(node, attrs, Object.keys(attrs), domNode, instance); - } + if (!isNullOrUndefined(attrs)) { + handleSelects(node); + mountAttributes(node, attrs, Object.keys(attrs), domNode, instance); } - if (bp && bp.hasEvents === true) { - mountBlueprintEvents(node, bp, domNode); - } else { - var events = node.events; + } + if (bp && bp.hasEvents === true) { + mountBlueprintEvents(node, bp, domNode); + } else { + var events = node.events; - if (!isNullOrUndefined(events)) { - mountEvents(events, Object.keys(events), domNode); - } + if (!isNullOrUndefined(events)) { + mountEvents(events, Object.keys(events), domNode); } } } } - var documetBody = isBrowser ? document.body : null; +} +var documetBody = isBrowser ? document.body : null; - function hydrate(node, parentDom, lifecycle) { - if (parentDom && parentDom.nodeType === 1) { - var rootNode = parentDom.querySelector('[data-infernoroot]'); +function hydrate(node, parentDom, lifecycle) { + if (parentDom && parentDom.nodeType === 1) { + var rootNode = parentDom.querySelector('[data-infernoroot]'); - if (rootNode && rootNode.parentNode === parentDom) { - hydrateNode(node, rootNode, parentDom, lifecycle, {}, true); - return true; - } - } - // clear parentDom, unless it's document.body - if (parentDom !== documetBody) { - parentDom.textContent = ''; - } else { - console.warn('Inferno Warning: rendering to the "document.body" is dangerous! Use a dedicated container element instead.'); + if (rootNode && rootNode.parentNode === parentDom) { + hydrateNode(node, rootNode, parentDom, lifecycle, {}, true); + return true; } - return false; } + // clear parentDom, unless it's document.body + if (parentDom !== documetBody) { + parentDom.textContent = ''; + } else { + console.warn('Inferno Warning: rendering to the "document.body" is dangerous! Use a dedicated container element instead.'); + } + return false; +} - var roots = new Map(); - var componentToDOMNodeMap = new Map(); +var roots = new Map(); +var componentToDOMNodeMap = new Map(); - function findDOMNode(domNode) { - return componentToDOMNodeMap.get(domNode) || null; - } +function findDOMNode(domNode) { + return componentToDOMNodeMap.get(domNode) || null; +} - function render(input, parentDom) { - var root = roots.get(parentDom); - var lifecycle = new Lifecycle(); +function render(input, parentDom) { + var root = roots.get(parentDom); + var lifecycle = new Lifecycle(); - if (isUndefined(root)) { - if (!isInvalidNode(input)) { - if (!hydrate(input, parentDom, lifecycle)) { - mount(input, parentDom, lifecycle, {}, null, false); - } - lifecycle.trigger(); - roots.set(parentDom, { input: input }); + if (isUndefined(root)) { + if (!isInvalidNode(input)) { + if (!hydrate(input, parentDom, lifecycle)) { + mount(input, parentDom, lifecycle, {}, null, false); } - } else { - var activeNode = getActiveNode(); - var nextInput = patch(root.input, input, parentDom, lifecycle, {}, null, false); - lifecycle.trigger(); - if (isNull(input)) { - roots.delete(parentDom); - } - root.input = nextInput; - resetActiveNode(activeNode); + roots.set(parentDom, { input: input }); + } + } else { + var activeNode = getActiveNode(); + var nextInput = patch(root.input, input, parentDom, lifecycle, {}, null, false); + + lifecycle.trigger(); + if (isNull(input)) { + roots.delete(parentDom); } + root.input = nextInput; + resetActiveNode(activeNode); } +} - var index = { - render: render, - findDOMNode: findDOMNode, - mount: mount, - patch: patch, - unmount: unmount - }; +var index = { + render: render, + findDOMNode: findDOMNode, + mount: mount, + patch: patch, + unmount: unmount +}; - return index; +return index; -})); \ No newline at end of file +}))); \ No newline at end of file diff --git a/packages/inferno/dist/inferno-dom.min.js b/packages/inferno/dist/inferno-dom.min.js index 2f2c1a5cc..4b4b5d2ab 100644 --- a/packages/inferno/dist/inferno-dom.min.js +++ b/packages/inferno/dist/inferno-dom.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.InfernoDOM=t()}(this,function(){"use strict";function e(e,n){if(!o(e)){var r=t(e);(r&&e.length>0||!r)&&(n=n?Object.assign({},n,{children:e}):{children:e})}return n}function t(e){return e instanceof Array}function n(e){return e.prototype&&void 0!==e.prototype.render}function r(e){return a(e)||s(e)}function o(e){return d(e)||u(e)}function l(e){return u(e)||e===!1||e===!0||d(e)}function i(e){return"function"==typeof e}function a(e){return"string"==typeof e}function s(e){return"number"==typeof e}function u(e){return null===e}function c(e){return e===!0}function d(e){return void 0===e}function f(e,n){if(!l(e))if(t(e))for(var r=0;r0)for(var i=0;i5)for(var r=0;rs.screenHeight)&&setClipNode(C,k,e,t,a,s,u,c,r.isSVG))return;if(C.bottom0||b>0)if(5===b||5===x)pe(e,t,k,s,u,c);else{var N=e.children,_=t.children;0===x||l(N)?b>2?ie(_,k,s,u,c):J(_,k,s,u,c):0===b||l(_)?x>2?Y(k,N):H(N,k):N!==_&&(4===x&&4===b?Me(N,_,k,s,u,c,i.isSVG,null):2===x&&2===b?fe(N,_,k,s,u,c,!0,i.isSVG):1===x&&1===b?me(k,N,_):pe(e,t,k,s,u,c,i.isSVG))}if(r.hasAttrs!==!0&&i.hasAttrs!==!0||we(e,t,r.attrKeys,i.attrKeys,k,c),r.hasEvents!==!0&&i.hasEvents!==!0||xe(e.events,t.events,r.eventKeys,i.eventKeys,k),r.hasClassName===!0||i.hasClassName===!0){var S=t.className;e.className!==S&&(o(S)?k.removeAttribute("class"):k.className=S)}if(r.hasStyle===!0||i.hasStyle===!0){var O=t.style,M=e.style;M!==O&&ke(M,O,k)}i.hasHooks!==!0||o(f.didUpdate)||f.didUpdate(k),P(m,t)}}function ye(e,t,r,l,a,s,u){var c=t.hooks,d=!o(c);d&&!o(c.willUpdate)&&c.willUpdate(e.dom);var f=t.tag||(o(t.bp)?null:t.bp.tag),m=e.tag||(o(e.bp)?null:e.bp.tag);if("svg"===f&&(u=!0),m!==f){var v=e.instance;i(m)?i(f)?E(e,t,r,l,a,s,u):n(m)?(y(e,null,!0),ye(v._lastNode,t,r,l,a,s,u)):(y(e,null,!0),ye(v,t,r,l,a,s,u)):E(v||e,t,r,l,a,s,u)}else if(o(m))t.dom=e.dom;else if(i(m)){if(i(f)){var p=e._instance;if(!o(p)&&p._unmounted){var h=ce(t,m,t.attrs||{},t.hooks,t.children,p,r,l,a);null!==r&&G(r,h,e.dom)}else t.instance=e.instance,t.dom=e.dom,Ce(!1,t,t.tag,null,null,t.instance,e.attrs||{},t.attrs||{},t.hooks,e.children,t.children,r,l,a)}}else{var g=e.dom,w=t.className,k=t.style;t.dom=g,pe(e,t,g,l,a,s,u),we(e,t,null,null,g,s),xe(e.events,t.events,null,null,g),e.className!==w&&(o(w)?g.removeAttribute("class"):g.className=w),e.style!==k&&ke(e.style,k,g),d&&!o(c.didUpdate)&&c.didUpdate(g),P(f,t)}}function we(e,t,n,r,l,i){"select"===e.tag&&F(t);var a=t.attrs,s=e.attrs,u=o(a),c=!o(s);if(!u)for(var d=r||Object.keys(a),f=d.length,m=0;mu?u:s,d=0;du)for(d=c;dd){if(v<=f)for(s=f+1f)for(;m<=d;)H(e[m++],n);else{var w,k=d-m+1,x=f-v+1,b=new Array(x);for(w=0;wC?N=!0:S=C,he(y,g,n,r,o,l,i,!1),M++,O=!1;break}O&&(H(y,n),_++)}else{var D=new Map;for(w=v;w<=f;w++)D.set(t[w].key,w);for(w=m;w<=d;w++)O=!0,y=e[w],MC?N=!0:S=C,he(y,g,n,r,o,l,i,!1),M++,O=!1)),O&&(H(y,n),_++)}var j;if(N){var U=De(b);for(C=U.length-1,w=x-1;w>=0;w--)b[w]===-1?(j=w+v,s=j+1=0;w--)b[w]===-1&&(j=w+v,s=j+10&&(t[r]=n[l-1]),n[l]=r)}for(l=n.length,i=n[l-1];l-- >0;)n[l]=i,i=t[i];return n}function Te(){this._listeners=[],this.scrollX=null,this.scrollY=null,this.screenHeight=Pe,this.screenWidth=Be}function je(e,t,n){t.addListener(function(){var r=n.getBoundingClientRect();null===t.scrollY&&t.refresh(),e.clipData={top:r.top+t.scrollY,left:r.left+t.scrollX,bottom:r.bottom+t.scrollY,right:r.right+t.scrollX,pending:!1}})}function Ue(e,t,n,r,o,l,i){var a=t[n.i];if(S(e)){var s=e.text;if(e.dom=a,3===a.nodeType&&""!==s)a.nodeValue=s;else{var u=$(s);G(r,u,a),t.splice(t.indexOf(a),1,u),e.dom=u}}else if(O(e))e.dom=a;else if(M(e)){var c=e.items;e.dom=document.createDocumentFragment();for(var d=0;d0||!r)&&(n=n?Object.assign({},n,{children:e}):{children:e})}return n}function t(e){return e instanceof Array}function n(e){return e.prototype&&void 0!==e.prototype.render}function r(e){return a(e)||s(e)}function o(e){return d(e)||u(e)}function l(e){return u(e)||e===!1||e===!0||d(e)}function i(e){return"function"==typeof e}function a(e){return"string"==typeof e}function s(e){return"number"==typeof e}function u(e){return null===e}function c(e){return e===!0}function d(e){return void 0===e}function f(e,n){if(!l(e))if(t(e))for(var r=0;r0)for(var i=0;i5)for(var r=0;rs.screenHeight)&&setClipNode(C,k,e,t,a,s,u,c,r.isSVG))return;if(C.bottom0||b>0)if(5===b||5===x)pe(e,t,k,s,u,c);else{var N=e.children,_=t.children;0===x||l(N)?b>2?ie(_,k,s,u,c):J(_,k,s,u,c):0===b||l(_)?x>2?Y(k,N):H(N,k):N!==_&&(4===x&&4===b?Me(N,_,k,s,u,c,i.isSVG,null):2===x&&2===b?fe(N,_,k,s,u,c,!0,i.isSVG):1===x&&1===b?me(k,N,_):pe(e,t,k,s,u,c,i.isSVG))}if(r.hasAttrs!==!0&&i.hasAttrs!==!0||we(e,t,r.attrKeys,i.attrKeys,k,c),r.hasEvents!==!0&&i.hasEvents!==!0||xe(e.events,t.events,r.eventKeys,i.eventKeys,k),r.hasClassName===!0||i.hasClassName===!0){var S=t.className;e.className!==S&&(o(S)?k.removeAttribute("class"):k.className=S)}if(r.hasStyle===!0||i.hasStyle===!0){var O=t.style,M=e.style;M!==O&&ke(M,O,k)}i.hasHooks!==!0||o(f.didUpdate)||f.didUpdate(k),P(m,t)}}function ye(e,t,r,l,a,s,u){var c=t.hooks,d=!o(c);d&&!o(c.willUpdate)&&c.willUpdate(e.dom);var f=t.tag||(o(t.bp)?null:t.bp.tag),m=e.tag||(o(e.bp)?null:e.bp.tag);if("svg"===f&&(u=!0),m!==f){var v=e.instance;i(m)?i(f)?E(e,t,r,l,a,s,u):n(m)?(y(e,null,!0),ye(v._lastNode,t,r,l,a,s,u)):(y(e,null,!0),ye(v,t,r,l,a,s,u)):E(v||e,t,r,l,a,s,u)}else if(o(m))t.dom=e.dom;else if(i(m)){if(i(f)){var p=e._instance;if(!o(p)&&p._unmounted){var h=ce(t,m,t.attrs||{},t.hooks,t.children,p,r,l,a);null!==r&&G(r,h,e.dom)}else t.instance=e.instance,t.dom=e.dom,Ce(!1,t,t.tag,null,null,t.instance,e.attrs||{},t.attrs||{},t.hooks,e.children,t.children,r,l,a)}}else{var g=e.dom,w=t.className,k=t.style;t.dom=g,pe(e,t,g,l,a,s,u),we(e,t,null,null,g,s),xe(e.events,t.events,null,null,g),e.className!==w&&(o(w)?g.removeAttribute("class"):g.className=w),e.style!==k&&ke(e.style,k,g),d&&!o(c.didUpdate)&&c.didUpdate(g),P(f,t)}}function we(e,t,n,r,l,i){"select"===e.tag&&F(t);var a=t.attrs,s=e.attrs,u=o(a),c=!o(s);if(!u)for(var d=r||Object.keys(a),f=d.length,m=0;mu?u:s,d=0;du)for(d=c;dd){if(v<=f)for(s=f+1f)for(;m<=d;)H(e[m++],n);else{var w,k=d-m+1,x=f-v+1,b=new Array(x);for(w=0;wC?N=!0:S=C,he(y,g,n,r,o,l,i,!1),M++,O=!1;break}O&&(H(y,n),_++)}else{var D=new Map;for(w=v;w<=f;w++)D.set(t[w].key,w);for(w=m;w<=d;w++)O=!0,y=e[w],MC?N=!0:S=C,he(y,g,n,r,o,l,i,!1),M++,O=!1)),O&&(H(y,n),_++)}var j;if(N){var U=De(b);for(C=U.length-1,w=x-1;w>=0;w--)b[w]===-1?(j=w+v,s=j+1=0;w--)b[w]===-1&&(j=w+v,s=j+10&&(t[r]=n[l-1]),n[l]=r)}for(l=n.length,i=n[l-1];l-- >0;)n[l]=i,i=t[i];return n}function Te(){this._listeners=[],this.scrollX=null,this.scrollY=null,this.screenHeight=Pe,this.screenWidth=Be}function je(e,t,n){t.addListener(function(){var r=n.getBoundingClientRect();null===t.scrollY&&t.refresh(),e.clipData={top:r.top+t.scrollY,left:r.left+t.scrollX,bottom:r.bottom+t.scrollY,right:r.right+t.scrollX,pending:!1}})}function Ue(e,t,n,r,o,l,i){var a=t[n.i];if(S(e)){var s=e.text;if(e.dom=a,3===a.nodeType&&""!==s)a.nodeValue=s;else{var u=$(s);G(r,u,a),t.splice(t.indexOf(a),1,u),e.dom=u}}else if(O(e))e.dom=a;else if(M(e)){var c=e.items;e.dom=document.createDocumentFragment();for(var d=0;d, ' + - "or explicitly pass \"store\" as a prop to \"" + connectDisplayName + "\"." - ); - - var storeState = this.store.getState(); - this.state = { storeState: storeState }; - this.clearCache(); - } - - if ( Component ) Connect.__proto__ = Component; - Connect.prototype = Object.create( Component && Component.prototype ); - Connect.prototype.constructor = Connect; - Connect.prototype.shouldComponentUpdate = function shouldComponentUpdate () { - return !pure || this.haveOwnPropsChanged || this.hasStoreStateChanged; - }; - - Connect.prototype.computeStateProps = function computeStateProps (store, props) { - if (!this.finalMapStateToProps) { - return this.configureFinalMapState(store, props); - } - var state = store.getState(); - var stateProps = this.doStatePropsDependOnOwnProps ? - this.finalMapStateToProps(state, props) : - this.finalMapStateToProps(state); - - return stateProps; - }; - Connect.prototype.configureFinalMapState = function configureFinalMapState (store, props) { - var mappedState = mapState(store.getState(), props); - var isFactory = isFunction(mappedState); - - this.finalMapStateToProps = isFactory ? mappedState : mapState; - this.doStatePropsDependOnOwnProps = this.finalMapStateToProps.length !== 1; - if (isFactory) { - return this.computeStateProps(store, props); - } - return mappedState; - }; - Connect.prototype.computeDispatchProps = function computeDispatchProps (store, props) { - if (!this.finalMapDispatchToProps) { - return this.configureFinalMapDispatch(store, props); - } - var dispatch = store.dispatch; - var dispatchProps = this.doDispatchPropsDependOnOwnProps ? - this.finalMapDispatchToProps(dispatch, props) : - this.finalMapDispatchToProps(dispatch); - - return dispatchProps; - }; - Connect.prototype.configureFinalMapDispatch = function configureFinalMapDispatch (store, props) { - var mappedDispatch = mapDispatch(store.dispatch, props); - var isFactory = isFunction(mappedDispatch); - - this.finalMapDispatchToProps = isFactory ? mappedDispatch : mapDispatch; - this.doDispatchPropsDependOnOwnProps = this.finalMapDispatchToProps.length !== 1; - - if (isFactory) { - return this.computeDispatchProps(store, props); - } - return mappedDispatch; - }; - Connect.prototype.updateStatePropsIfNeeded = function updateStatePropsIfNeeded () { - var nextStateProps = this.computeStateProps(this.store, this.props); - - if (this.stateProps && shallowEqual(nextStateProps, this.stateProps)) { - return false; - } - this.stateProps = nextStateProps; - return true; - }; - Connect.prototype.updateDispatchPropsIfNeeded = function updateDispatchPropsIfNeeded () { - var nextDispatchProps = this.computeDispatchProps(this.store, this.props); - - if (this.dispatchProps && shallowEqual(nextDispatchProps, this.dispatchProps)) { - return false; - } - this.dispatchProps = nextDispatchProps; - return true; - }; - Connect.prototype.updateMergedPropsIfNeeded = function updateMergedPropsIfNeeded () { - var nextMergedProps = computeMergedProps(this.stateProps, this.dispatchProps, this.props); - - if (this.mergedProps && checkMergedEquals && shallowEqual(nextMergedProps, this.mergedProps)) { - return false; - } - this.mergedProps = nextMergedProps; - return true; - }; - Connect.prototype.isSubscribed = function isSubscribed () { - return isFunction(this.unsubscribe); - }; - Connect.prototype.trySubscribe = function trySubscribe () { - if (shouldSubscribe && !this.unsubscribe) { - this.unsubscribe = this.store.subscribe(this.handleChange.bind(this)); - this.handleChange(); - } - }; - Connect.prototype.tryUnsubscribe = function tryUnsubscribe () { - if (this.unsubscribe) { - this.unsubscribe(); - this.unsubscribe = null; - } - }; - Connect.prototype.componentDidMount = function componentDidMount () { - this.trySubscribe(); - }; - Connect.prototype.componentWillReceiveProps = function componentWillReceiveProps (nextProps) { - if (!pure || !shallowEqual(nextProps, this.props)) { - this.haveOwnPropsChanged = true; - } - }; - Connect.prototype.componentWillUnmount = function componentWillUnmount () { - this.tryUnsubscribe(); - this.clearCache(); - }; - Connect.prototype.clearCache = function clearCache () { - this.dispatchProps = null; - this.stateProps = null; - this.mergedProps = null; - this.haveOwnPropsChanged = true; - this.hasStoreStateChanged = true; - this.haveStatePropsBeenPrecalculated = false; - this.statePropsPrecalculationError = null; - this.renderedElement = null; - this.finalMapDispatchToProps = null; - this.finalMapStateToProps = null; - }; - Connect.prototype.handleChange = function handleChange () { - if (!this.unsubscribe) { - return; - } - var storeState = this.store.getState(); - var prevStoreState = this.state.storeState; - - if (pure && prevStoreState === storeState) { - return; - } - if (pure && !this.doStatePropsDependOnOwnProps) { - var haveStatePropsChanged = tryCatch(this.updateStatePropsIfNeeded, this); - if (!haveStatePropsChanged) { - return; - } - if (haveStatePropsChanged === errorObject) { - this.statePropsPrecalculationError = errorObject.value; - } - this.haveStatePropsBeenPrecalculated = true; - } - this.hasStoreStateChanged = true; - this.setState({ storeState: storeState }); - }; - Connect.prototype.getWrappedInstance = function getWrappedInstance () { - return this.refs.wrappedInstance; - }; - Connect.prototype.render = function render () { - var ref = this; - var haveOwnPropsChanged = ref.haveOwnPropsChanged; - var hasStoreStateChanged = ref.hasStoreStateChanged; - var haveStatePropsBeenPrecalculated = ref.haveStatePropsBeenPrecalculated; - var statePropsPrecalculationError = ref.statePropsPrecalculationError; - var renderedElement = ref.renderedElement; - - this.haveOwnPropsChanged = false; - this.hasStoreStateChanged = false; - this.haveStatePropsBeenPrecalculated = false; - this.statePropsPrecalculationError = null; - - if (statePropsPrecalculationError) { - throw statePropsPrecalculationError; - } - var shouldUpdateStateProps = true; - var shouldUpdateDispatchProps = true; - - if (pure && renderedElement) { - shouldUpdateStateProps = hasStoreStateChanged || ( - haveOwnPropsChanged && this.doStatePropsDependOnOwnProps - ); - shouldUpdateDispatchProps = - haveOwnPropsChanged && this.doDispatchPropsDependOnOwnProps; - } - var haveStatePropsChanged = false; - var haveDispatchPropsChanged = false; - - if (haveStatePropsBeenPrecalculated) { - haveStatePropsChanged = true; - } else if (shouldUpdateStateProps) { - haveStatePropsChanged = this.updateStatePropsIfNeeded(); - } - if (shouldUpdateDispatchProps) { - haveDispatchPropsChanged = this.updateDispatchPropsIfNeeded(); - } - var haveMergedPropsChanged = true; - - if ( - haveStatePropsChanged || - haveDispatchPropsChanged || - haveOwnPropsChanged - ) { - haveMergedPropsChanged = this.updateMergedPropsIfNeeded(); - } else { - haveMergedPropsChanged = false; - } - - if (!haveMergedPropsChanged && renderedElement) { - return renderedElement; - } - if (withRef) { - this.renderedElement = createVNode().setTag(WrappedComponent) - .setAttrs(Object.assign({}, this.mergedProps, { ref: 'wrappedInstance' })); - } else { - this.renderedElement = createVNode().setTag(WrappedComponent) - .setAttrs(this.mergedProps); - } - return this.renderedElement; - }; - - return Connect; - }(Component)); - Connect.displayName = connectDisplayName; - Connect.WrappedComponent = WrappedComponent; - - if ("production" !== 'production') {} - return hoistStatics(Connect, WrappedComponent); - }; + } + + if (!condition) { + var error; + if (format === undefined) { + error = new Error( + 'Minified exception occurred; use the non-minified dev environment ' + + 'for the full error message and additional helpful warnings.' + ); + } else { + var args = [a, b, c, d, e, f]; + var argIndex = 0; + error = new Error( + format.replace(/%s/g, function() { return args[argIndex++]; }) + ); + error.name = 'Invariant Violation'; } - var index = { - Provider: Provider, - connect: connect, - }; - - return index; - -})); \ No newline at end of file + error.framesToPop = 1; // we don't care about invariant's own frame + throw error; + } +}; + +module.exports = invariant; +}); + +var invariant$1 = interopDefault(invariant); + +var errorObject = { value: null }; +var defaultMapStateToProps = function (state) { return ({}); }; // eslint-disable-line no-unused-vars +var defaultMapDispatchToProps = function (dispatch) { return ({ dispatch: dispatch }); }; +var defaultMergeProps = function (stateProps, dispatchProps, parentProps) { return (Object.assign({}, parentProps, + stateProps, + dispatchProps)); }; + +function tryCatch(fn, ctx) { + try { + return fn.apply(ctx); + } catch (e) { + errorObject.value = e; + return errorObject; + } +} + +function getDisplayName(WrappedComponent) { + return WrappedComponent.displayName || WrappedComponent.name || 'Component'; +} + +// Helps track hot reloading. +var nextVersion = 0; + +function connect(mapStateToProps, mapDispatchToProps, mergeProps, options) { + if ( options === void 0 ) options = {}; + + var shouldSubscribe = Boolean(mapStateToProps); + var mapState = mapStateToProps || defaultMapStateToProps; + var mapDispatch; + + if (isFunction(mapDispatchToProps)) { + mapDispatch = mapDispatchToProps; + } else if (!mapDispatchToProps) { + mapDispatch = defaultMapDispatchToProps; + } else { + mapDispatch = wrapActionCreators(mapDispatchToProps); + } + var finalMergeProps = mergeProps || defaultMergeProps; + var pure = options.pure; if ( pure === void 0 ) pure = true; + var withRef = options.withRef; if ( withRef === void 0 ) withRef = false; + var checkMergedEquals = pure && finalMergeProps !== defaultMergeProps; + // Helps track hot reloading. + var version = nextVersion++; + + return function wrapWithConnect(WrappedComponent) { + var connectDisplayName = "Connect(" + (getDisplayName(WrappedComponent)) + ")"; + + function checkStateShape(props, methodName) { + if (!isPlainObject(props)) { + warning( + methodName + "() in " + connectDisplayName + " must return a plain object. " + + "Instead received " + props + "." + ); + } + } + function computeMergedProps(stateProps, dispatchProps, parentProps) { + var mergedProps = finalMergeProps(stateProps, dispatchProps, parentProps); + if ("production" !== 'production') {} + return mergedProps; + } + + var Connect = (function (Component) { + function Connect(props, context) { + Component.call(this, props, context); + + this.version = version; + this.store = (props && props.store) || (context && context.store); + + invariant$1(this.store, + 'Could not find "store" in either the context or ' + + "props of \"" + connectDisplayName + "\". " + + 'Either wrap the root component in a , ' + + "or explicitly pass \"store\" as a prop to \"" + connectDisplayName + "\"." + ); + + var storeState = this.store.getState(); + this.state = { storeState: storeState }; + this.clearCache(); + } + + if ( Component ) Connect.__proto__ = Component; + Connect.prototype = Object.create( Component && Component.prototype ); + Connect.prototype.constructor = Connect; + Connect.prototype.shouldComponentUpdate = function shouldComponentUpdate () { + return !pure || this.haveOwnPropsChanged || this.hasStoreStateChanged; + }; + + Connect.prototype.computeStateProps = function computeStateProps (store, props) { + if (!this.finalMapStateToProps) { + return this.configureFinalMapState(store, props); + } + var state = store.getState(); + var stateProps = this.doStatePropsDependOnOwnProps ? + this.finalMapStateToProps(state, props) : + this.finalMapStateToProps(state); + + return stateProps; + }; + Connect.prototype.configureFinalMapState = function configureFinalMapState (store, props) { + var mappedState = mapState(store.getState(), props); + var isFactory = isFunction(mappedState); + + this.finalMapStateToProps = isFactory ? mappedState : mapState; + this.doStatePropsDependOnOwnProps = this.finalMapStateToProps.length !== 1; + if (isFactory) { + return this.computeStateProps(store, props); + } + return mappedState; + }; + Connect.prototype.computeDispatchProps = function computeDispatchProps (store, props) { + if (!this.finalMapDispatchToProps) { + return this.configureFinalMapDispatch(store, props); + } + var dispatch = store.dispatch; + var dispatchProps = this.doDispatchPropsDependOnOwnProps ? + this.finalMapDispatchToProps(dispatch, props) : + this.finalMapDispatchToProps(dispatch); + + return dispatchProps; + }; + Connect.prototype.configureFinalMapDispatch = function configureFinalMapDispatch (store, props) { + var mappedDispatch = mapDispatch(store.dispatch, props); + var isFactory = isFunction(mappedDispatch); + + this.finalMapDispatchToProps = isFactory ? mappedDispatch : mapDispatch; + this.doDispatchPropsDependOnOwnProps = this.finalMapDispatchToProps.length !== 1; + + if (isFactory) { + return this.computeDispatchProps(store, props); + } + return mappedDispatch; + }; + Connect.prototype.updateStatePropsIfNeeded = function updateStatePropsIfNeeded () { + var nextStateProps = this.computeStateProps(this.store, this.props); + + if (this.stateProps && shallowEqual(nextStateProps, this.stateProps)) { + return false; + } + this.stateProps = nextStateProps; + return true; + }; + Connect.prototype.updateDispatchPropsIfNeeded = function updateDispatchPropsIfNeeded () { + var nextDispatchProps = this.computeDispatchProps(this.store, this.props); + + if (this.dispatchProps && shallowEqual(nextDispatchProps, this.dispatchProps)) { + return false; + } + this.dispatchProps = nextDispatchProps; + return true; + }; + Connect.prototype.updateMergedPropsIfNeeded = function updateMergedPropsIfNeeded () { + var nextMergedProps = computeMergedProps(this.stateProps, this.dispatchProps, this.props); + + if (this.mergedProps && checkMergedEquals && shallowEqual(nextMergedProps, this.mergedProps)) { + return false; + } + this.mergedProps = nextMergedProps; + return true; + }; + Connect.prototype.isSubscribed = function isSubscribed () { + return isFunction(this.unsubscribe); + }; + Connect.prototype.trySubscribe = function trySubscribe () { + if (shouldSubscribe && !this.unsubscribe) { + this.unsubscribe = this.store.subscribe(this.handleChange.bind(this)); + this.handleChange(); + } + }; + Connect.prototype.tryUnsubscribe = function tryUnsubscribe () { + if (this.unsubscribe) { + this.unsubscribe(); + this.unsubscribe = null; + } + }; + Connect.prototype.componentDidMount = function componentDidMount () { + this.trySubscribe(); + }; + Connect.prototype.componentWillReceiveProps = function componentWillReceiveProps (nextProps) { + if (!pure || !shallowEqual(nextProps, this.props)) { + this.haveOwnPropsChanged = true; + } + }; + Connect.prototype.componentWillUnmount = function componentWillUnmount () { + this.tryUnsubscribe(); + this.clearCache(); + }; + Connect.prototype.clearCache = function clearCache () { + this.dispatchProps = null; + this.stateProps = null; + this.mergedProps = null; + this.haveOwnPropsChanged = true; + this.hasStoreStateChanged = true; + this.haveStatePropsBeenPrecalculated = false; + this.statePropsPrecalculationError = null; + this.renderedElement = null; + this.finalMapDispatchToProps = null; + this.finalMapStateToProps = null; + }; + Connect.prototype.handleChange = function handleChange () { + if (!this.unsubscribe) { + return; + } + var storeState = this.store.getState(); + var prevStoreState = this.state.storeState; + + if (pure && prevStoreState === storeState) { + return; + } + if (pure && !this.doStatePropsDependOnOwnProps) { + var haveStatePropsChanged = tryCatch(this.updateStatePropsIfNeeded, this); + if (!haveStatePropsChanged) { + return; + } + if (haveStatePropsChanged === errorObject) { + this.statePropsPrecalculationError = errorObject.value; + } + this.haveStatePropsBeenPrecalculated = true; + } + this.hasStoreStateChanged = true; + this.setState({ storeState: storeState }); + }; + Connect.prototype.getWrappedInstance = function getWrappedInstance () { + return this.refs.wrappedInstance; + }; + Connect.prototype.render = function render () { + var ref = this; + var haveOwnPropsChanged = ref.haveOwnPropsChanged; + var hasStoreStateChanged = ref.hasStoreStateChanged; + var haveStatePropsBeenPrecalculated = ref.haveStatePropsBeenPrecalculated; + var statePropsPrecalculationError = ref.statePropsPrecalculationError; + var renderedElement = ref.renderedElement; + + this.haveOwnPropsChanged = false; + this.hasStoreStateChanged = false; + this.haveStatePropsBeenPrecalculated = false; + this.statePropsPrecalculationError = null; + + if (statePropsPrecalculationError) { + throw statePropsPrecalculationError; + } + var shouldUpdateStateProps = true; + var shouldUpdateDispatchProps = true; + + if (pure && renderedElement) { + shouldUpdateStateProps = hasStoreStateChanged || ( + haveOwnPropsChanged && this.doStatePropsDependOnOwnProps + ); + shouldUpdateDispatchProps = + haveOwnPropsChanged && this.doDispatchPropsDependOnOwnProps; + } + var haveStatePropsChanged = false; + var haveDispatchPropsChanged = false; + + if (haveStatePropsBeenPrecalculated) { + haveStatePropsChanged = true; + } else if (shouldUpdateStateProps) { + haveStatePropsChanged = this.updateStatePropsIfNeeded(); + } + if (shouldUpdateDispatchProps) { + haveDispatchPropsChanged = this.updateDispatchPropsIfNeeded(); + } + var haveMergedPropsChanged = true; + + if ( + haveStatePropsChanged || + haveDispatchPropsChanged || + haveOwnPropsChanged + ) { + haveMergedPropsChanged = this.updateMergedPropsIfNeeded(); + } else { + haveMergedPropsChanged = false; + } + + if (!haveMergedPropsChanged && renderedElement) { + return renderedElement; + } + if (withRef) { + this.renderedElement = createVNode().setTag(WrappedComponent) + .setAttrs(Object.assign({}, this.mergedProps, { ref: 'wrappedInstance' })); + } else { + this.renderedElement = createVNode().setTag(WrappedComponent) + .setAttrs(this.mergedProps); + } + return this.renderedElement; + }; + + return Connect; + }(Component)); + Connect.displayName = connectDisplayName; + Connect.WrappedComponent = WrappedComponent; + + if ("production" !== 'production') {} + return hoistStatics(Connect, WrappedComponent); + }; +} + +var index = { + Provider: Provider, + connect: connect, +}; + +return index; + +}))); \ No newline at end of file diff --git a/packages/inferno/dist/inferno-redux.min.js b/packages/inferno/dist/inferno-redux.min.js index b8da73f95..2ad1c1b52 100644 --- a/packages/inferno/dist/inferno-redux.min.js +++ b/packages/inferno/dist/inferno-redux.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.InfernoRedux=e()}(this,function(){"use strict";function t(t){return e(t)?t:t?[t]:t}function e(t){return t instanceof Array}function n(t){return i(t)||r(t)}function o(t){return"function"==typeof t}function r(t){return null===t}function i(t){return void 0===t}function s(t){this.bp=t,this.dom=null,this.instance=null,this.tag=null,this.children=null,this.style=null,this.className=null,this.attrs=null,this.events=null,this.hooks=null,this.key=null,this.clipData=null}function a(t){return new s(t)}function p(){this.placeholder=!0,this.dom=null}function u(){return new p}function c(t,e,n){t.split(",").forEach(function(t){return e[t]=n})}function l(){this._listeners=[],this.scrollX=null,this.scrollY=null,this.screenHeight=I,this.screenWidth=j}function h(){return document.activeElement}function d(t){t!==document.body&&document.activeElement!==t&&t.focus()}function f(t,e,n){for(var o in e)t._pendingState[o]=e[o];t._pendingSetState?(t.state=Object.assign({},t.state,t._pendingState),t._pendingState={}):(t._pendingSetState=!0,m(t,!1,n))}function m(t,e,o){if((!t._deferSetState||e)&&!t._blockRender){t._pendingSetState=!1;var r=t._pendingState,i=t.state,s=Object.assign({},i,r),a=t.props;t._pendingState={};var p=t._updateComponent(i,s,a,a,e);p===x?p=t._lastNode:n(p)&&(p=u());var c=t._lastNode,f=c.dom.parentNode,m=h(),y=new l;t._patch(c,p,f,y,t.context,t,null),t._lastNode=p,t._componentToDOMNodeMap.set(t,p.dom),t._parentNode.dom=p.dom,t.componentDidUpdate(a,i),y.trigger(),n(o)||o(),d(m)}}function y(t){return t&&"object"==typeof t&&"default"in t?t.default:t}function g(t,e){return e={exports:{}},t(e,e.exports),e.exports}function v(t,e){return function(){return e(t.apply(void 0,arguments))}}function w(t,e){if("function"==typeof t)return v(t,e);if("object"!=typeof t||null===t)throw new Error("bindActionCreators expected an object or a function, instead received "+(null===t?"null":typeof t)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');for(var n=Object.keys(t),o={},r=0;r, or explicitly pass "store" as a prop to "'+n+'".');var o=this.store.getState();this.state={storeState:o},this.clearCache()}return r&&(u.__proto__=r),u.prototype=Object.create(r&&r.prototype),u.prototype.constructor=u,u.prototype.shouldComponentUpdate=function(){return!c||this.haveOwnPropsChanged||this.hasStoreStateChanged},u.prototype.computeStateProps=function(t,e){if(!this.finalMapStateToProps)return this.configureFinalMapState(t,e);var n=t.getState(),o=this.doStatePropsDependOnOwnProps?this.finalMapStateToProps(n,e):this.finalMapStateToProps(n);return o},u.prototype.configureFinalMapState=function(t,e){var n=p(t.getState(),e),r=o(n);return this.finalMapStateToProps=r?n:p,this.doStatePropsDependOnOwnProps=1!==this.finalMapStateToProps.length,r?this.computeStateProps(t,e):n},u.prototype.computeDispatchProps=function(t,e){if(!this.finalMapDispatchToProps)return this.configureFinalMapDispatch(t,e);var n=t.dispatch,o=this.doDispatchPropsDependOnOwnProps?this.finalMapDispatchToProps(n,e):this.finalMapDispatchToProps(n);return o},u.prototype.configureFinalMapDispatch=function(t,e){var n=i(t.dispatch,e),r=o(n);return this.finalMapDispatchToProps=r?n:i,this.doDispatchPropsDependOnOwnProps=1!==this.finalMapDispatchToProps.length,r?this.computeDispatchProps(t,e):n},u.prototype.updateStatePropsIfNeeded=function(){var t=this.computeStateProps(this.store,this.props);return(!this.stateProps||!P(t,this.stateProps))&&(this.stateProps=t,!0)},u.prototype.updateDispatchPropsIfNeeded=function(){var t=this.computeDispatchProps(this.store,this.props);return(!this.dispatchProps||!P(t,this.dispatchProps))&&(this.dispatchProps=t,!0)},u.prototype.updateMergedPropsIfNeeded=function(){var t=e(this.stateProps,this.dispatchProps,this.props);return!(this.mergedProps&&h&&P(t,this.mergedProps))&&(this.mergedProps=t,!0)},u.prototype.isSubscribed=function(){return o(this.unsubscribe)},u.prototype.trySubscribe=function(){s&&!this.unsubscribe&&(this.unsubscribe=this.store.subscribe(this.handleChange.bind(this)),this.handleChange())},u.prototype.tryUnsubscribe=function(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)},u.prototype.componentDidMount=function(){this.trySubscribe()},u.prototype.componentWillReceiveProps=function(t){c&&P(t,this.props)||(this.haveOwnPropsChanged=!0)},u.prototype.componentWillUnmount=function(){this.tryUnsubscribe(),this.clearCache()},u.prototype.clearCache=function(){this.dispatchProps=null,this.stateProps=null,this.mergedProps=null,this.haveOwnPropsChanged=!0,this.hasStoreStateChanged=!0,this.haveStatePropsBeenPrecalculated=!1,this.statePropsPrecalculationError=null,this.renderedElement=null,this.finalMapDispatchToProps=null,this.finalMapStateToProps=null},u.prototype.handleChange=function(){if(this.unsubscribe){var t=this.store.getState(),e=this.state.storeState;if(!c||e!==t){if(c&&!this.doStatePropsDependOnOwnProps){var n=b(this.updateStatePropsIfNeeded,this);if(!n)return;n===Q&&(this.statePropsPrecalculationError=Q.value),this.haveStatePropsBeenPrecalculated=!0}this.hasStoreStateChanged=!0,this.setState({storeState:t})}}},u.prototype.getWrappedInstance=function(){return this.refs.wrappedInstance},u.prototype.render=function(){var e=this,n=e.haveOwnPropsChanged,o=e.hasStoreStateChanged,r=e.haveStatePropsBeenPrecalculated,i=e.statePropsPrecalculationError,s=e.renderedElement;if(this.haveOwnPropsChanged=!1,this.hasStoreStateChanged=!1,this.haveStatePropsBeenPrecalculated=!1,this.statePropsPrecalculationError=null,i)throw i;var p=!0,u=!0;c&&s&&(p=o||n&&this.doStatePropsDependOnOwnProps,u=n&&this.doDispatchPropsDependOnOwnProps);var h=!1,d=!1;r?h=!0:p&&(h=this.updateStatePropsIfNeeded()),u&&(d=this.updateDispatchPropsIfNeeded());var f=!0;return f=!!(h||d||n)&&this.updateMergedPropsIfNeeded(),!f&&s?s:(l?this.renderedElement=a().setTag(t).setAttrs(Object.assign({},this.mergedProps,{ref:"wrappedInstance"})):this.renderedElement=a().setTag(t).setAttrs(this.mergedProps),this.renderedElement)},u}(F);return r.displayName=n,r.WrappedComponent=t,K(r,t)}}var x="NO_RENDER",C="undefined"!=typeof window&&window.document;s.prototype={setAttrs:function(t){return this.attrs=t,this},setTag:function(t){return this.tag=t,this},setStyle:function(t){return this.style=t,this},setClassName:function(t){return this.className=t,this},setChildren:function(t){return this.children=t,this},setHooks:function(t){return this.hooks=t,this},setEvents:function(t){return this.events=t,this},setKey:function(t){return this.key=t,this}};var D=(C?document.body:null,"http://www.w3.org/1999/xlink"),k="http://www.w3.org/XML/1998/namespace",M={},E={},N={},T={};c("xlink:href,xlink:arcrole,xlink:actuate,xlink:role,xlink:titlef,xlink:type",N,D),c("xml:base,xml:lang,xml:space",N,k),c("volume,value",M,!0),c("muted,scoped,loop,open,checked,default,capture,disabled,selected,readonly,multiple,required,autoplay,controls,seamless,reversed,allowfullscreen,novalidate",E,!0),c("animationIterationCount,borderImageOutset,borderImageSlice,borderImageWidth,boxFlex,boxFlexGroup,boxOrdinalGroup,columnCount,flex,flexGrow,flexPositive,flexShrink,flexNegative,flexOrder,gridRow,gridColumn,fontWeight,lineClamp,lineHeight,opacity,order,orphans,tabSize,widows,zIndex,zoom,fillOpacity,floodOpacity,stopOpacity,strokeDasharray,strokeDashoffset,strokeMiterlimit,strokeOpacity,strokeWidth,",T,!0);var j=C&&window.screen.width,I=C&&window.screen.height,W=0,U=0,R=0;C&&(window.onscroll=function(){W=window.scrollX,U=window.scrollY,R=performance.now()},window.resize=function(){W=window.scrollX,U=window.scrollY,j=window.screen.width,I=window.screen.height,R=performance.now()}),l.prototype={refresh:function(){this.scrollX=C&&window.scrollX,this.scrollY=C&&window.scrollY},addListener:function(t){this._listeners.push(t)},trigger:function(){for(var t=this,e=0;e, or explicitly pass "store" as a prop to "'+n+'".');var o=this.store.getState();this.state={storeState:o},this.clearCache()}return r&&(u.__proto__=r),u.prototype=Object.create(r&&r.prototype),u.prototype.constructor=u,u.prototype.shouldComponentUpdate=function(){return!c||this.haveOwnPropsChanged||this.hasStoreStateChanged},u.prototype.computeStateProps=function(t,e){if(!this.finalMapStateToProps)return this.configureFinalMapState(t,e);var n=t.getState(),o=this.doStatePropsDependOnOwnProps?this.finalMapStateToProps(n,e):this.finalMapStateToProps(n);return o},u.prototype.configureFinalMapState=function(t,e){var n=p(t.getState(),e),r=o(n);return this.finalMapStateToProps=r?n:p,this.doStatePropsDependOnOwnProps=1!==this.finalMapStateToProps.length,r?this.computeStateProps(t,e):n},u.prototype.computeDispatchProps=function(t,e){if(!this.finalMapDispatchToProps)return this.configureFinalMapDispatch(t,e);var n=t.dispatch,o=this.doDispatchPropsDependOnOwnProps?this.finalMapDispatchToProps(n,e):this.finalMapDispatchToProps(n);return o},u.prototype.configureFinalMapDispatch=function(t,e){var n=i(t.dispatch,e),r=o(n);return this.finalMapDispatchToProps=r?n:i,this.doDispatchPropsDependOnOwnProps=1!==this.finalMapDispatchToProps.length,r?this.computeDispatchProps(t,e):n},u.prototype.updateStatePropsIfNeeded=function(){var t=this.computeStateProps(this.store,this.props);return(!this.stateProps||!P(t,this.stateProps))&&(this.stateProps=t,!0)},u.prototype.updateDispatchPropsIfNeeded=function(){var t=this.computeDispatchProps(this.store,this.props);return(!this.dispatchProps||!P(t,this.dispatchProps))&&(this.dispatchProps=t,!0)},u.prototype.updateMergedPropsIfNeeded=function(){var t=e(this.stateProps,this.dispatchProps,this.props);return!(this.mergedProps&&h&&P(t,this.mergedProps))&&(this.mergedProps=t,!0)},u.prototype.isSubscribed=function(){return o(this.unsubscribe)},u.prototype.trySubscribe=function(){s&&!this.unsubscribe&&(this.unsubscribe=this.store.subscribe(this.handleChange.bind(this)),this.handleChange())},u.prototype.tryUnsubscribe=function(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)},u.prototype.componentDidMount=function(){this.trySubscribe()},u.prototype.componentWillReceiveProps=function(t){c&&P(t,this.props)||(this.haveOwnPropsChanged=!0)},u.prototype.componentWillUnmount=function(){this.tryUnsubscribe(),this.clearCache()},u.prototype.clearCache=function(){this.dispatchProps=null,this.stateProps=null,this.mergedProps=null,this.haveOwnPropsChanged=!0,this.hasStoreStateChanged=!0,this.haveStatePropsBeenPrecalculated=!1,this.statePropsPrecalculationError=null,this.renderedElement=null,this.finalMapDispatchToProps=null,this.finalMapStateToProps=null},u.prototype.handleChange=function(){if(this.unsubscribe){var t=this.store.getState(),e=this.state.storeState;if(!c||e!==t){if(c&&!this.doStatePropsDependOnOwnProps){var n=b(this.updateStatePropsIfNeeded,this);if(!n)return;n===Z&&(this.statePropsPrecalculationError=Z.value),this.haveStatePropsBeenPrecalculated=!0}this.hasStoreStateChanged=!0,this.setState({storeState:t})}}},u.prototype.getWrappedInstance=function(){return this.refs.wrappedInstance},u.prototype.render=function(){var e=this,n=e.haveOwnPropsChanged,o=e.hasStoreStateChanged,r=e.haveStatePropsBeenPrecalculated,i=e.statePropsPrecalculationError,s=e.renderedElement;if(this.haveOwnPropsChanged=!1,this.hasStoreStateChanged=!1,this.haveStatePropsBeenPrecalculated=!1,this.statePropsPrecalculationError=null,i)throw i;var p=!0,u=!0;c&&s&&(p=o||n&&this.doStatePropsDependOnOwnProps,u=n&&this.doDispatchPropsDependOnOwnProps);var h=!1,d=!1;r?h=!0:p&&(h=this.updateStatePropsIfNeeded()),u&&(d=this.updateDispatchPropsIfNeeded());var f=!0;return f=!!(h||d||n)&&this.updateMergedPropsIfNeeded(),!f&&s?s:(l?this.renderedElement=a().setTag(t).setAttrs(Object.assign({},this.mergedProps,{ref:"wrappedInstance"})):this.renderedElement=a().setTag(t).setAttrs(this.mergedProps),this.renderedElement)},u}(F);return r.displayName=n,r.WrappedComponent=t,V(r,t)}}var x="NO_RENDER",C="undefined"!=typeof window&&window.document;s.prototype={setAttrs:function(t){return this.attrs=t,this},setTag:function(t){return this.tag=t,this},setStyle:function(t){return this.style=t,this},setClassName:function(t){return this.className=t,this},setChildren:function(t){return this.children=t,this},setHooks:function(t){return this.hooks=t,this},setEvents:function(t){return this.events=t,this},setKey:function(t){return this.key=t,this}};var D=(C?document.body:null,"http://www.w3.org/1999/xlink"),k="http://www.w3.org/XML/1998/namespace",M={},E={},N={},T={};c("xlink:href,xlink:arcrole,xlink:actuate,xlink:role,xlink:titlef,xlink:type",N,D),c("xml:base,xml:lang,xml:space",N,k),c("volume,value",M,!0),c("muted,scoped,loop,open,checked,default,capture,disabled,selected,readonly,multiple,required,autoplay,controls,seamless,reversed,allowfullscreen,novalidate",E,!0),c("animationIterationCount,borderImageOutset,borderImageSlice,borderImageWidth,boxFlex,boxFlexGroup,boxOrdinalGroup,columnCount,flex,flexGrow,flexPositive,flexShrink,flexNegative,flexOrder,gridRow,gridColumn,fontWeight,lineClamp,lineHeight,opacity,order,orphans,tabSize,widows,zIndex,zoom,fillOpacity,floodOpacity,stopOpacity,strokeDasharray,strokeDashoffset,strokeMiterlimit,strokeOpacity,strokeWidth,",T,!0);var j=C&&window.screen.width,I=C&&window.screen.height,W=0,U=0,R=0;C&&(window.onscroll=function(){W=window.scrollX,U=window.scrollY,R=performance.now()},window.resize=function(){W=window.scrollX,U=window.scrollY,j=window.screen.width,I=window.screen.height,R=performance.now()}),l.prototype={refresh:function(){this.scrollX=C&&window.scrollX,this.scrollY=C&&window.scrollY},addListener:function(t){this._listeners.push(t)},trigger:function(){for(var t=this,e=0;e 0 || !isChildrenArray) { - if (props) { - props = Object.assign({}, props, { children: children }); - } else { - props = { - children: children - }; - } +}(this, (function (stream) { 'use strict'; + +function addChildrenToProps(children, props) { + if (!isNullOrUndefined(children)) { + var isChildrenArray = isArray(children); + if (isChildrenArray && children.length > 0 || !isChildrenArray) { + if (props) { + props = Object.assign({}, props, { children: children }); + } else { + props = { + children: children + }; } } - return props; - } - - // Runs only once in applications lifetime - var isBrowser = typeof window !== 'undefined' && window.document; - - function isArray(obj) { - return obj instanceof Array; - } - - function isStatefulComponent(obj) { - return obj.prototype && obj.prototype.render !== undefined; - } - - function isStringOrNumber(obj) { - return isString(obj) || isNumber(obj); - } - - function isNullOrUndefined(obj) { - return isUndefined(obj) || isNull(obj); - } - - function isInvalidNode(obj) { - return isNull(obj) || obj === false || obj === true || isUndefined(obj); - } - - function isFunction(obj) { - return typeof obj === 'function'; - } - - function isString(obj) { - return typeof obj === 'string'; - } - - function isNumber(obj) { - return typeof obj === 'number'; - } - - function isNull(obj) { - return obj === null; - } - - function isTrue$1(obj) { - return obj === true; - } - - function isUndefined(obj) { - return obj === undefined; - } - - var screenWidth = isBrowser && window.screen.width; - var screenHeight = isBrowser && window.screen.height; - var scrollX = 0; - var scrollY = 0; - var lastScrollTime = 0; - - if (isBrowser) { - window.onscroll = function () { - scrollX = window.scrollX; - scrollY = window.scrollY; - lastScrollTime = performance.now(); - }; - - window.resize = function () { - scrollX = window.scrollX; - scrollY = window.scrollY; - screenWidth = window.screen.width; - screenHeight = window.screen.height; - lastScrollTime = performance.now(); - }; - } - - var documetBody = isBrowser ? document.body : null; - - function constructDefaults(string, object, value) { - /* eslint no-return-assign: 0 */ - string.split(',').forEach(function (i) { return object[i] = value; }); - } - - var xlinkNS = 'http://www.w3.org/1999/xlink'; - var xmlNS = 'http://www.w3.org/XML/1998/namespace'; - var strictProps = {}; - var booleanProps = {}; - var namespaces = {}; - var isUnitlessNumber = {}; - - constructDefaults('xlink:href,xlink:arcrole,xlink:actuate,xlink:role,xlink:titlef,xlink:type', namespaces, xlinkNS); - constructDefaults('xml:base,xml:lang,xml:space', namespaces, xmlNS); - constructDefaults('volume,value', strictProps, true); - constructDefaults('muted,scoped,loop,open,checked,default,capture,disabled,selected,readonly,multiple,required,autoplay,controls,seamless,reversed,allowfullscreen,novalidate', booleanProps, true); - constructDefaults('animationIterationCount,borderImageOutset,borderImageSlice,borderImageWidth,boxFlex,boxFlexGroup,boxOrdinalGroup,columnCount,flex,flexGrow,flexPositive,flexShrink,flexNegative,flexOrder,gridRow,gridColumn,fontWeight,lineClamp,lineHeight,opacity,order,orphans,tabSize,widows,zIndex,zoom,fillOpacity,floodOpacity,stopOpacity,strokeDasharray,strokeDashoffset,strokeMiterlimit,strokeOpacity,strokeWidth,', isUnitlessNumber, true); - - function escapeText(str) { - return (str + '') - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, ''') - .replace(/\//g, '/'); - } - - function escapeAttr(str) { - return (str + '') - .replace(/&/g, '&') - .replace(/"/g, '"'); } - - function toHyphenCase(str) { - return str.replace(/([a-zA-Z])(?=[A-Z])/g, '$1-').toLowerCase(); - } - - var voidElements = { - area: true, - base: true, - br: true, - col: true, - command: true, - embed: true, - hr: true, - img: true, - input: true, - keygen: true, - link: true, - meta: true, - param: true, - source: true, - track: true, - wbr: true + return props; +} + +// Runs only once in applications lifetime +var isBrowser = typeof window !== 'undefined' && window.document; + +function isArray(obj) { + return obj instanceof Array; +} + +function isStatefulComponent(obj) { + return obj.prototype && obj.prototype.render !== undefined; +} + +function isStringOrNumber(obj) { + return isString(obj) || isNumber(obj); +} + +function isNullOrUndefined(obj) { + return isUndefined(obj) || isNull(obj); +} + +function isInvalidNode(obj) { + return isNull(obj) || obj === false || obj === true || isUndefined(obj); +} + +function isFunction(obj) { + return typeof obj === 'function'; +} + +function isString(obj) { + return typeof obj === 'string'; +} + +function isNumber(obj) { + return typeof obj === 'number'; +} + +function isNull(obj) { + return obj === null; +} + +function isTrue$1(obj) { + return obj === true; +} + +function isUndefined(obj) { + return obj === undefined; +} + +var screenWidth = isBrowser && window.screen.width; +var screenHeight = isBrowser && window.screen.height; +var scrollX = 0; +var scrollY = 0; +var lastScrollTime = 0; + +if (isBrowser) { + window.onscroll = function () { + scrollX = window.scrollX; + scrollY = window.scrollY; + lastScrollTime = performance.now(); }; - function isVoidElement(str) { - return !!voidElements[str]; - } - - function renderComponent(Component, props, children, context, isRoot) { - props = addChildrenToProps(children, props); - - if (isStatefulComponent(Component)) { - var instance = new Component(props, context); - var childContext = instance.getChildContext(); - - if (!isNullOrUndefined(childContext)) { - context = Object.assign({}, context, childContext); - } - instance.context = context; - // Block setting state - we should render only once, using latest state - instance._pendingSetState = true; - instance.componentWillMount(); - var node = instance.render(); - - instance._pendingSetState = false; - return renderNode(node, context, isRoot); - } else { - return renderNode(Component(props, context), context, isRoot); + window.resize = function () { + scrollX = window.scrollX; + scrollY = window.scrollY; + screenWidth = window.screen.width; + screenHeight = window.screen.height; + lastScrollTime = performance.now(); + }; +} + +var documetBody = isBrowser ? document.body : null; + +function constructDefaults(string, object, value) { + /* eslint no-return-assign: 0 */ + string.split(',').forEach(function (i) { return object[i] = value; }); +} + +var xlinkNS = 'http://www.w3.org/1999/xlink'; +var xmlNS = 'http://www.w3.org/XML/1998/namespace'; +var strictProps = {}; +var booleanProps = {}; +var namespaces = {}; +var isUnitlessNumber = {}; + +constructDefaults('xlink:href,xlink:arcrole,xlink:actuate,xlink:role,xlink:titlef,xlink:type', namespaces, xlinkNS); +constructDefaults('xml:base,xml:lang,xml:space', namespaces, xmlNS); +constructDefaults('volume,value', strictProps, true); +constructDefaults('muted,scoped,loop,open,checked,default,capture,disabled,selected,readonly,multiple,required,autoplay,controls,seamless,reversed,allowfullscreen,novalidate', booleanProps, true); +constructDefaults('animationIterationCount,borderImageOutset,borderImageSlice,borderImageWidth,boxFlex,boxFlexGroup,boxOrdinalGroup,columnCount,flex,flexGrow,flexPositive,flexShrink,flexNegative,flexOrder,gridRow,gridColumn,fontWeight,lineClamp,lineHeight,opacity,order,orphans,tabSize,widows,zIndex,zoom,fillOpacity,floodOpacity,stopOpacity,strokeDasharray,strokeDashoffset,strokeMiterlimit,strokeOpacity,strokeWidth,', isUnitlessNumber, true); + +function escapeText(str) { + return (str + '') + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(/\//g, '/'); +} + +function escapeAttr(str) { + return (str + '') + .replace(/&/g, '&') + .replace(/"/g, '"'); +} + +function toHyphenCase(str) { + return str.replace(/([a-zA-Z])(?=[A-Z])/g, '$1-').toLowerCase(); +} + +var voidElements = { + area: true, + base: true, + br: true, + col: true, + command: true, + embed: true, + hr: true, + img: true, + input: true, + keygen: true, + link: true, + meta: true, + param: true, + source: true, + track: true, + wbr: true +}; + +function isVoidElement(str) { + return !!voidElements[str]; +} + +function renderComponent(Component, props, children, context, isRoot) { + props = addChildrenToProps(children, props); + + if (isStatefulComponent(Component)) { + var instance = new Component(props, context); + var childContext = instance.getChildContext(); + + if (!isNullOrUndefined(childContext)) { + context = Object.assign({}, context, childContext); } + instance.context = context; + // Block setting state - we should render only once, using latest state + instance._pendingSetState = true; + instance.componentWillMount(); + var node = instance.render(); + + instance._pendingSetState = false; + return renderNode(node, context, isRoot); + } else { + return renderNode(Component(props, context), context, isRoot); } - - function renderChildren(children, context) { - if (children && isArray(children)) { - var childrenResult = []; - var insertComment = false; - - for (var i = 0; i < children.length; i++) { - var child = children[i]; - var isText = isStringOrNumber(child); - var isInvalid = isInvalidNode(child); - - if (isText || isInvalid) { - if (insertComment === true) { - if (isInvalidNode(child)) { - childrenResult.push(''); - } else { - childrenResult.push(''); - } - } - if (isText) { - childrenResult.push(escapeText(child)); +} + +function renderChildren(children, context) { + if (children && isArray(children)) { + var childrenResult = []; + var insertComment = false; + + for (var i = 0; i < children.length; i++) { + var child = children[i]; + var isText = isStringOrNumber(child); + var isInvalid = isInvalidNode(child); + + if (isText || isInvalid) { + if (insertComment === true) { + if (isInvalidNode(child)) { + childrenResult.push(''); + } else { + childrenResult.push(''); } - insertComment = true; - } else if (isArray(child)) { - childrenResult.push(''); - childrenResult.push(renderChildren(child)); - childrenResult.push(''); - insertComment = true; - } else { - insertComment = false; - childrenResult.push(renderNode(child, context, false)); } - } - return childrenResult.join(''); - } else if (!isInvalidNode(children)) { - if (isStringOrNumber(children)) { - return escapeText(children); + if (isText) { + childrenResult.push(escapeText(child)); + } + insertComment = true; + } else if (isArray(child)) { + childrenResult.push(''); + childrenResult.push(renderChildren(child)); + childrenResult.push(''); + insertComment = true; } else { - return renderNode(children, context, false) || ''; + insertComment = false; + childrenResult.push(renderNode(child, context, false)); } } - return ''; - } - - function renderStyleToString(style) { - if (isStringOrNumber(style)) { - return style; + return childrenResult.join(''); + } else if (!isInvalidNode(children)) { + if (isStringOrNumber(children)) { + return escapeText(children); } else { - var styles = []; - var keys = Object.keys(style); - - for (var i = 0; i < keys.length; i++) { - var styleName = keys[i]; - var value = style[styleName]; - var px = isNumber(value) && !isUnitlessNumber[styleName] ? 'px' : ''; - - if (!isNullOrUndefined(value)) { - styles.push(((toHyphenCase(styleName)) + ":" + (escapeAttr(value)) + px + ";")); - } - } - return styles.join(); + return renderNode(children, context, false) || ''; } } - - function renderNode(node, context, isRoot) { - if (!isInvalidNode(node)) { - var bp = node.bp; - var tag = node.tag || (bp && bp.tag); - var outputAttrs = []; - var className = node.className; - var style = node.style; - - if (isFunction(tag)) { - return renderComponent(tag, node.attrs, node.children, context, isRoot); - } - if (!isNullOrUndefined(className)) { - outputAttrs.push('class="' + escapeAttr(className) + '"'); - } - if (!isNullOrUndefined(style)) { - outputAttrs.push('style="' + renderStyleToString(style) + '"'); - } - var attrs = node.attrs; - var attrKeys = (attrs && Object.keys(attrs)) || []; - var html = ''; - - if (bp && bp.hasAttrs === true) { - attrKeys = bp.attrKeys ? bp.attrKeys.concat(attrKeys) : attrKeys; - } - attrKeys.forEach(function (attrsKey, i) { - var attr = attrKeys[i]; - var value = attrs[attr]; - - if (attr === 'dangerouslySetInnerHTML') { - html = value.__html; - } else { - if (isStringOrNumber(value)) { - outputAttrs.push(escapeAttr(attr) + '="' + escapeAttr(value) + '"'); - } else if (isTrue$1(value)) { - outputAttrs.push(escapeAttr(attr)); - } - } - }); - - if (isRoot) { - outputAttrs.push('data-infernoroot'); - } - if (isVoidElement(tag)) { - return ("<" + tag + (outputAttrs.length > 0 ? ' ' + outputAttrs.join(' ') : '') + ">"); - } else { - return ("<" + tag + (outputAttrs.length > 0 ? ' ' + outputAttrs.join(' ') : '') + ">" + (html || renderChildren(node.children, context)) + ""); + return ''; +} + +function renderStyleToString(style) { + if (isStringOrNumber(style)) { + return style; + } else { + var styles = []; + var keys = Object.keys(style); + + for (var i = 0; i < keys.length; i++) { + var styleName = keys[i]; + var value = style[styleName]; + var px = isNumber(value) && !isUnitlessNumber[styleName] ? 'px' : ''; + + if (!isNullOrUndefined(value)) { + styles.push(((toHyphenCase(styleName)) + ":" + (escapeAttr(value)) + px + ";")); } } + return styles.join(); } +} - function renderToString(node) { - return renderNode(node, null, false); - } - - function renderToStaticMarkup(node) { - return renderNode(node, null, true); - } - - function renderStyleToString$1(style) { - if (isStringOrNumber(style)) { - return style; - } else { - var styles = []; - var keys = Object.keys(style); - - for (var i = 0; i < keys.length; i++) { - var styleName = keys[i]; - var value = style[styleName]; - var px = isNumber(value) && !isUnitlessNumber[styleName] ? 'px' : ''; +function renderNode(node, context, isRoot) { + if (!isInvalidNode(node)) { + var bp = node.bp; + var tag = node.tag || (bp && bp.tag); + var outputAttrs = []; + var className = node.className; + var style = node.style; - if (!isNullOrUndefined(value)) { - styles.push(((toHyphenCase(styleName)) + ":" + (escapeAttr(value)) + px + ";")); - } - } - return styles.join(); + if (isFunction(tag)) { + return renderComponent(tag, node.attrs, node.children, context, isRoot); } - } - - function renderAttributes(bp, attrs){ - var outputAttrs = []; + if (!isNullOrUndefined(className)) { + outputAttrs.push('class="' + escapeAttr(className) + '"'); + } + if (!isNullOrUndefined(style)) { + outputAttrs.push('style="' + renderStyleToString(style) + '"'); + } + var attrs = node.attrs; var attrKeys = (attrs && Object.keys(attrs)) || []; var html = ''; @@ -334,197 +272,259 @@ var value = attrs[attr]; if (attr === 'dangerouslySetInnerHTML') { - return; + html = value.__html; } else { if (isStringOrNumber(value)) { outputAttrs.push(escapeAttr(attr) + '="' + escapeAttr(value) + '"'); - } else if (isTrue(value)) { + } else if (isTrue$1(value)) { outputAttrs.push(escapeAttr(attr)); } } }); - return outputAttrs; + if (isRoot) { + outputAttrs.push('data-infernoroot'); + } + if (isVoidElement(tag)) { + return ("<" + tag + (outputAttrs.length > 0 ? ' ' + outputAttrs.join(' ') : '') + ">"); + } else { + return ("<" + tag + (outputAttrs.length > 0 ? ' ' + outputAttrs.join(' ') : '') + ">" + (html || renderChildren(node.children, context)) + ""); + } } - - var RenderStream = (function (Readable) { - function RenderStream(initNode, staticMarkup) { - Readable.call(this); - this.initNode = initNode; - this.staticMarkup = staticMarkup; - this.started = false; +} + +function renderToString(node) { + return renderNode(node, null, false); +} + +function renderToStaticMarkup(node) { + return renderNode(node, null, true); +} + +function renderStyleToString$1(style) { + if (isStringOrNumber(style)) { + return style; + } else { + var styles = []; + var keys = Object.keys(style); + + for (var i = 0; i < keys.length; i++) { + var styleName = keys[i]; + var value = style[styleName]; + var px = isNumber(value) && !isUnitlessNumber[styleName] ? 'px' : ''; + + if (!isNullOrUndefined(value)) { + styles.push(((toHyphenCase(styleName)) + ":" + (escapeAttr(value)) + px + ";")); + } } + return styles.join(); + } +} - if ( Readable ) RenderStream.__proto__ = Readable; - RenderStream.prototype = Object.create( Readable && Readable.prototype ); - RenderStream.prototype.constructor = RenderStream; +function renderAttributes(bp, attrs){ + var outputAttrs = []; + var attrKeys = (attrs && Object.keys(attrs)) || []; + var html = ''; - RenderStream.prototype._read = function _read (){ - var this$1 = this; + if (bp && bp.hasAttrs === true) { + attrKeys = bp.attrKeys ? bp.attrKeys.concat(attrKeys) : attrKeys; + } + attrKeys.forEach(function (attrsKey, i) { + var attr = attrKeys[i]; + var value = attrs[attr]; - if (this.started) { - return; + if (attr === 'dangerouslySetInnerHTML') { + return; + } else { + if (isStringOrNumber(value)) { + outputAttrs.push(escapeAttr(attr) + '="' + escapeAttr(value) + '"'); + } else if (isTrue(value)) { + outputAttrs.push(escapeAttr(attr)); } - this.started = true; - - Promise.resolve().then(function () { - return this$1.renderNode(this$1.initNode, null, this$1.staticMarkup); - }).then(function (){ - this$1.push(null); - }).catch(function (err) { - this$1.emit('error', err); - }); - }; + } + }); - RenderStream.prototype.renderNode = function renderNode (node, context, isRoot){ - if (isInvalidNode(node)) { - return; - } + return outputAttrs; +} - var bp = node.bp; - var tag = node.tag || (bp && bp.tag); +var RenderStream = (function (Readable) { + function RenderStream(initNode, staticMarkup) { + Readable.call(this); + this.initNode = initNode; + this.staticMarkup = staticMarkup; + this.started = false; + } - if (isFunction(tag)) { - return this.renderComponent(tag, node.attrs, node.children, context, isRoot); - } else { - return this.renderNative(tag, node, context, isRoot); - } - }; - RenderStream.prototype.renderComponent = function renderComponent (Component, props, children, context, isRoot) { - var this$1 = this; + if ( Readable ) RenderStream.__proto__ = Readable; + RenderStream.prototype = Object.create( Readable && Readable.prototype ); + RenderStream.prototype.constructor = RenderStream; - props = addChildrenToProps(children, props); + RenderStream.prototype._read = function _read (){ + var this$1 = this; - if (!isStatefulComponent(Component)) { - return this.renderNode(Component(props, context), context, isRoot); - } + if (this.started) { + return; + } + this.started = true; + + Promise.resolve().then(function () { + return this$1.renderNode(this$1.initNode, null, this$1.staticMarkup); + }).then(function (){ + this$1.push(null); + }).catch(function (err) { + this$1.emit('error', err); + }); + }; - var instance = new Component(props, context); - var childContext = instance.getChildContext(); + RenderStream.prototype.renderNode = function renderNode (node, context, isRoot){ + if (isInvalidNode(node)) { + return; + } - if (!isNullOrUndefined(childContext)) { - context = Object.assign({}, context, childContext); - } - instance.context = context; - - // Block setting state - we should render only once, using latest state - instance._pendingSetState = true; - return Promise.resolve(instance.componentWillMount()).then(function () { - var node = instance.render(); - instance._pendingSetState = false; - return this$1.renderNode(node, context, isRoot); - }); - }; + var bp = node.bp; + var tag = node.tag || (bp && bp.tag); - RenderStream.prototype.renderChildren = function renderChildren (children, context){ - var this$1 = this; + if (isFunction(tag)) { + return this.renderComponent(tag, node.attrs, node.children, context, isRoot); + } else { + return this.renderNative(tag, node, context, isRoot); + } + }; + RenderStream.prototype.renderComponent = function renderComponent (Component, props, children, context, isRoot) { + var this$1 = this; - if (isStringOrNumber(children)) { - return this.push(escapeText(children)); - } - if (!children) { - return; - } + props = addChildrenToProps(children, props); - var childrenIsArray = isArray(children); - if (!childrenIsArray && !isInvalidNode(children)) { - return this.renderNode(children, context, false); - } - if (!childrenIsArray) { - throw new Error('invalid component'); - } - return children.reduce(function (p, child){ - return p.then(function (insertComment){ - var isText = isStringOrNumber(child); - var isInvalid = isInvalidNode(child); - - if (isText || isInvalid) { - if (insertComment === true) { - if (isInvalid) { - this$1.push(''); - } else { - this$1.push(''); - } - } - if (isText) { - this$1.push(escapeText(child)); - } - return true; - } else if (isArray(child)) { - this$1.push(''); - return Promise.resolve(this$1.renderChildren(child)).then(function (){ - this$1.push(''); - return true; - }); - } else { - return this$1.renderNode(child, context, false) - .then(function () { - return false; - }); - } - }); - }, Promise.resolve(false)); - }; + if (!isStatefulComponent(Component)) { + return this.renderNode(Component(props, context), context, isRoot); + } - RenderStream.prototype.renderNative = function renderNative (tag, node, context, isRoot) { - var this$1 = this; + var instance = new Component(props, context); + var childContext = instance.getChildContext(); - var bp = node.bp; - var attrs = node.attrs; - var className = node.className; - var style = node.style; + if (!isNullOrUndefined(childContext)) { + context = Object.assign({}, context, childContext); + } + instance.context = context; - var outputAttrs = renderAttributes(bp, attrs); - if (!isNullOrUndefined(className)) { - outputAttrs.push('class="' + escapeAttr(className) + '"'); - } - if (!isNullOrUndefined(style)) { - outputAttrs.push('style="' + renderStyleToString$1(style) + '"'); - } + // Block setting state - we should render only once, using latest state + instance._pendingSetState = true; + return Promise.resolve(instance.componentWillMount()).then(function () { + var node = instance.render(); + instance._pendingSetState = false; + return this$1.renderNode(node, context, isRoot); + }); + }; - var html = ''; + RenderStream.prototype.renderChildren = function renderChildren (children, context){ + var this$1 = this; - if (attrs && 'dangerouslySetInnerHTML' in attrs) { - html = attrs[ 'dangerouslySetInnerHTML' ].__html; - } + if (isStringOrNumber(children)) { + return this.push(escapeText(children)); + } + if (!children) { + return; + } + var childrenIsArray = isArray(children); + if (!childrenIsArray && !isInvalidNode(children)) { + return this.renderNode(children, context, false); + } + if (!childrenIsArray) { + throw new Error('invalid component'); + } + return children.reduce(function (p, child){ + return p.then(function (insertComment){ + var isText = isStringOrNumber(child); + var isInvalid = isInvalidNode(child); - if (isRoot) { - outputAttrs.push('data-infernoroot'); - } - this.push(("<" + tag + (outputAttrs.length > 0 ? ' ' + outputAttrs.join(' ') : '') + ">")); - if (isVoidElement(tag)) { - return; - } - if (html) { - this.push(html); - this.push(("")); - return; - } - return Promise.resolve(this.renderChildren(node.children, context)).then(function (){ - this$1.push(("")); + if (isText || isInvalid) { + if (insertComment === true) { + if (isInvalid) { + this$1.push(''); + } else { + this$1.push(''); + } + } + if (isText) { + this$1.push(escapeText(child)); + } + return true; + } else if (isArray(child)) { + this$1.push(''); + return Promise.resolve(this$1.renderChildren(child)).then(function (){ + this$1.push(''); + return true; + }); + } else { + return this$1.renderNode(child, context, false) + .then(function () { + return false; + }); + } }); - }; + }, Promise.resolve(false)); + }; - return RenderStream; - }(stream.Readable)); + RenderStream.prototype.renderNative = function renderNative (tag, node, context, isRoot) { + var this$1 = this; - function streamAsString(node) { - return new RenderStream(node, false); - } + var bp = node.bp; + var attrs = node.attrs; + var className = node.className; + var style = node.style; - function streamAsStaticMarkup(node) { - return new RenderStream(node, true); - } + var outputAttrs = renderAttributes(bp, attrs); + if (!isNullOrUndefined(className)) { + outputAttrs.push('class="' + escapeAttr(className) + '"'); + } + if (!isNullOrUndefined(style)) { + outputAttrs.push('style="' + renderStyleToString$1(style) + '"'); + } + + var html = ''; - var index = { - renderToString: renderToString, - renderToStaticMarkup: renderToStaticMarkup, - streamAsString: streamAsString, - streamAsStaticMarkup: streamAsStaticMarkup, - RenderStream: RenderStream + if (attrs && 'dangerouslySetInnerHTML' in attrs) { + html = attrs[ 'dangerouslySetInnerHTML' ].__html; + } + + + if (isRoot) { + outputAttrs.push('data-infernoroot'); + } + this.push(("<" + tag + (outputAttrs.length > 0 ? ' ' + outputAttrs.join(' ') : '') + ">")); + if (isVoidElement(tag)) { + return; + } + if (html) { + this.push(html); + this.push(("")); + return; + } + return Promise.resolve(this.renderChildren(node.children, context)).then(function (){ + this$1.push(("")); + }); }; - return index; + return RenderStream; +}(stream.Readable)); + +function streamAsString(node) { + return new RenderStream(node, false); +} + +function streamAsStaticMarkup(node) { + return new RenderStream(node, true); +} + +var index = { + renderToString: renderToString, + renderToStaticMarkup: renderToStaticMarkup, + streamAsString: streamAsString, + streamAsStaticMarkup: streamAsStaticMarkup, + RenderStream: RenderStream +}; + +return index; -})); \ No newline at end of file +}))); \ No newline at end of file diff --git a/packages/inferno/dist/inferno-server.min.js b/packages/inferno/dist/inferno-server.min.js index 53d7d6bb0..db66bccd8 100644 --- a/packages/inferno/dist/inferno-server.min.js +++ b/packages/inferno/dist/inferno-server.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("stream")):"function"==typeof define&&define.amd?define(["stream"],t):e.InfernoServer=t(e.stream)}(this,function(e){"use strict";function t(e,t){if(!i(e)){var r=n(e);(r&&e.length>0||!r)&&(t=t?Object.assign({},t,{children:e}):{children:e})}return t}function n(e){return e instanceof Array}function r(e){return e.prototype&&void 0!==e.prototype.render}function o(e){return s(e)||c(e)}function i(e){return d(e)||l(e)}function u(e){return l(e)||e===!1||e===!0||d(e)}function a(e){return"function"==typeof e}function s(e){return"string"==typeof e}function c(e){return"number"==typeof e}function l(e){return null===e}function p(e){return e===!0}function d(e){return void 0===e}function f(e,t,n){e.split(",").forEach(function(e){return t[e]=n})}function h(e){return(e+"").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}function m(e){return(e+"").replace(/&/g,"&").replace(/"/g,""")}function g(e){return e.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase()}function w(e){return!!K[e]}function v(e,n,o,u,a){if(n=t(o,n),r(e)){var s=new e(n,u),c=s.getChildContext();i(c)||(u=Object.assign({},u,c)),s.context=u,s._pendingSetState=!0,s.componentWillMount();var l=s.render();return s._pendingSetState=!1,b(l,u,a)}return b(e(n,u),u,a)}function y(e,t){if(e&&n(e)){for(var r=[],i=!1,a=0;a"):r.push("")),c&&r.push(h(s)),i=!0):n(s)?(r.push(""),r.push(y(s)),r.push(""),i=!0):(i=!1,r.push(b(s,t,!1)))}return r.join("")}return u(e)?"":o(e)?h(e):b(e,t,!1)||""}function x(e){if(o(e))return e;for(var t=[],n=Object.keys(e),r=0;r0?" "+c.join(" "):"")+">":"<"+s+(c.length>0?" "+c.join(" "):"")+">"+(g||y(e.children,t))+""}}function k(e){return b(e,null,!1)}function S(e){return b(e,null,!0)}function j(e){if(o(e))return e;for(var t=[],n=Object.keys(e),r=0;r"):r.push("")),a&&r.push(h(i)),!0):n(i)?(r.push(""),Promise.resolve(r.renderChildren(i)).then(function(){return r.push(""),!0})):r.renderNode(i,t,!1).then(function(){return!1})})},Promise.resolve(!1))}},s.prototype.renderNative=function(e,t,n,r){var o=this,u=t.bp,a=t.attrs,s=t.className,c=t.style,l=O(u,a);i(s)||l.push('class="'+m(s)+'"'),i(c)||l.push('style="'+j(c)+'"');var p="";if(a&&"dangerouslySetInnerHTML"in a&&(p=a.dangerouslySetInnerHTML.__html),r&&l.push("data-infernoroot"),this.push("<"+e+(l.length>0?" "+l.join(" "):"")+">"),!w(e))return p?(this.push(p),void this.push("")):Promise.resolve(this.renderChildren(t.children,n)).then(function(){o.push("")})},s}(e.Readable),G={renderToString:k,renderToStaticMarkup:S,streamAsString:C,streamAsStaticMarkup:N,RenderStream:F};return G}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("stream")):"function"==typeof define&&define.amd?define(["stream"],t):e.InfernoServer=t(e.stream)}(this,function(e){"use strict";function t(e,t){if(!i(e)){var r=n(e);(r&&e.length>0||!r)&&(t=t?Object.assign({},t,{children:e}):{children:e})}return t}function n(e){return e instanceof Array}function r(e){return e.prototype&&void 0!==e.prototype.render}function o(e){return s(e)||c(e)}function i(e){return d(e)||l(e)}function u(e){return l(e)||e===!1||e===!0||d(e)}function a(e){return"function"==typeof e}function s(e){return"string"==typeof e}function c(e){return"number"==typeof e}function l(e){return null===e}function p(e){return e===!0}function d(e){return void 0===e}function f(e,t,n){e.split(",").forEach(function(e){return t[e]=n})}function h(e){return(e+"").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}function m(e){return(e+"").replace(/&/g,"&").replace(/"/g,""")}function g(e){return e.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase()}function w(e){return!!K[e]}function v(e,n,o,u,a){if(n=t(o,n),r(e)){var s=new e(n,u),c=s.getChildContext();i(c)||(u=Object.assign({},u,c)),s.context=u,s._pendingSetState=!0,s.componentWillMount();var l=s.render();return s._pendingSetState=!1,b(l,u,a)}return b(e(n,u),u,a)}function y(e,t){if(e&&n(e)){for(var r=[],i=!1,a=0;a"):r.push("")),c&&r.push(h(s)),i=!0):n(s)?(r.push(""),r.push(y(s)),r.push(""),i=!0):(i=!1,r.push(b(s,t,!1)))}return r.join("")}return u(e)?"":o(e)?h(e):b(e,t,!1)||""}function x(e){if(o(e))return e;for(var t=[],n=Object.keys(e),r=0;r0?" "+c.join(" "):"")+">":"<"+s+(c.length>0?" "+c.join(" "):"")+">"+(g||y(e.children,t))+""}}function k(e){return b(e,null,!1)}function S(e){return b(e,null,!0)}function j(e){if(o(e))return e;for(var t=[],n=Object.keys(e),r=0;r"):r.push("")),a&&r.push(h(i)),!0):n(i)?(r.push(""),Promise.resolve(r.renderChildren(i)).then(function(){return r.push(""),!0})):r.renderNode(i,t,!1).then(function(){return!1})})},Promise.resolve(!1))}},s.prototype.renderNative=function(e,t,n,r){var o=this,u=t.bp,a=t.attrs,s=t.className,c=t.style,l=O(u,a);i(s)||l.push('class="'+m(s)+'"'),i(c)||l.push('style="'+j(c)+'"');var p="";if(a&&"dangerouslySetInnerHTML"in a&&(p=a.dangerouslySetInnerHTML.__html),r&&l.push("data-infernoroot"),this.push("<"+e+(l.length>0?" "+l.join(" "):"")+">"),!w(e))return p?(this.push(p),void this.push("")):Promise.resolve(this.renderChildren(t.children,n)).then(function(){o.push("")})},s}(e.Readable),G={renderToString:k,renderToStaticMarkup:S,streamAsString:C,streamAsStaticMarkup:N,RenderStream:F};return G}); \ No newline at end of file diff --git a/packages/inferno/dist/inferno-test-utils.js b/packages/inferno/dist/inferno-test-utils.js index 9b5bcdccf..ea82803dc 100644 --- a/packages/inferno/dist/inferno-test-utils.js +++ b/packages/inferno/dist/inferno-test-utils.js @@ -1,5 +1,5 @@ /*! - * inferno-test-utils v0.7.25 + * inferno-test-utils v0.7.26 * (c) 2016 Dominic Gannaway * Released under the MIT License. */ @@ -7,27 +7,27 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global.InfernoTestUtils = factory()); -}(this, function () { 'use strict'; +}(this, (function () { 'use strict'; - function shallowRender() { +function shallowRender() { - } +} - function deepRender() { +function deepRender() { - } +} - function renderIntoDocument() { +function renderIntoDocument() { - } +} - var index = { - shallowRender: shallowRender, - deepRender: deepRender, - renderIntoDocument: renderIntoDocument - // Simulate - }; +var index = { + shallowRender: shallowRender, + deepRender: deepRender, + renderIntoDocument: renderIntoDocument + // Simulate +}; - return index; +return index; -})); \ No newline at end of file +}))); \ No newline at end of file diff --git a/packages/inferno/dist/inferno.js b/packages/inferno/dist/inferno.js index 950024dc3..187b4d81c 100644 --- a/packages/inferno/dist/inferno.js +++ b/packages/inferno/dist/inferno.js @@ -1,5 +1,5 @@ /*! - * inferno v0.7.25 + * inferno v0.7.26 * (c) 2016 Dominic Gannaway * Released under the MIT License. */ @@ -7,306 +7,306 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global.Inferno = factory()); -}(this, function () { 'use strict'; - - // Runs only once in applications lifetime - var isBrowser = typeof window !== 'undefined' && window.document; - - function isNullOrUndefined(obj) { - return isUndefined(obj) || isNull(obj); - } - - function isAttrAnEvent$1(attr) { - return attr[0] === 'o' && attr[1] === 'n' && attr.length > 3; - } - - function isNull(obj) { - return obj === null; +}(this, (function () { 'use strict'; + +// Runs only once in applications lifetime +var isBrowser = typeof window !== 'undefined' && window.document; + +function isNullOrUndefined(obj) { + return isUndefined(obj) || isNull(obj); +} + +function isAttrAnEvent$1(attr) { + return attr[0] === 'o' && attr[1] === 'n' && attr.length > 3; +} + +function isNull(obj) { + return obj === null; +} + +function isUndefined(obj) { + return obj === undefined; +} + +function VNode(blueprint) { + this.bp = blueprint; + this.dom = null; + this.instance = null; + this.tag = null; + this.children = null; + this.style = null; + this.className = null; + this.attrs = null; + this.events = null; + this.hooks = null; + this.key = null; + this.clipData = null; +} + +VNode.prototype = { + setAttrs: function setAttrs(attrs) { + this.attrs = attrs; + return this; + }, + setTag: function setTag(tag) { + this.tag = tag; + return this; + }, + setStyle: function setStyle(style) { + this.style = style; + return this; + }, + setClassName: function setClassName(className) { + this.className = className; + return this; + }, + setChildren: function setChildren(children) { + this.children = children; + return this; + }, + setHooks: function setHooks(hooks) { + this.hooks = hooks; + return this; + }, + setEvents: function setEvents(events) { + this.events = events; + return this; + }, + setKey: function setKey(key) { + this.key = key; + return this; } - - function isUndefined(obj) { - return obj === undefined; - } - - function VNode(blueprint) { - this.bp = blueprint; - this.dom = null; - this.instance = null; - this.tag = null; - this.children = null; - this.style = null; - this.className = null; - this.attrs = null; - this.events = null; - this.hooks = null; - this.key = null; - this.clipData = null; - } - - VNode.prototype = { - setAttrs: function setAttrs(attrs) { - this.attrs = attrs; - return this; - }, - setTag: function setTag(tag) { - this.tag = tag; - return this; - }, - setStyle: function setStyle(style) { - this.style = style; - return this; - }, - setClassName: function setClassName(className) { - this.className = className; - return this; - }, - setChildren: function setChildren(children) { - this.children = children; - return this; - }, - setHooks: function setHooks(hooks) { - this.hooks = hooks; - return this; - }, - setEvents: function setEvents(events) { - this.events = events; - return this; - }, - setKey: function setKey(key) { - this.key = key; - return this; - } +}; + +function createVNode(bp) { + return new VNode(bp); +} + +function isAttrAnEvent(attr) { + return attr[0] === 'o' && attr[1] === 'n' && attr.length > 3; +} + +function isAttrAHook(hook) { + return hook === 'onCreated' + || hook === 'onAttached' + || hook === 'onWillDetach' + || hook === 'onWillUpdate' + || hook === 'onDidUpdate'; +} + +function isAttrAComponentHook(hook) { + return hook === 'onComponentWillMount' + || hook === 'onComponentDidMount' + || hook === 'onComponentWillUnmount' + || hook === 'onComponentShouldUpdate' + || hook === 'onComponentWillUpdate' + || hook === 'onComponentDidUpdate'; +} + + +function createBlueprint(shape, childrenType) { + var tag = shape.tag || null; + var tagIsDynamic = tag && tag.arg !== undefined ? true : false; + + var children = isNullOrUndefined(shape.children) ? null : shape.children; + var childrenIsDynamic = children && children.arg !== undefined ? true : false; + + var attrs = shape.attrs || null; + var attrsIsDynamic = attrs && attrs.arg !== undefined ? true : false; + + var hooks = shape.hooks || null; + var hooksIsDynamic = hooks && hooks.arg !== undefined ? true : false; + + var events = shape.events || null; + var eventsIsDynamic = events && events.arg !== undefined ? true : false; + + var key = shape.key === undefined ? null : shape.key; + var keyIsDynamic = !isNullOrUndefined(key) && !isNullOrUndefined(key.arg); + + var style = shape.style || null; + var styleIsDynamic = style && style.arg !== undefined ? true : false; + + var className = shape.className === undefined ? null : shape.className; + var classNameIsDynamic = className && className.arg !== undefined ? true : false; + + var spread = shape.spread === undefined ? null : shape.spread; + var hasSpread = shape.spread !== undefined; + + var blueprint = { + lazy: shape.lazy || false, + dom: null, + pool: [], + tag: tagIsDynamic ? null : tag, + className: className !== '' && className ? className : null, + style: style !== '' && style ? style : null, + isComponent: tagIsDynamic, + hasAttrs: attrsIsDynamic || (attrs ? true : false), + hasHooks: hooksIsDynamic, + hasEvents: eventsIsDynamic, + hasStyle: styleIsDynamic || (style !== '' && style ? true : false), + hasClassName: classNameIsDynamic || (className !== '' && className ? true : false), + childrenType: childrenType === undefined ? (children ? 5 : 0) : childrenType, + attrKeys: null, + eventKeys: null, + isSVG: shape.isSVG || false }; - function createVNode(bp) { - return new VNode(bp); - } - - function isAttrAnEvent(attr) { - return attr[0] === 'o' && attr[1] === 'n' && attr.length > 3; - } - - function isAttrAHook(hook) { - return hook === 'onCreated' - || hook === 'onAttached' - || hook === 'onWillDetach' - || hook === 'onWillUpdate' - || hook === 'onDidUpdate'; - } - - function isAttrAComponentHook(hook) { - return hook === 'onComponentWillMount' - || hook === 'onComponentDidMount' - || hook === 'onComponentWillUnmount' - || hook === 'onComponentShouldUpdate' - || hook === 'onComponentWillUpdate' - || hook === 'onComponentDidUpdate'; - } - - - function createBlueprint(shape, childrenType) { - var tag = shape.tag || null; - var tagIsDynamic = tag && tag.arg !== undefined ? true : false; + return function () { + var vNode = new VNode(blueprint); - var children = isNullOrUndefined(shape.children) ? null : shape.children; - var childrenIsDynamic = children && children.arg !== undefined ? true : false; - - var attrs = shape.attrs || null; - var attrsIsDynamic = attrs && attrs.arg !== undefined ? true : false; - - var hooks = shape.hooks || null; - var hooksIsDynamic = hooks && hooks.arg !== undefined ? true : false; - - var events = shape.events || null; - var eventsIsDynamic = events && events.arg !== undefined ? true : false; - - var key = shape.key === undefined ? null : shape.key; - var keyIsDynamic = !isNullOrUndefined(key) && !isNullOrUndefined(key.arg); - - var style = shape.style || null; - var styleIsDynamic = style && style.arg !== undefined ? true : false; - - var className = shape.className === undefined ? null : shape.className; - var classNameIsDynamic = className && className.arg !== undefined ? true : false; - - var spread = shape.spread === undefined ? null : shape.spread; - var hasSpread = shape.spread !== undefined; - - var blueprint = { - lazy: shape.lazy || false, - dom: null, - pool: [], - tag: tagIsDynamic ? null : tag, - className: className !== '' && className ? className : null, - style: style !== '' && style ? style : null, - isComponent: tagIsDynamic, - hasAttrs: attrsIsDynamic || (attrs ? true : false), - hasHooks: hooksIsDynamic, - hasEvents: eventsIsDynamic, - hasStyle: styleIsDynamic || (style !== '' && style ? true : false), - hasClassName: classNameIsDynamic || (className !== '' && className ? true : false), - childrenType: childrenType === undefined ? (children ? 5 : 0) : childrenType, - attrKeys: null, - eventKeys: null, - isSVG: shape.isSVG || false - }; - - return function () { - var vNode = new VNode(blueprint); - - if (tagIsDynamic === true) { - vNode.tag = arguments[tag.arg]; - } - if (childrenIsDynamic === true) { - vNode.children = arguments[children.arg]; - } - if (hasSpread) { - var _spread = arguments[spread.arg]; - var attrs$1; - var events$1; - var hooks$1; - var attrKeys = []; - var eventKeys = []; - - for (var prop in _spread) { - var value = _spread[prop]; - - if (prop === 'className' || (prop === 'class' && !blueprint.isSVG)) { - vNode.className = value; - blueprint.hasClassName = true; - } else if (prop === 'style') { - vNode.style = value; - blueprint.hasStyle = true; - } else if (prop === 'key') { - vNode.key = value; - } else if (isAttrAHook(prop) || isAttrAComponentHook(prop)) { - if (!hooks$1) { - hooks$1 = {}; - } - hooks$1[prop[2].toLowerCase() + prop.substring(3)] = value; - } else if (isAttrAnEvent(prop)) { - if (!events$1) { - events$1 = {}; - } - eventKeys.push(prop.toLowerCase()); - events$1[prop.toLowerCase()] = value; - } else if (prop === 'children') { - vNode.children = value; - blueprint.childrenType = blueprint.childrenType || 5; - } else { - if (!attrs$1) { - attrs$1 = {}; - } - attrKeys.push(prop); - attrs$1[prop] = value; + if (tagIsDynamic === true) { + vNode.tag = arguments[tag.arg]; + } + if (childrenIsDynamic === true) { + vNode.children = arguments[children.arg]; + } + if (hasSpread) { + var _spread = arguments[spread.arg]; + var attrs$1; + var events$1; + var hooks$1; + var attrKeys = []; + var eventKeys = []; + + for (var prop in _spread) { + var value = _spread[prop]; + + if (prop === 'className' || (prop === 'class' && !blueprint.isSVG)) { + vNode.className = value; + blueprint.hasClassName = true; + } else if (prop === 'style') { + vNode.style = value; + blueprint.hasStyle = true; + } else if (prop === 'key') { + vNode.key = value; + } else if (isAttrAHook(prop) || isAttrAComponentHook(prop)) { + if (!hooks$1) { + hooks$1 = {}; } - } - if (attrs$1) { - vNode.attrs = attrs$1; - blueprint.attrKeys = attrKeys; - blueprint.hasAttrs = true; - } - if (events$1) { - vNode.events = events$1; - blueprint.eventKeys = eventKeys; - blueprint.hasEvents = true; - } - if (hooks$1) { - vNode.hooks = hooks$1; - blueprint.hasHooks = true; - } - } else { - if (attrsIsDynamic === true) { - vNode.attrs = arguments[attrs.arg]; - } else { - vNode.attrs = attrs; - } - if (hooksIsDynamic === true) { - vNode.hooks = arguments[hooks.arg]; - } - if (eventsIsDynamic === true) { - vNode.events = arguments[events.arg]; - } - if (keyIsDynamic === true) { - vNode.key = arguments[key.arg]; - } else { - vNode.key = key; - } - if (styleIsDynamic === true) { - vNode.style = arguments[style.arg]; - } else { - vNode.style = blueprint.style; - } - if (classNameIsDynamic === true) { - vNode.className = arguments[className.arg]; + hooks$1[prop[2].toLowerCase() + prop.substring(3)] = value; + } else if (isAttrAnEvent(prop)) { + if (!events$1) { + events$1 = {}; + } + eventKeys.push(prop.toLowerCase()); + events$1[prop.toLowerCase()] = value; + } else if (prop === 'children') { + vNode.children = value; + blueprint.childrenType = blueprint.childrenType || 5; } else { - vNode.className = blueprint.className; + if (!attrs$1) { + attrs$1 = {}; + } + attrKeys.push(prop); + attrs$1[prop] = value; } } - return vNode; - }; - } + if (attrs$1) { + vNode.attrs = attrs$1; + blueprint.attrKeys = attrKeys; + blueprint.hasAttrs = true; + } + if (events$1) { + vNode.events = events$1; + blueprint.eventKeys = eventKeys; + blueprint.hasEvents = true; + } + if (hooks$1) { + vNode.hooks = hooks$1; + blueprint.hasHooks = true; + } + } else { + if (attrsIsDynamic === true) { + vNode.attrs = arguments[attrs.arg]; + } else { + vNode.attrs = attrs; + } + if (hooksIsDynamic === true) { + vNode.hooks = arguments[hooks.arg]; + } + if (eventsIsDynamic === true) { + vNode.events = arguments[events.arg]; + } + if (keyIsDynamic === true) { + vNode.key = arguments[key.arg]; + } else { + vNode.key = key; + } + if (styleIsDynamic === true) { + vNode.style = arguments[style.arg]; + } else { + vNode.style = blueprint.style; + } + if (classNameIsDynamic === true) { + vNode.className = arguments[className.arg]; + } else { + vNode.className = blueprint.className; + } + } + return vNode; + }; +} - function VText(text) { - this.text = text; - this.dom = null; - } +function VText(text) { + this.text = text; + this.dom = null; +} - function createVText(text) { - return new VText(text); - } +function createVText(text) { + return new VText(text); +} - // Copy of the util from dom/util, otherwise it makes massive bundles - function documentCreateElement(tag, isSVG) { - var dom; +// Copy of the util from dom/util, otherwise it makes massive bundles +function documentCreateElement(tag, isSVG) { + var dom; - if (isSVG === true) { - dom = document.createElementNS('http://www.w3.org/2000/svg', tag); - } else { - dom = document.createElement(tag); - } - return dom; + if (isSVG === true) { + dom = document.createElementNS('http://www.w3.org/2000/svg', tag); + } else { + dom = document.createElement(tag); } - - function createUniversalElement(tag, attrs, isSVG) { - if (isBrowser) { - var dom = documentCreateElement(tag, isSVG); - if (attrs) { - createStaticAttributes(attrs, dom); - } - return dom; + return dom; +} + +function createUniversalElement(tag, attrs, isSVG) { + if (isBrowser) { + var dom = documentCreateElement(tag, isSVG); + if (attrs) { + createStaticAttributes(attrs, dom); } - return null; + return dom; } + return null; +} - function createStaticAttributes(attrs, dom) { - var attrKeys = Object.keys(attrs); +function createStaticAttributes(attrs, dom) { + var attrKeys = Object.keys(attrs); - for (var i = 0; i < attrKeys.length; i++) { - var attr = attrKeys[i]; - var value = attrs[attr]; + for (var i = 0; i < attrKeys.length; i++) { + var attr = attrKeys[i]; + var value = attrs[attr]; - if (attr === 'className') { - dom.className = value; - } else { - if (value === true) { - dom.setAttribute(attr, attr); - } else if (!isNullOrUndefined(value) && value !== false && !isAttrAnEvent$1(attr)) { - dom.setAttribute(attr, value); - } + if (attr === 'className') { + dom.className = value; + } else { + if (value === true) { + dom.setAttribute(attr, attr); + } else if (!isNullOrUndefined(value) && value !== false && !isAttrAnEvent$1(attr)) { + dom.setAttribute(attr, value); } } } +} + +var index = { + createBlueprint: createBlueprint, + createVNode: createVNode, + createVText: createVText, + universal: { + createElement: createUniversalElement + } +}; - var index = { - createBlueprint: createBlueprint, - createVNode: createVNode, - createVText: createVText, - universal: { - createElement: createUniversalElement - } - }; - - return index; +return index; -})); \ No newline at end of file +}))); \ No newline at end of file diff --git a/src/DOM/patching.js b/src/DOM/patching.js index 907c31ed8..81e919adb 100644 --- a/src/DOM/patching.js +++ b/src/DOM/patching.js @@ -109,7 +109,7 @@ export function patch(lastInput, nextInput, parentDom, lifecycle, context, insta } export function patchTextNode(dom, lastChildren, nextChildren) { - if (isStringOrNumber(lastChildren)) { + if (isStringOrNumber(lastChildren) && lastChildren !== '') { dom.firstChild.nodeValue = nextChildren; } else { dom.textContent = nextChildren; From 70e6a84bb3d63c2d6ea17a289c202da9c7c0e960 Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Thu, 8 Sep 2016 13:03:49 +0100 Subject: [PATCH 4/4] updated build and version --- README.md | 14 +++--- config/rollup.config.js | 2 +- package.json | 2 +- packages/inferno-compat/package.json | 4 +- packages/inferno-component/package.json | 4 +- packages/inferno-create-class/package.json | 4 +- packages/inferno-create-element/package.json | 4 +- packages/inferno-dom/package.json | 4 +- packages/inferno-redux/package.json | 4 +- packages/inferno-router/package.json | 4 +- packages/inferno-server/package.json | 4 +- packages/inferno-test-utils/package.json | 4 +- packages/inferno/dist/inferno-compat.js | 2 +- packages/inferno/dist/inferno-component.js | 2 +- packages/inferno/dist/inferno-create-class.js | 2 +- .../inferno/dist/inferno-create-element.js | 2 +- packages/inferno/dist/inferno-dom.js | 2 +- packages/inferno/dist/inferno-redux.js | 50 +++++++------------ packages/inferno/dist/inferno-redux.min.js | 2 +- packages/inferno/dist/inferno-router.js | 2 +- packages/inferno/dist/inferno-server.js | 2 +- packages/inferno/dist/inferno-server.min.js | 2 +- packages/inferno/dist/inferno-test-utils.js | 2 +- packages/inferno/dist/inferno.js | 2 +- packages/inferno/package.json | 2 +- 25 files changed, 58 insertions(+), 70 deletions(-) diff --git a/README.md b/README.md index e18e0fe2e..d5e60b4cb 100755 --- a/README.md +++ b/README.md @@ -83,13 +83,13 @@ npm install --save inferno-router Pre-bundled files for browser consumption can be found on [our cdnjs](https://cdnjs.com/libraries/inferno): ``` -https://cdnjs.cloudflare.com/ajax/libs/inferno/0.7.26/inferno.min.js -https://cdnjs.cloudflare.com/ajax/libs/inferno/0.7.26/inferno-create-element.min.js -https://cdnjs.cloudflare.com/ajax/libs/inferno/0.7.26/inferno-create-class.min.js -https://cdnjs.cloudflare.com/ajax/libs/inferno/0.7.26/inferno-component.min.js -https://cdnjs.cloudflare.com/ajax/libs/inferno/0.7.26/inferno-dom.min.js -https://cdnjs.cloudflare.com/ajax/libs/inferno/0.7.26/inferno-server.min.js -https://cdnjs.cloudflare.com/ajax/libs/inferno/0.7.26/inferno-router.min.js +https://cdnjs.cloudflare.com/ajax/libs/inferno/0.7.27/inferno.min.js +https://cdnjs.cloudflare.com/ajax/libs/inferno/0.7.27/inferno-create-element.min.js +https://cdnjs.cloudflare.com/ajax/libs/inferno/0.7.27/inferno-create-class.min.js +https://cdnjs.cloudflare.com/ajax/libs/inferno/0.7.27/inferno-component.min.js +https://cdnjs.cloudflare.com/ajax/libs/inferno/0.7.27/inferno-dom.min.js +https://cdnjs.cloudflare.com/ajax/libs/inferno/0.7.27/inferno-server.min.js +https://cdnjs.cloudflare.com/ajax/libs/inferno/0.7.27/inferno-router.min.js ``` ## Overview diff --git a/config/rollup.config.js b/config/rollup.config.js index 84535a044..ba300bba6 100644 --- a/config/rollup.config.js +++ b/config/rollup.config.js @@ -24,7 +24,7 @@ const plugins = [ }), commonjs({ include: 'node_modules/**', - exclude: '**/*.css' + exclude: ['node_modules/symbol-observable/**', '**/*.css'] }), replace({ 'process.env.NODE_ENV': JSON.stringify('production'), diff --git a/package.json b/package.json index 0e1ff891c..f69a6aa0a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "inferno-src", "license": "MIT", - "version": "0.7.26", + "version": "0.7.27", "author": { "name": "Dominic Gannaway", "email": "dg@domgan.com" diff --git a/packages/inferno-compat/package.json b/packages/inferno-compat/package.json index 955c10e8c..161bf8b9f 100644 --- a/packages/inferno-compat/package.json +++ b/packages/inferno-compat/package.json @@ -1,6 +1,6 @@ { "name": "inferno-compat", - "version": "0.7.26", + "version": "0.7.27", "license": "MIT", "description": "Provides a compatibility with React codebases", "author": { @@ -21,7 +21,7 @@ "user interfaces" ], "dependencies": { - "inferno": "^0.7.26", + "inferno": "^0.7.27", "proptypes": "^0.14.3" } } diff --git a/packages/inferno-component/package.json b/packages/inferno-component/package.json index 903d4efe6..64f07f26d 100644 --- a/packages/inferno-component/package.json +++ b/packages/inferno-component/package.json @@ -1,6 +1,6 @@ { "name": "inferno-component", - "version": "0.7.26", + "version": "0.7.27", "license": "MIT", "description": "Provides ES2015 stateful components (with lifecycle events) to Inferno", "author": { @@ -27,6 +27,6 @@ "rollup" ], "dependencies": { - "inferno": "^0.7.26" + "inferno": "^0.7.27" } } diff --git a/packages/inferno-create-class/package.json b/packages/inferno-create-class/package.json index eec26051c..8e3f73aaf 100644 --- a/packages/inferno-create-class/package.json +++ b/packages/inferno-create-class/package.json @@ -1,6 +1,6 @@ { "name": "inferno-create-class", - "version": "0.7.26", + "version": "0.7.27", "license": "MIT", "description": "Provides a helper to create Inferno Components without needing ES2015", "author": { @@ -21,6 +21,6 @@ "user interfaces" ], "dependencies": { - "inferno": "^0.7.26" + "inferno": "^0.7.27" } } diff --git a/packages/inferno-create-element/package.json b/packages/inferno-create-element/package.json index 2ddda87e9..8d8347664 100644 --- a/packages/inferno-create-element/package.json +++ b/packages/inferno-create-element/package.json @@ -1,6 +1,6 @@ { "name": "inferno-create-element", - "version": "0.7.26", + "version": "0.7.27", "license": "MIT", "description": "Provides methods to create Inferno VNodes", "author": { @@ -21,6 +21,6 @@ "user interfaces" ], "dependencies": { - "inferno": "^0.7.26" + "inferno": "^0.7.27" } } diff --git a/packages/inferno-dom/package.json b/packages/inferno-dom/package.json index f3fdd8ccf..7b908476e 100644 --- a/packages/inferno-dom/package.json +++ b/packages/inferno-dom/package.json @@ -1,6 +1,6 @@ { "name": "inferno-dom", - "version": "0.7.26", + "version": "0.7.27", "license": "MIT", "description": "Provides methods to render DOM nodes from Inferno elements", "author": { @@ -22,6 +22,6 @@ ], "repository": "https://github.com/trueadm/inferno", "dependencies": { - "inferno": "^0.7.26" + "inferno": "^0.7.27" } } diff --git a/packages/inferno-redux/package.json b/packages/inferno-redux/package.json index a1144a740..60d70205c 100644 --- a/packages/inferno-redux/package.json +++ b/packages/inferno-redux/package.json @@ -1,6 +1,6 @@ { "name": "inferno-redux", - "version": "0.7.26", + "version": "0.7.27", "license": "MIT", "description": "Official Inferno bindings for Redux", "author": { @@ -23,6 +23,6 @@ ], "repository": "https://github.com/trueadm/inferno", "dependencies": { - "inferno": "^0.7.26" + "inferno": "^0.7.27" } } diff --git a/packages/inferno-router/package.json b/packages/inferno-router/package.json index 166a7c0ce..efc2d6004 100644 --- a/packages/inferno-router/package.json +++ b/packages/inferno-router/package.json @@ -1,6 +1,6 @@ { "name": "inferno-router", - "version": "0.7.26", + "version": "0.7.27", "license": "MIT", "description": "Provides routing functionality for Inferno", "author": { @@ -23,6 +23,6 @@ ], "repository": "https://github.com/trueadm/inferno", "dependencies": { - "inferno": "^0.7.26" + "inferno": "^0.7.27" } } diff --git a/packages/inferno-server/package.json b/packages/inferno-server/package.json index 2b616d225..3156b5efa 100644 --- a/packages/inferno-server/package.json +++ b/packages/inferno-server/package.json @@ -1,6 +1,6 @@ { "name": "inferno-server", - "version": "0.7.26", + "version": "0.7.27", "license": "MIT", "description": "Provides methods to render HTML strings from Inferno elements", "author": { @@ -28,6 +28,6 @@ "main": "inferno-server.js", "repository": "https://github.com/trueadm/inferno", "dependencies": { - "inferno": "^0.7.26" + "inferno": "^0.7.27" } } diff --git a/packages/inferno-test-utils/package.json b/packages/inferno-test-utils/package.json index 6e524044c..113c5a4b9 100644 --- a/packages/inferno-test-utils/package.json +++ b/packages/inferno-test-utils/package.json @@ -1,6 +1,6 @@ { "name": "inferno-test-utils", - "version": "0.7.26", + "version": "0.7.27", "license": "MIT", "description": "Provides test utilities to help with creating and maintaining tests for Inferno applications", "author": { @@ -20,7 +20,7 @@ "user interfaces" ], "dependencies": { - "inferno": "^0.7.26" + "inferno": "^0.7.27" }, "main": "inferno-test-utils.js", "repository": "https://github.com/trueadm/inferno" diff --git a/packages/inferno/dist/inferno-compat.js b/packages/inferno/dist/inferno-compat.js index a6cde0888..affa5aa72 100644 --- a/packages/inferno/dist/inferno-compat.js +++ b/packages/inferno/dist/inferno-compat.js @@ -1,5 +1,5 @@ /*! - * inferno-compat v0.7.26 + * inferno-compat v0.7.27 * (c) 2016 Dominic Gannaway * Released under the MIT License. */ diff --git a/packages/inferno/dist/inferno-component.js b/packages/inferno/dist/inferno-component.js index 64f394cfd..e08663e05 100644 --- a/packages/inferno/dist/inferno-component.js +++ b/packages/inferno/dist/inferno-component.js @@ -1,5 +1,5 @@ /*! - * inferno-component v0.7.26 + * inferno-component v0.7.27 * (c) 2016 Dominic Gannaway * Released under the MIT License. */ diff --git a/packages/inferno/dist/inferno-create-class.js b/packages/inferno/dist/inferno-create-class.js index c4b045a46..937986f8d 100644 --- a/packages/inferno/dist/inferno-create-class.js +++ b/packages/inferno/dist/inferno-create-class.js @@ -1,5 +1,5 @@ /*! - * inferno-create-class v0.7.26 + * inferno-create-class v0.7.27 * (c) 2016 Dominic Gannaway * Released under the MIT License. */ diff --git a/packages/inferno/dist/inferno-create-element.js b/packages/inferno/dist/inferno-create-element.js index 2b05da439..8ab4493a7 100644 --- a/packages/inferno/dist/inferno-create-element.js +++ b/packages/inferno/dist/inferno-create-element.js @@ -1,5 +1,5 @@ /*! - * inferno-create-element v0.7.26 + * inferno-create-element v0.7.27 * (c) 2016 Dominic Gannaway * Released under the MIT License. */ diff --git a/packages/inferno/dist/inferno-dom.js b/packages/inferno/dist/inferno-dom.js index f9eeb69f0..f75bb8d87 100644 --- a/packages/inferno/dist/inferno-dom.js +++ b/packages/inferno/dist/inferno-dom.js @@ -1,5 +1,5 @@ /*! - * inferno-dom v0.7.26 + * inferno-dom v0.7.27 * (c) 2016 Dominic Gannaway * Released under the MIT License. */ diff --git a/packages/inferno/dist/inferno-redux.js b/packages/inferno/dist/inferno-redux.js index 9bb2d0254..315ee9d0d 100644 --- a/packages/inferno/dist/inferno-redux.js +++ b/packages/inferno/dist/inferno-redux.js @@ -1,5 +1,5 @@ /*! - * inferno-redux v0.7.26 + * inferno-redux v0.7.27 * (c) 2016 Dominic Gannaway * Released under the MIT License. */ @@ -340,20 +340,7 @@ var funcToString = funcProto.toString; /** Used to infer the `Object` constructor. */ var objectCtorString = funcToString.call(Object); -var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {} - -function interopDefault(ex) { - return ex && typeof ex === 'object' && 'default' in ex ? ex['default'] : ex; -} - -function createCommonjsModule(fn, module) { - return module = { exports: {} }, fn(module, module.exports), module.exports; -} - -var ponyfill = createCommonjsModule(function (module) { -'use strict'; - -module.exports = function symbolObservablePonyfill(root) { +function symbolObservablePonyfill(root) { var result; var Symbol = root.Symbol; @@ -370,23 +357,16 @@ module.exports = function symbolObservablePonyfill(root) { return result; }; -}); - -var ponyfill$1 = interopDefault(ponyfill); - - -var require$$0 = Object.freeze({ - default: ponyfill$1 -}); -var index$1 = createCommonjsModule(function (module) { /* global window */ -'use strict'; - -module.exports = interopDefault(require$$0)(commonjsGlobal || window || commonjsGlobal); -}); +var root = undefined; +if (typeof global !== 'undefined') { + root = global; +} else if (typeof window !== 'undefined') { + root = window; +} -interopDefault(index$1); +var result = symbolObservablePonyfill(root); function bindActionCreator(actionCreator, dispatch) { return function () { @@ -511,7 +491,15 @@ var Provider = (function (Component) { return Provider; }(Component)); -var index$2 = createCommonjsModule(function (module) { +function interopDefault(ex) { + return ex && typeof ex === 'object' && 'default' in ex ? ex['default'] : ex; +} + +function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; +} + +var index$1 = createCommonjsModule(function (module) { 'use strict'; var INFERNO_STATICS = { @@ -561,7 +549,7 @@ function hoistNonReactStatics(targetComponent, sourceComponent, customStatics) { module.exports = hoistNonReactStatics; }); -var hoistStatics = interopDefault(index$2); +var hoistStatics = interopDefault(index$1); var invariant = createCommonjsModule(function (module) { /** diff --git a/packages/inferno/dist/inferno-redux.min.js b/packages/inferno/dist/inferno-redux.min.js index 2ad1c1b52..264734560 100644 --- a/packages/inferno/dist/inferno-redux.min.js +++ b/packages/inferno/dist/inferno-redux.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.InfernoRedux=e()}(this,function(){"use strict";function t(t){return e(t)?t:t?[t]:t}function e(t){return t instanceof Array}function n(t){return i(t)||r(t)}function o(t){return"function"==typeof t}function r(t){return null===t}function i(t){return void 0===t}function s(t){this.bp=t,this.dom=null,this.instance=null,this.tag=null,this.children=null,this.style=null,this.className=null,this.attrs=null,this.events=null,this.hooks=null,this.key=null,this.clipData=null}function a(t){return new s(t)}function p(){this.placeholder=!0,this.dom=null}function u(){return new p}function c(t,e,n){t.split(",").forEach(function(t){return e[t]=n})}function l(){this._listeners=[],this.scrollX=null,this.scrollY=null,this.screenHeight=I,this.screenWidth=j}function h(){return document.activeElement}function d(t){t!==document.body&&document.activeElement!==t&&t.focus()}function f(t,e,n){for(var o in e)t._pendingState[o]=e[o];t._pendingSetState?(t.state=Object.assign({},t.state,t._pendingState),t._pendingState={}):(t._pendingSetState=!0,m(t,!1,n))}function m(t,e,o){if((!t._deferSetState||e)&&!t._blockRender){t._pendingSetState=!1;var r=t._pendingState,i=t.state,s=Object.assign({},i,r),a=t.props;t._pendingState={};var p=t._updateComponent(i,s,a,a,e);p===x?p=t._lastNode:n(p)&&(p=u());var c=t._lastNode,f=c.dom.parentNode,m=h(),y=new l;t._patch(c,p,f,y,t.context,t,null),t._lastNode=p,t._componentToDOMNodeMap.set(t,p.dom),t._parentNode.dom=p.dom,t.componentDidUpdate(a,i),y.trigger(),n(o)||o(),d(m)}}function y(t){return t&&"object"==typeof t&&"default"in t?t.default:t}function g(t,e){return e={exports:{}},t(e,e.exports),e.exports}function v(t,e){return function(){return e(t.apply(void 0,arguments))}}function w(t,e){if("function"==typeof t)return v(t,e);if("object"!=typeof t||null===t)throw new Error("bindActionCreators expected an object or a function, instead received "+(null===t?"null":typeof t)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');for(var n=Object.keys(t),o={},r=0;r, or explicitly pass "store" as a prop to "'+n+'".');var o=this.store.getState();this.state={storeState:o},this.clearCache()}return r&&(u.__proto__=r),u.prototype=Object.create(r&&r.prototype),u.prototype.constructor=u,u.prototype.shouldComponentUpdate=function(){return!c||this.haveOwnPropsChanged||this.hasStoreStateChanged},u.prototype.computeStateProps=function(t,e){if(!this.finalMapStateToProps)return this.configureFinalMapState(t,e);var n=t.getState(),o=this.doStatePropsDependOnOwnProps?this.finalMapStateToProps(n,e):this.finalMapStateToProps(n);return o},u.prototype.configureFinalMapState=function(t,e){var n=p(t.getState(),e),r=o(n);return this.finalMapStateToProps=r?n:p,this.doStatePropsDependOnOwnProps=1!==this.finalMapStateToProps.length,r?this.computeStateProps(t,e):n},u.prototype.computeDispatchProps=function(t,e){if(!this.finalMapDispatchToProps)return this.configureFinalMapDispatch(t,e);var n=t.dispatch,o=this.doDispatchPropsDependOnOwnProps?this.finalMapDispatchToProps(n,e):this.finalMapDispatchToProps(n);return o},u.prototype.configureFinalMapDispatch=function(t,e){var n=i(t.dispatch,e),r=o(n);return this.finalMapDispatchToProps=r?n:i,this.doDispatchPropsDependOnOwnProps=1!==this.finalMapDispatchToProps.length,r?this.computeDispatchProps(t,e):n},u.prototype.updateStatePropsIfNeeded=function(){var t=this.computeStateProps(this.store,this.props);return(!this.stateProps||!P(t,this.stateProps))&&(this.stateProps=t,!0)},u.prototype.updateDispatchPropsIfNeeded=function(){var t=this.computeDispatchProps(this.store,this.props);return(!this.dispatchProps||!P(t,this.dispatchProps))&&(this.dispatchProps=t,!0)},u.prototype.updateMergedPropsIfNeeded=function(){var t=e(this.stateProps,this.dispatchProps,this.props);return!(this.mergedProps&&h&&P(t,this.mergedProps))&&(this.mergedProps=t,!0)},u.prototype.isSubscribed=function(){return o(this.unsubscribe)},u.prototype.trySubscribe=function(){s&&!this.unsubscribe&&(this.unsubscribe=this.store.subscribe(this.handleChange.bind(this)),this.handleChange())},u.prototype.tryUnsubscribe=function(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)},u.prototype.componentDidMount=function(){this.trySubscribe()},u.prototype.componentWillReceiveProps=function(t){c&&P(t,this.props)||(this.haveOwnPropsChanged=!0)},u.prototype.componentWillUnmount=function(){this.tryUnsubscribe(),this.clearCache()},u.prototype.clearCache=function(){this.dispatchProps=null,this.stateProps=null,this.mergedProps=null,this.haveOwnPropsChanged=!0,this.hasStoreStateChanged=!0,this.haveStatePropsBeenPrecalculated=!1,this.statePropsPrecalculationError=null,this.renderedElement=null,this.finalMapDispatchToProps=null,this.finalMapStateToProps=null},u.prototype.handleChange=function(){if(this.unsubscribe){var t=this.store.getState(),e=this.state.storeState;if(!c||e!==t){if(c&&!this.doStatePropsDependOnOwnProps){var n=b(this.updateStatePropsIfNeeded,this);if(!n)return;n===Z&&(this.statePropsPrecalculationError=Z.value),this.haveStatePropsBeenPrecalculated=!0}this.hasStoreStateChanged=!0,this.setState({storeState:t})}}},u.prototype.getWrappedInstance=function(){return this.refs.wrappedInstance},u.prototype.render=function(){var e=this,n=e.haveOwnPropsChanged,o=e.hasStoreStateChanged,r=e.haveStatePropsBeenPrecalculated,i=e.statePropsPrecalculationError,s=e.renderedElement;if(this.haveOwnPropsChanged=!1,this.hasStoreStateChanged=!1,this.haveStatePropsBeenPrecalculated=!1,this.statePropsPrecalculationError=null,i)throw i;var p=!0,u=!0;c&&s&&(p=o||n&&this.doStatePropsDependOnOwnProps,u=n&&this.doDispatchPropsDependOnOwnProps);var h=!1,d=!1;r?h=!0:p&&(h=this.updateStatePropsIfNeeded()),u&&(d=this.updateDispatchPropsIfNeeded());var f=!0;return f=!!(h||d||n)&&this.updateMergedPropsIfNeeded(),!f&&s?s:(l?this.renderedElement=a().setTag(t).setAttrs(Object.assign({},this.mergedProps,{ref:"wrappedInstance"})):this.renderedElement=a().setTag(t).setAttrs(this.mergedProps),this.renderedElement)},u}(F);return r.displayName=n,r.WrappedComponent=t,V(r,t)}}var x="NO_RENDER",C="undefined"!=typeof window&&window.document;s.prototype={setAttrs:function(t){return this.attrs=t,this},setTag:function(t){return this.tag=t,this},setStyle:function(t){return this.style=t,this},setClassName:function(t){return this.className=t,this},setChildren:function(t){return this.children=t,this},setHooks:function(t){return this.hooks=t,this},setEvents:function(t){return this.events=t,this},setKey:function(t){return this.key=t,this}};var D=(C?document.body:null,"http://www.w3.org/1999/xlink"),k="http://www.w3.org/XML/1998/namespace",M={},E={},N={},T={};c("xlink:href,xlink:arcrole,xlink:actuate,xlink:role,xlink:titlef,xlink:type",N,D),c("xml:base,xml:lang,xml:space",N,k),c("volume,value",M,!0),c("muted,scoped,loop,open,checked,default,capture,disabled,selected,readonly,multiple,required,autoplay,controls,seamless,reversed,allowfullscreen,novalidate",E,!0),c("animationIterationCount,borderImageOutset,borderImageSlice,borderImageWidth,boxFlex,boxFlexGroup,boxOrdinalGroup,columnCount,flex,flexGrow,flexPositive,flexShrink,flexNegative,flexOrder,gridRow,gridColumn,fontWeight,lineClamp,lineHeight,opacity,order,orphans,tabSize,widows,zIndex,zoom,fillOpacity,floodOpacity,stopOpacity,strokeDasharray,strokeDashoffset,strokeMiterlimit,strokeOpacity,strokeWidth,",T,!0);var j=C&&window.screen.width,I=C&&window.screen.height,W=0,U=0,R=0;C&&(window.onscroll=function(){W=window.scrollX,U=window.scrollY,R=performance.now()},window.resize=function(){W=window.scrollX,U=window.scrollY,j=window.screen.width,I=window.screen.height,R=performance.now()}),l.prototype={refresh:function(){this.scrollX=C&&window.scrollX,this.scrollY=C&&window.scrollY},addListener:function(t){this._listeners.push(t)},trigger:function(){for(var t=this,e=0;e, or explicitly pass "store" as a prop to "'+n+'".');var o=this.store.getState();this.state={storeState:o},this.clearCache()}return r&&(u.__proto__=r),u.prototype=Object.create(r&&r.prototype),u.prototype.constructor=u,u.prototype.shouldComponentUpdate=function(){return!c||this.haveOwnPropsChanged||this.hasStoreStateChanged},u.prototype.computeStateProps=function(t,e){if(!this.finalMapStateToProps)return this.configureFinalMapState(t,e);var n=t.getState(),o=this.doStatePropsDependOnOwnProps?this.finalMapStateToProps(n,e):this.finalMapStateToProps(n);return o},u.prototype.configureFinalMapState=function(t,e){var n=p(t.getState(),e),r=o(n);return this.finalMapStateToProps=r?n:p,this.doStatePropsDependOnOwnProps=1!==this.finalMapStateToProps.length,r?this.computeStateProps(t,e):n},u.prototype.computeDispatchProps=function(t,e){if(!this.finalMapDispatchToProps)return this.configureFinalMapDispatch(t,e);var n=t.dispatch,o=this.doDispatchPropsDependOnOwnProps?this.finalMapDispatchToProps(n,e):this.finalMapDispatchToProps(n);return o},u.prototype.configureFinalMapDispatch=function(t,e){var n=i(t.dispatch,e),r=o(n);return this.finalMapDispatchToProps=r?n:i,this.doDispatchPropsDependOnOwnProps=1!==this.finalMapDispatchToProps.length,r?this.computeDispatchProps(t,e):n},u.prototype.updateStatePropsIfNeeded=function(){var t=this.computeStateProps(this.store,this.props);return(!this.stateProps||!P(t,this.stateProps))&&(this.stateProps=t,!0)},u.prototype.updateDispatchPropsIfNeeded=function(){var t=this.computeDispatchProps(this.store,this.props);return(!this.dispatchProps||!P(t,this.dispatchProps))&&(this.dispatchProps=t,!0)},u.prototype.updateMergedPropsIfNeeded=function(){var t=e(this.stateProps,this.dispatchProps,this.props);return!(this.mergedProps&&l&&P(t,this.mergedProps))&&(this.mergedProps=t,!0)},u.prototype.isSubscribed=function(){return o(this.unsubscribe)},u.prototype.trySubscribe=function(){s&&!this.unsubscribe&&(this.unsubscribe=this.store.subscribe(this.handleChange.bind(this)),this.handleChange())},u.prototype.tryUnsubscribe=function(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)},u.prototype.componentDidMount=function(){this.trySubscribe()},u.prototype.componentWillReceiveProps=function(t){c&&P(t,this.props)||(this.haveOwnPropsChanged=!0)},u.prototype.componentWillUnmount=function(){this.tryUnsubscribe(),this.clearCache()},u.prototype.clearCache=function(){this.dispatchProps=null,this.stateProps=null,this.mergedProps=null,this.haveOwnPropsChanged=!0,this.hasStoreStateChanged=!0,this.haveStatePropsBeenPrecalculated=!1,this.statePropsPrecalculationError=null,this.renderedElement=null,this.finalMapDispatchToProps=null,this.finalMapStateToProps=null},u.prototype.handleChange=function(){if(this.unsubscribe){var t=this.store.getState(),e=this.state.storeState;if(!c||e!==t){if(c&&!this.doStatePropsDependOnOwnProps){var n=_(this.updateStatePropsIfNeeded,this);if(!n)return;n===V&&(this.statePropsPrecalculationError=V.value),this.haveStatePropsBeenPrecalculated=!0}this.hasStoreStateChanged=!0,this.setState({storeState:t})}}},u.prototype.getWrappedInstance=function(){return this.refs.wrappedInstance},u.prototype.render=function(){var e=this,n=e.haveOwnPropsChanged,o=e.hasStoreStateChanged,r=e.haveStatePropsBeenPrecalculated,i=e.statePropsPrecalculationError,s=e.renderedElement;if(this.haveOwnPropsChanged=!1,this.hasStoreStateChanged=!1,this.haveStatePropsBeenPrecalculated=!1,this.statePropsPrecalculationError=null,i)throw i;var p=!0,u=!0;c&&s&&(p=o||n&&this.doStatePropsDependOnOwnProps,u=n&&this.doDispatchPropsDependOnOwnProps);var l=!1,d=!1;r?l=!0:p&&(l=this.updateStatePropsIfNeeded()),u&&(d=this.updateDispatchPropsIfNeeded());var f=!0;return f=!!(l||d||n)&&this.updateMergedPropsIfNeeded(),!f&&s?s:(h?this.renderedElement=a().setTag(t).setAttrs(Object.assign({},this.mergedProps,{ref:"wrappedInstance"})):this.renderedElement=a().setTag(t).setAttrs(this.mergedProps),this.renderedElement)},u}(X);return r.displayName=n,r.WrappedComponent=t,q(r,t)}}var x="NO_RENDER",D="undefined"!=typeof window&&window.document;s.prototype={setAttrs:function(t){return this.attrs=t,this},setTag:function(t){return this.tag=t,this},setStyle:function(t){return this.style=t,this},setClassName:function(t){return this.className=t,this},setChildren:function(t){return this.children=t,this},setHooks:function(t){return this.hooks=t,this},setEvents:function(t){return this.events=t,this},setKey:function(t){return this.key=t,this}};var k=(D?document.body:null,"http://www.w3.org/1999/xlink"),M="http://www.w3.org/XML/1998/namespace",E={},N={},T={},I={};c("xlink:href,xlink:arcrole,xlink:actuate,xlink:role,xlink:titlef,xlink:type",T,k),c("xml:base,xml:lang,xml:space",T,M),c("volume,value",E,!0),c("muted,scoped,loop,open,checked,default,capture,disabled,selected,readonly,multiple,required,autoplay,controls,seamless,reversed,allowfullscreen,novalidate",N,!0),c("animationIterationCount,borderImageOutset,borderImageSlice,borderImageWidth,boxFlex,boxFlexGroup,boxOrdinalGroup,columnCount,flex,flexGrow,flexPositive,flexShrink,flexNegative,flexOrder,gridRow,gridColumn,fontWeight,lineClamp,lineHeight,opacity,order,orphans,tabSize,widows,zIndex,zoom,fillOpacity,floodOpacity,stopOpacity,strokeDasharray,strokeDashoffset,strokeMiterlimit,strokeOpacity,strokeWidth,",I,!0);var j=D&&window.screen.width,W=D&&window.screen.height,U=0,R=0,A=0;D&&(window.onscroll=function(){U=window.scrollX,R=window.scrollY,A=performance.now()},window.resize=function(){U=window.scrollX,R=window.scrollY,j=window.screen.width,W=window.screen.height,A=performance.now()}),h.prototype={refresh:function(){this.scrollX=D&&window.scrollX,this.scrollY=D&&window.scrollY},addListener:function(t){this._listeners.push(t)},trigger:function(){for(var t=this,e=0;e0||!r)&&(t=t?Object.assign({},t,{children:e}):{children:e})}return t}function n(e){return e instanceof Array}function r(e){return e.prototype&&void 0!==e.prototype.render}function o(e){return s(e)||c(e)}function i(e){return d(e)||l(e)}function u(e){return l(e)||e===!1||e===!0||d(e)}function a(e){return"function"==typeof e}function s(e){return"string"==typeof e}function c(e){return"number"==typeof e}function l(e){return null===e}function p(e){return e===!0}function d(e){return void 0===e}function f(e,t,n){e.split(",").forEach(function(e){return t[e]=n})}function h(e){return(e+"").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}function m(e){return(e+"").replace(/&/g,"&").replace(/"/g,""")}function g(e){return e.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase()}function w(e){return!!K[e]}function v(e,n,o,u,a){if(n=t(o,n),r(e)){var s=new e(n,u),c=s.getChildContext();i(c)||(u=Object.assign({},u,c)),s.context=u,s._pendingSetState=!0,s.componentWillMount();var l=s.render();return s._pendingSetState=!1,b(l,u,a)}return b(e(n,u),u,a)}function y(e,t){if(e&&n(e)){for(var r=[],i=!1,a=0;a"):r.push("")),c&&r.push(h(s)),i=!0):n(s)?(r.push(""),r.push(y(s)),r.push(""),i=!0):(i=!1,r.push(b(s,t,!1)))}return r.join("")}return u(e)?"":o(e)?h(e):b(e,t,!1)||""}function x(e){if(o(e))return e;for(var t=[],n=Object.keys(e),r=0;r0?" "+c.join(" "):"")+">":"<"+s+(c.length>0?" "+c.join(" "):"")+">"+(g||y(e.children,t))+""}}function k(e){return b(e,null,!1)}function S(e){return b(e,null,!0)}function j(e){if(o(e))return e;for(var t=[],n=Object.keys(e),r=0;r"):r.push("")),a&&r.push(h(i)),!0):n(i)?(r.push(""),Promise.resolve(r.renderChildren(i)).then(function(){return r.push(""),!0})):r.renderNode(i,t,!1).then(function(){return!1})})},Promise.resolve(!1))}},s.prototype.renderNative=function(e,t,n,r){var o=this,u=t.bp,a=t.attrs,s=t.className,c=t.style,l=O(u,a);i(s)||l.push('class="'+m(s)+'"'),i(c)||l.push('style="'+j(c)+'"');var p="";if(a&&"dangerouslySetInnerHTML"in a&&(p=a.dangerouslySetInnerHTML.__html),r&&l.push("data-infernoroot"),this.push("<"+e+(l.length>0?" "+l.join(" "):"")+">"),!w(e))return p?(this.push(p),void this.push("")):Promise.resolve(this.renderChildren(t.children,n)).then(function(){o.push("")})},s}(e.Readable),G={renderToString:k,renderToStaticMarkup:S,streamAsString:C,streamAsStaticMarkup:N,RenderStream:F};return G}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("stream")):"function"==typeof define&&define.amd?define(["stream"],t):e.InfernoServer=t(e.stream)}(this,function(e){"use strict";function t(e,t){if(!i(e)){var r=n(e);(r&&e.length>0||!r)&&(t=t?Object.assign({},t,{children:e}):{children:e})}return t}function n(e){return e instanceof Array}function r(e){return e.prototype&&void 0!==e.prototype.render}function o(e){return s(e)||c(e)}function i(e){return d(e)||l(e)}function u(e){return l(e)||e===!1||e===!0||d(e)}function a(e){return"function"==typeof e}function s(e){return"string"==typeof e}function c(e){return"number"==typeof e}function l(e){return null===e}function p(e){return e===!0}function d(e){return void 0===e}function f(e,t,n){e.split(",").forEach(function(e){return t[e]=n})}function h(e){return(e+"").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}function m(e){return(e+"").replace(/&/g,"&").replace(/"/g,""")}function g(e){return e.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase()}function w(e){return!!K[e]}function v(e,n,o,u,a){if(n=t(o,n),r(e)){var s=new e(n,u),c=s.getChildContext();i(c)||(u=Object.assign({},u,c)),s.context=u,s._pendingSetState=!0,s.componentWillMount();var l=s.render();return s._pendingSetState=!1,b(l,u,a)}return b(e(n,u),u,a)}function y(e,t){if(e&&n(e)){for(var r=[],i=!1,a=0;a"):r.push("")),c&&r.push(h(s)),i=!0):n(s)?(r.push(""),r.push(y(s)),r.push(""),i=!0):(i=!1,r.push(b(s,t,!1)))}return r.join("")}return u(e)?"":o(e)?h(e):b(e,t,!1)||""}function x(e){if(o(e))return e;for(var t=[],n=Object.keys(e),r=0;r0?" "+c.join(" "):"")+">":"<"+s+(c.length>0?" "+c.join(" "):"")+">"+(g||y(e.children,t))+""}}function k(e){return b(e,null,!1)}function S(e){return b(e,null,!0)}function j(e){if(o(e))return e;for(var t=[],n=Object.keys(e),r=0;r"):r.push("")),a&&r.push(h(i)),!0):n(i)?(r.push(""),Promise.resolve(r.renderChildren(i)).then(function(){return r.push(""),!0})):r.renderNode(i,t,!1).then(function(){return!1})})},Promise.resolve(!1))}},s.prototype.renderNative=function(e,t,n,r){var o=this,u=t.bp,a=t.attrs,s=t.className,c=t.style,l=O(u,a);i(s)||l.push('class="'+m(s)+'"'),i(c)||l.push('style="'+j(c)+'"');var p="";if(a&&"dangerouslySetInnerHTML"in a&&(p=a.dangerouslySetInnerHTML.__html),r&&l.push("data-infernoroot"),this.push("<"+e+(l.length>0?" "+l.join(" "):"")+">"),!w(e))return p?(this.push(p),void this.push("")):Promise.resolve(this.renderChildren(t.children,n)).then(function(){o.push("")})},s}(e.Readable),G={renderToString:k,renderToStaticMarkup:S,streamAsString:C,streamAsStaticMarkup:N,RenderStream:F};return G}); \ No newline at end of file diff --git a/packages/inferno/dist/inferno-test-utils.js b/packages/inferno/dist/inferno-test-utils.js index ea82803dc..cc396dac1 100644 --- a/packages/inferno/dist/inferno-test-utils.js +++ b/packages/inferno/dist/inferno-test-utils.js @@ -1,5 +1,5 @@ /*! - * inferno-test-utils v0.7.26 + * inferno-test-utils v0.7.27 * (c) 2016 Dominic Gannaway * Released under the MIT License. */ diff --git a/packages/inferno/dist/inferno.js b/packages/inferno/dist/inferno.js index 187b4d81c..1fd206c68 100644 --- a/packages/inferno/dist/inferno.js +++ b/packages/inferno/dist/inferno.js @@ -1,5 +1,5 @@ /*! - * inferno v0.7.26 + * inferno v0.7.27 * (c) 2016 Dominic Gannaway * Released under the MIT License. */ diff --git a/packages/inferno/package.json b/packages/inferno/package.json index abf973cdc..a8e6edbb9 100644 --- a/packages/inferno/package.json +++ b/packages/inferno/package.json @@ -1,6 +1,6 @@ { "name": "inferno", - "version": "0.7.26", + "version": "0.7.27", "license": "MIT", "description": "An extremely fast, isomorphic JavaScript library for building modern user interfaces", "author": {