1 /******/ (function(modules) { // webpackBootstrap
2 /******/ // The module cache
3 /******/ var installedModules = {};
5 /******/ // The require function
6 /******/ function __webpack_require__(moduleId) {
8 /******/ // Check if module is in cache
9 /******/ if(installedModules[moduleId])
10 /******/ return installedModules[moduleId].exports;
12 /******/ // Create a new module (and put it into the cache)
13 /******/ var module = installedModules[moduleId] = {
15 /******/ id: moduleId,
16 /******/ loaded: false
19 /******/ // Execute the module function
20 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22 /******/ // Flag the module as loaded
23 /******/ module.loaded = true;
25 /******/ // Return the exports of the module
26 /******/ return module.exports;
30 /******/ // expose the modules object (__webpack_modules__)
31 /******/ __webpack_require__.m = modules;
33 /******/ // expose the module cache
34 /******/ __webpack_require__.c = installedModules;
36 /******/ // __webpack_public_path__
37 /******/ __webpack_require__.p = "dist";
39 /******/ // Load entry module and return exports
40 /******/ return __webpack_require__(0);
42 /************************************************************************/
45 /***/ function(module, exports, __webpack_require__) {
49 var _inferno = __webpack_require__(1);
51 var _inferno2 = _interopRequireDefault(_inferno);
53 var _infernoComponent = __webpack_require__(3);
55 var _infernoComponent2 = _interopRequireDefault(_infernoComponent);
57 var _share = __webpack_require__(5);
59 var _base = __webpack_require__(6);
61 var _model = __webpack_require__(7);
63 var _model2 = _interopRequireDefault(_model);
65 var _item = __webpack_require__(8);
67 var _item2 = _interopRequireDefault(_item);
69 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
71 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
73 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
75 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
77 var render = _inferno2.default.render;
79 var model = new _model2.default();
81 var App = function (_Component) {
82 _inherits(App, _Component);
85 var _temp, _this, _ret;
87 _classCallCheck(this, App);
89 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
90 args[_key] = arguments[_key];
93 return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.state = {
94 route: (0, _share.read)(),
96 }, _this.update = function (arr) {
97 return _this.setState({ todos: arr });
98 }, _this.componentWillMount = function () {
99 window.onhashchange = function () {
100 return _this.setState({ route: (0, _share.read)() });
102 }, _this.add = function (e) {
103 if (e.which !== _share.ENTER) return;
105 var val = e.target.value.trim();
109 _this.update(model.add(val));
110 }, _this.edit = function (todo, val) {
113 _this.update(model.put(todo, { title: val, editing: 0 }));
117 }, _this.focus = function (todo) {
118 return _this.update(model.put(todo, { editing: 1 }));
119 }, _this.blur = function (todo) {
120 return _this.update(model.put(todo, { editing: 0 }));
121 }, _this.remove = function (todo) {
122 return _this.update(model.del(todo));
123 }, _this.toggleOne = function (todo) {
124 return _this.update(model.toggle(todo));
125 }, _this.toggleAll = function (ev) {
126 return _this.update(model.toggleAll(ev.target.checked));
127 }, _this.clearCompleted = function () {
128 return _this.update(model.clearCompleted());
129 }, _temp), _possibleConstructorReturn(_this, _ret);
132 App.prototype.render = function render(_, _ref) {
135 var todos = _ref.todos,
138 var num = todos.length;
139 var shown = todos.filter(_share.filters[route]);
140 var numDone = todos.filter(_share.filters.completed).length;
141 var numAct = num - numDone;
143 return _inferno2.default.createVNode(2, 'div', null, [_inferno2.default.createVNode(16, _base.Head, {
145 }), num ? _inferno2.default.createVNode(2, 'section', {
147 }, [_inferno2.default.createVNode(512, 'input', {
148 'className': 'toggle-all',
150 'checked': numAct === 0
152 'onClick': this.toggleAll
153 }), _inferno2.default.createVNode(2, 'ul', {
154 'className': 'todo-list'
155 }, shown.map(function (t) {
156 return _inferno2.default.createVNode(16, _item2.default, {
158 'onBlur': function onBlur() {
159 return _this2.blur(t);
161 'onFocus': function onFocus() {
162 return _this2.focus(t);
164 'doDelete': function doDelete() {
165 return _this2.remove(t);
167 'doSave': function doSave(val) {
168 return _this2.edit(t, val);
170 'doToggle': function doToggle() {
171 return _this2.toggleOne(t);
174 }))]) : null, numAct || numDone ? _inferno2.default.createVNode(16, _base.Foot, {
175 'onClear': this.clearCompleted,
183 }(_infernoComponent2.default);
185 render(_inferno2.default.createVNode(16, App), document.getElementById('app'));
189 /***/ function(module, exports, __webpack_require__) {
191 module.exports = __webpack_require__(2);
196 /***/ function(module, exports, __webpack_require__) {
199 * inferno v1.0.0-beta32
200 * (c) 2016 Dominic Gannaway
201 * Released under the MIT License.
203 (function (global, factory) {
204 true ? factory(exports) :
205 typeof define === 'function' && define.amd ? define(['exports'], factory) :
206 (factory((global.Inferno = global.Inferno || {})));
207 }(this, (function (exports) { 'use strict';
209 var NO_OP = '$NO_OP';
210 var ERROR_MSG = 'a runtime error occured! Use Inferno in development environment to find the error.';
211 var isBrowser = typeof window !== 'undefined' && window.document;
213 // this is MUCH faster than .constructor === Array and instanceof Array
214 // in Node 7 and the later versions of V8, slower in older versions though
215 var isArray = Array.isArray;
216 function isStatefulComponent(o) {
217 return !isUndefined(o.prototype) && !isUndefined(o.prototype.render);
219 function isStringOrNumber(obj) {
220 return isString(obj) || isNumber(obj);
222 function isNullOrUndef(obj) {
223 return isUndefined(obj) || isNull(obj);
225 function isInvalid(obj) {
226 return isNull(obj) || obj === false || isTrue(obj) || isUndefined(obj);
228 function isFunction(obj) {
229 return typeof obj === 'function';
231 function isAttrAnEvent(attr) {
232 return attr[0] === 'o' && attr[1] === 'n' && attr.length > 3;
234 function isString(obj) {
235 return typeof obj === 'string';
237 function isNumber(obj) {
238 return typeof obj === 'number';
240 function isNull(obj) {
243 function isTrue(obj) {
246 function isUndefined(obj) {
247 return obj === undefined;
249 function isObject(o) {
250 return typeof o === 'object';
252 function throwError(message) {
256 throw new Error(("Inferno Error: " + message));
258 function warning(condition, message) {
260 console.error(message);
265 function cloneVNode(vNodeToClone, props) {
266 var _children = [], len = arguments.length - 2;
267 while ( len-- > 0 ) _children[ len ] = arguments[ len + 2 ];
269 var children = _children;
270 if (_children.length > 0 && !isNull(_children[0])) {
274 if (_children.length === 1) {
275 children = _children[0];
277 if (isUndefined(props.children)) {
278 props.children = children;
281 if (isArray(children)) {
282 if (isArray(props.children)) {
283 props.children = props.children.concat(children);
286 props.children = [props.children].concat(children);
290 if (isArray(props.children)) {
291 props.children.push(children);
294 props.children = [props.children];
295 props.children.push(children);
301 var flags = vNodeToClone.flags;
302 var events = vNodeToClone.events || (props && props.events) || null;
304 if (isArray(vNodeToClone)) {
305 newVNode = vNodeToClone.map(function (vNode) { return cloneVNode(vNode); });
307 else if (isNullOrUndef(props) && isNullOrUndef(children)) {
308 newVNode = Object.assign({}, vNodeToClone);
311 var key = !isNullOrUndef(vNodeToClone.key) ? vNodeToClone.key : props.key;
312 var ref = vNodeToClone.ref || props.ref;
313 if (flags & 28 /* Component */) {
314 newVNode = createVNode(flags, vNodeToClone.type, Object.assign({}, vNodeToClone.props, props), null, events, key, ref, true);
316 else if (flags & 3970 /* Element */) {
317 children = (props && props.children) || vNodeToClone.children;
318 newVNode = createVNode(flags, vNodeToClone.type, Object.assign({}, vNodeToClone.props, props), children, events, key, ref, !children);
321 if (flags & 28 /* Component */) {
322 var newProps = newVNode.props;
324 var newChildren = newProps.children;
325 // we need to also clone component children that are in props
326 // as the children may also have been hoisted
328 if (isArray(newChildren)) {
329 for (var i = 0; i < newChildren.length; i++) {
330 var child = newChildren[i];
331 if (!isInvalid(child) && isVNode(child)) {
332 newProps.children[i] = cloneVNode(child);
336 else if (isVNode(newChildren)) {
337 newProps.children = cloneVNode(newChildren);
341 newVNode.children = null;
347 function _normalizeVNodes(nodes, result, i) {
348 for (; i < nodes.length; i++) {
351 if (Array.isArray(n)) {
352 _normalizeVNodes(n, result, 0);
355 if (isStringOrNumber(n)) {
356 n = createTextVNode(n);
358 else if (isVNode(n) && n.dom) {
366 function normalizeVNodes(nodes) {
368 // we assign $ which basically means we've flagged this array for future note
369 // if it comes back again, we need to clone it, as people are using it
370 // in an immutable way
373 nodes = nodes.slice();
379 for (var i = 0; i < nodes.length; i++) {
383 newNodes = nodes.slice(0, i);
387 else if (Array.isArray(n)) {
388 var result = (newNodes || nodes).slice(0, i);
389 _normalizeVNodes(nodes, result, i);
392 else if (isStringOrNumber(n)) {
394 newNodes = nodes.slice(0, i);
396 newNodes.push(createTextVNode(n));
398 else if (isVNode(n) && n.dom) {
400 newNodes = nodes.slice(0, i);
402 newNodes.push(cloneVNode(n));
405 newNodes.push(cloneVNode(n));
408 return newNodes || nodes;
410 function normalizeChildren(children) {
411 if (isArray(children)) {
412 return normalizeVNodes(children);
414 else if (isVNode(children) && children.dom) {
415 return cloneVNode(children);
419 function normalizeProps(vNode, props, children) {
420 if (!(vNode.flags & 28 /* Component */) && isNullOrUndef(children) && !isNullOrUndef(props.children)) {
421 vNode.children = props.children;
424 vNode.ref = props.ref;
427 vNode.events = props.events;
429 if (!isNullOrUndef(props.key)) {
430 vNode.key = props.key;
433 function normalize(vNode) {
434 var props = vNode.props;
435 var children = vNode.children;
436 // convert a wrongly created type back to element
437 if (isString(vNode.type) && (vNode.flags & 28 /* Component */)) {
438 vNode.flags = 3970 /* Element */;
441 normalizeProps(vNode, props, children);
443 if (!isInvalid(children)) {
444 vNode.children = normalizeChildren(children);
446 if (props && !isInvalid(props.children)) {
447 props.children = normalizeChildren(props.children);
450 function createVNode(flags, type, props, children, events, key, ref, noNormalise) {
451 if (flags & 16 /* ComponentUnknown */) {
452 flags = isStatefulComponent(type) ? 4 /* ComponentClass */ : 8 /* ComponentFunction */;
455 children: isUndefined(children) ? null : children,
457 events: events || null,
459 key: key === undefined ? null : key,
460 props: props || null,
469 function createVoidVNode() {
470 return createVNode(4096 /* Void */);
472 function createTextVNode(text) {
473 return createVNode(1 /* Text */, null, null, text);
475 function isVNode(o) {
479 var devToolsStatus = {
482 var internalIncrementer = {
485 var componentIdMap = new Map();
486 function getIncrementalId() {
487 return internalIncrementer.id++;
489 function sendToDevTools(global, data) {
490 var event = new CustomEvent('inferno.client.message', {
491 detail: JSON.stringify(data, function (key, val) {
492 if (!isNull(val) && !isUndefined(val)) {
493 if (key === '_vComponent' || !isUndefined(val.nodeType)) {
496 else if (isFunction(val)) {
497 return ("$$f:" + (val.name));
503 global.dispatchEvent(event);
505 function rerenderRoots() {
506 for (var i = 0; i < roots.length; i++) {
508 render(root.input, root.dom);
511 function initDevToolsHooks(global) {
512 global.__INFERNO_DEVTOOLS_GLOBAL_HOOK__ = roots;
513 global.addEventListener('inferno.devtools.message', function (message) {
514 var detail = JSON.parse(message.detail);
515 var type = detail.type;
518 if (!devToolsStatus.connected) {
519 devToolsStatus.connected = true;
530 function sendRoots(global) {
531 sendToDevTools(global, { type: 'roots', data: roots });
534 var Lifecycle = function Lifecycle() {
536 this.fastUnmount = true;
538 Lifecycle.prototype.addListener = function addListener (callback) {
539 this.listeners.push(callback);
541 Lifecycle.prototype.trigger = function trigger () {
544 for (var i = 0; i < this.listeners.length; i++) {
545 this$1.listeners[i]();
549 function constructDefaults(string, object, value) {
550 /* eslint no-return-assign: 0 */
551 string.split(',').forEach(function (i) { return object[i] = value; });
553 var xlinkNS = 'http://www.w3.org/1999/xlink';
554 var xmlNS = 'http://www.w3.org/XML/1998/namespace';
555 var svgNS = 'http://www.w3.org/2000/svg';
556 var strictProps = {};
557 var booleanProps = {};
559 var isUnitlessNumber = {};
561 var dehyphenProps = {
562 textAnchor: 'text-anchor'
564 var delegatedProps = {};
565 constructDefaults('xlink:href,xlink:arcrole,xlink:actuate,xlink:role,xlink:titlef,xlink:type', namespaces, xlinkNS);
566 constructDefaults('xml:base,xml:lang,xml:space', namespaces, xmlNS);
567 constructDefaults('volume,defaultValue,defaultChecked', strictProps, true);
568 constructDefaults('children,ref,key,selected,checked,value,multiple', skipProps, true);
569 constructDefaults('onClick,onMouseDown,onMouseUp,onMouseMove', delegatedProps, true);
570 constructDefaults('muted,scoped,loop,open,checked,default,capture,disabled,readonly,required,autoplay,controls,seamless,reversed,allowfullscreen,novalidate', booleanProps, true);
571 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);
573 var delegatedEvents = new Map();
574 function handleEvent(name, lastEvent, nextEvent, dom) {
575 var delegatedRoots = delegatedEvents.get(name);
577 if (!delegatedRoots) {
578 delegatedRoots = { items: new Map(), count: 0, docEvent: null };
579 var docEvent = attachEventToDocument(name, delegatedRoots);
580 delegatedRoots.docEvent = docEvent;
581 delegatedEvents.set(name, delegatedRoots);
584 delegatedRoots.count++;
586 delegatedRoots.items.set(dom, nextEvent);
588 else if (delegatedRoots) {
589 if (delegatedRoots.items.has(dom)) {
590 delegatedRoots.count--;
591 delegatedRoots.items.delete(dom);
592 if (delegatedRoots.count === 0) {
593 document.removeEventListener(normalizeEventName(name), delegatedRoots.docEvent);
594 delegatedEvents.delete(name);
599 function dispatchEvent(event, dom, items, count, eventData) {
600 var eventsToTrigger = items.get(dom);
601 if (eventsToTrigger) {
605 if (eventsToTrigger.event) {
606 eventsToTrigger.event(eventsToTrigger.data, event);
609 eventsToTrigger(event);
611 if (eventData.stopPropagation) {
615 var parentDom = dom.parentNode;
616 if (count > 0 && (parentDom || parentDom === document.body)) {
617 dispatchEvent(event, parentDom, items, count, eventData);
620 function normalizeEventName(name) {
621 return name.substr(2).toLowerCase();
623 function attachEventToDocument(name, delegatedRoots) {
624 var docEvent = function (event) {
626 stopPropagation: false,
629 // we have to do this as some browsers recycle the same Event between calls
630 // so we need to make the property configurable
631 Object.defineProperty(event, 'currentTarget', {
633 get: function get() {
634 return eventData.dom;
637 event.stopPropagation = function () {
638 eventData.stopPropagation = true;
640 var count = delegatedRoots.count;
642 dispatchEvent(event, event.target, delegatedRoots.items, count, eventData);
645 document.addEventListener(normalizeEventName(name), docEvent);
649 function isCheckedType(type) {
650 return type === 'checkbox' || type === 'radio';
652 function isControlled(props) {
653 var usesChecked = isCheckedType(props.type);
654 return usesChecked ? !isNullOrUndef(props.checked) : !isNullOrUndef(props.value);
656 function onTextInputChange(e) {
657 var vNode = this.vNode;
658 var events = vNode.events || EMPTY_OBJ;
660 if (events.onInput) {
663 else if (events.oninput) {
666 // the user may have updated the vNode from the above onInput events
667 // so we need to get it from the context of `this` again
668 applyValue(this.vNode, dom);
670 function onCheckboxChange(e) {
671 var vNode = this.vNode;
672 var events = vNode.events || EMPTY_OBJ;
674 if (events.onClick) {
677 else if (events.onclick) {
680 // the user may have updated the vNode from the above onClick events
681 // so we need to get it from the context of `this` again
682 applyValue(this.vNode, dom);
684 function handleAssociatedRadioInputs(name) {
685 var inputs = document.querySelectorAll(("input[type=\"radio\"][name=\"" + name + "\"]"));
686 [].forEach.call(inputs, function (dom) {
687 var inputWrapper = wrappers.get(dom);
689 var props = inputWrapper.vNode.props;
691 dom.checked = inputWrapper.vNode.props.checked;
696 function processInput(vNode, dom) {
697 var props = vNode.props || EMPTY_OBJ;
698 applyValue(vNode, dom);
699 if (isControlled(props)) {
700 var inputWrapper = wrappers.get(dom);
705 if (isCheckedType(props.type)) {
706 dom.onclick = onCheckboxChange.bind(inputWrapper);
707 dom.onclick.wrapped = true;
710 dom.oninput = onTextInputChange.bind(inputWrapper);
711 dom.oninput.wrapped = true;
713 wrappers.set(dom, inputWrapper);
715 inputWrapper.vNode = vNode;
718 function applyValue(vNode, dom) {
719 var props = vNode.props || EMPTY_OBJ;
720 var type = props.type;
721 var value = props.value;
722 var checked = props.checked;
723 if (type !== dom.type && type) {
726 if (props.multiple !== dom.multiple) {
727 dom.multiple = props.multiple;
729 if (isCheckedType(type)) {
730 if (!isNullOrUndef(value)) {
733 dom.checked = checked;
734 if (type === 'radio' && props.name) {
735 handleAssociatedRadioInputs(props.name);
739 if (!isNullOrUndef(value) && dom.value !== value) {
742 else if (!isNullOrUndef(checked)) {
743 dom.checked = checked;
748 function isControlled$1(props) {
749 return !isNullOrUndef(props.value);
751 function updateChildOption(vNode, value) {
752 var props = vNode.props || EMPTY_OBJ;
754 // we do this as multiple may have changed
755 dom.value = props.value;
756 if ((isArray(value) && value.indexOf(props.value) !== -1) || props.value === value) {
760 dom.selected = props.selected || false;
763 function onSelectChange(e) {
764 var vNode = this.vNode;
765 var events = vNode.events || EMPTY_OBJ;
767 if (events.onChange) {
770 else if (events.onchange) {
773 // the user may have updated the vNode from the above onChange events
774 // so we need to get it from the context of `this` again
775 applyValue$1(this.vNode, dom);
777 function processSelect(vNode, dom) {
778 var props = vNode.props || EMPTY_OBJ;
779 applyValue$1(vNode, dom);
780 if (isControlled$1(props)) {
781 var selectWrapper = wrappers.get(dom);
782 if (!selectWrapper) {
786 dom.onchange = onSelectChange.bind(selectWrapper);
787 dom.onchange.wrapped = true;
788 wrappers.set(dom, selectWrapper);
790 selectWrapper.vNode = vNode;
793 function applyValue$1(vNode, dom) {
794 var props = vNode.props || EMPTY_OBJ;
795 if (props.multiple !== dom.multiple) {
796 dom.multiple = props.multiple;
798 var children = vNode.children;
799 var value = props.value;
800 if (isArray(children)) {
801 for (var i = 0; i < children.length; i++) {
802 updateChildOption(children[i], value);
805 else if (isVNode(children)) {
806 updateChildOption(children, value);
810 function isControlled$2(props) {
811 return !isNullOrUndef(props.value);
813 function onTextareaInputChange(e) {
814 var vNode = this.vNode;
815 var events = vNode.events || EMPTY_OBJ;
817 if (events.onInput) {
820 else if (events.oninput) {
823 // the user may have updated the vNode from the above onInput events
824 // so we need to get it from the context of `this` again
825 applyValue$2(this.vNode, dom);
827 function processTextarea(vNode, dom) {
828 var props = vNode.props || EMPTY_OBJ;
829 applyValue$2(vNode, dom);
830 var textareaWrapper = wrappers.get(dom);
831 if (isControlled$2(props)) {
832 if (!textareaWrapper) {
836 dom.oninput = onTextareaInputChange.bind(textareaWrapper);
837 dom.oninput.wrapped = true;
838 wrappers.set(dom, textareaWrapper);
840 textareaWrapper.vNode = vNode;
843 function applyValue$2(vNode, dom) {
844 var props = vNode.props || EMPTY_OBJ;
845 var value = props.value;
846 if (dom.value !== value) {
851 var wrappers = new Map();
852 function processElement(flags, vNode, dom) {
853 if (flags & 512 /* InputElement */) {
854 processInput(vNode, dom);
856 else if (flags & 2048 /* SelectElement */) {
857 processSelect(vNode, dom);
859 else if (flags & 1024 /* TextareaElement */) {
860 processTextarea(vNode, dom);
864 function unmount(vNode, parentDom, lifecycle, canRecycle, shallowUnmount, isRecycling) {
865 var flags = vNode.flags;
866 if (flags & 28 /* Component */) {
867 unmountComponent(vNode, parentDom, lifecycle, canRecycle, shallowUnmount, isRecycling);
869 else if (flags & 3970 /* Element */) {
870 unmountElement(vNode, parentDom, lifecycle, canRecycle, shallowUnmount, isRecycling);
872 else if (flags & (1 /* Text */ | 4096 /* Void */)) {
873 unmountVoidOrText(vNode, parentDom);
876 function unmountVoidOrText(vNode, parentDom) {
878 removeChild(parentDom, vNode.dom);
881 function unmountComponent(vNode, parentDom, lifecycle, canRecycle, shallowUnmount, isRecycling) {
882 var instance = vNode.children;
883 var flags = vNode.flags;
884 var isStatefulComponent$$1 = flags & 4;
888 if (!shallowUnmount) {
889 if (isStatefulComponent$$1) {
890 var subLifecycle = instance._lifecycle;
891 if (!subLifecycle.fastUnmount) {
892 unmount(instance._lastInput, null, lifecycle, false, shallowUnmount, isRecycling);
896 if (!lifecycle.fastUnmount) {
897 unmount(instance, null, lifecycle, false, shallowUnmount, isRecycling);
901 if (isStatefulComponent$$1) {
902 instance._ignoreSetState = true;
903 instance.componentWillUnmount();
904 if (ref && !isRecycling) {
907 instance._unmounted = true;
908 findDOMNodeEnabled && componentToDOMNodeMap.delete(instance);
910 else if (!isNullOrUndef(ref)) {
911 if (!isNullOrUndef(ref.onComponentWillUnmount)) {
912 ref.onComponentWillUnmount(dom);
917 var lastInput = instance._lastInput;
918 if (isNullOrUndef(lastInput)) {
919 lastInput = instance;
921 removeChild(parentDom, dom);
923 if (recyclingEnabled && !isStatefulComponent$$1 && (parentDom || canRecycle)) {
924 poolComponent(vNode);
927 function unmountElement(vNode, parentDom, lifecycle, canRecycle, shallowUnmount, isRecycling) {
930 var events = vNode.events;
931 if (!shallowUnmount && !lifecycle.fastUnmount) {
932 if (ref && !isRecycling) {
935 var children = vNode.children;
936 if (!isNullOrUndef(children)) {
937 unmountChildren$1(children, lifecycle, shallowUnmount, isRecycling);
940 if (!isNull(events)) {
941 for (var name in events) {
942 // do not add a hasOwnProperty check here, it affects performance
943 patchEvent(name, events[name], null, dom, lifecycle);
948 removeChild(parentDom, dom);
950 if (recyclingEnabled && (parentDom || canRecycle)) {
954 function unmountChildren$1(children, lifecycle, shallowUnmount, isRecycling) {
955 if (isArray(children)) {
956 for (var i = 0; i < children.length; i++) {
957 var child = children[i];
958 if (!isInvalid(child) && isObject(child)) {
959 unmount(child, null, lifecycle, false, shallowUnmount, isRecycling);
963 else if (isObject(children)) {
964 unmount(children, null, lifecycle, false, shallowUnmount, isRecycling);
967 function unmountRef(ref) {
968 if (isFunction(ref)) {
972 if (isInvalid(ref)) {
976 throwError('string "refs" are not supported in Inferno 1.0. Use callback "refs" instead.');
982 function patch(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG, isRecycling) {
983 if (lastVNode !== nextVNode) {
984 var lastFlags = lastVNode.flags;
985 var nextFlags = nextVNode.flags;
986 if (nextFlags & 28 /* Component */) {
987 if (lastFlags & 28 /* Component */) {
988 patchComponent(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG, nextFlags & 4 /* ComponentClass */, isRecycling);
991 replaceVNode(parentDom, mountComponent(nextVNode, null, lifecycle, context, isSVG, nextFlags & 4 /* ComponentClass */), lastVNode, lifecycle, isRecycling);
994 else if (nextFlags & 3970 /* Element */) {
995 if (lastFlags & 3970 /* Element */) {
996 patchElement(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG, isRecycling);
999 replaceVNode(parentDom, mountElement(nextVNode, null, lifecycle, context, isSVG), lastVNode, lifecycle, isRecycling);
1002 else if (nextFlags & 1 /* Text */) {
1003 if (lastFlags & 1 /* Text */) {
1004 patchText(lastVNode, nextVNode);
1007 replaceVNode(parentDom, mountText(nextVNode, null), lastVNode, lifecycle, isRecycling);
1010 else if (nextFlags & 4096 /* Void */) {
1011 if (lastFlags & 4096 /* Void */) {
1012 patchVoid(lastVNode, nextVNode);
1015 replaceVNode(parentDom, mountVoid(nextVNode, null), lastVNode, lifecycle, isRecycling);
1019 // Error case: mount new one replacing old one
1020 replaceLastChildAndUnmount(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG, isRecycling);
1024 function unmountChildren(children, dom, lifecycle, isRecycling) {
1025 if (isVNode(children)) {
1026 unmount(children, dom, lifecycle, true, false, isRecycling);
1028 else if (isArray(children)) {
1029 removeAllChildren(dom, children, lifecycle, false, isRecycling);
1032 dom.textContent = '';
1035 function patchElement(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG, isRecycling) {
1036 var nextTag = nextVNode.type;
1037 var lastTag = lastVNode.type;
1038 if (lastTag !== nextTag) {
1039 replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG, isRecycling);
1042 var dom = lastVNode.dom;
1043 var lastProps = lastVNode.props;
1044 var nextProps = nextVNode.props;
1045 var lastChildren = lastVNode.children;
1046 var nextChildren = nextVNode.children;
1047 var lastFlags = lastVNode.flags;
1048 var nextFlags = nextVNode.flags;
1049 var lastRef = lastVNode.ref;
1050 var nextRef = nextVNode.ref;
1051 var lastEvents = lastVNode.events;
1052 var nextEvents = nextVNode.events;
1053 nextVNode.dom = dom;
1054 if (isSVG || (nextFlags & 128 /* SvgElement */)) {
1057 if (lastChildren !== nextChildren) {
1058 patchChildren(lastFlags, nextFlags, lastChildren, nextChildren, dom, lifecycle, context, isSVG, isRecycling);
1060 if (!(nextFlags & 2 /* HtmlElement */)) {
1061 processElement(nextFlags, nextVNode, dom);
1063 if (lastProps !== nextProps) {
1064 patchProps(lastProps, nextProps, dom, lifecycle, context, isSVG);
1066 if (lastEvents !== nextEvents) {
1067 patchEvents(lastEvents, nextEvents, dom, lifecycle);
1070 if (lastRef !== nextRef || isRecycling) {
1071 mountRef(dom, nextRef, lifecycle);
1076 function patchChildren(lastFlags, nextFlags, lastChildren, nextChildren, dom, lifecycle, context, isSVG, isRecycling) {
1077 var patchArray = false;
1078 var patchKeyed = false;
1079 if (nextFlags & 64 /* HasNonKeyedChildren */) {
1082 else if ((lastFlags & 32 /* HasKeyedChildren */) && (nextFlags & 32 /* HasKeyedChildren */)) {
1086 else if (isInvalid(nextChildren)) {
1087 unmountChildren(lastChildren, dom, lifecycle, isRecycling);
1089 else if (isInvalid(lastChildren)) {
1090 if (isStringOrNumber(nextChildren)) {
1091 setTextContent(dom, nextChildren);
1094 if (isArray(nextChildren)) {
1095 mountArrayChildren(nextChildren, dom, lifecycle, context, isSVG);
1098 mount(nextChildren, dom, lifecycle, context, isSVG);
1102 else if (isStringOrNumber(nextChildren)) {
1103 if (isStringOrNumber(lastChildren)) {
1104 updateTextContent(dom, nextChildren);
1107 unmountChildren(lastChildren, dom, lifecycle, isRecycling);
1108 setTextContent(dom, nextChildren);
1111 else if (isArray(nextChildren)) {
1112 if (isArray(lastChildren)) {
1114 if (isKeyed(lastChildren, nextChildren)) {
1119 unmountChildren(lastChildren, dom, lifecycle, isRecycling);
1120 mountArrayChildren(nextChildren, dom, lifecycle, context, isSVG);
1123 else if (isArray(lastChildren)) {
1124 removeAllChildren(dom, lastChildren, lifecycle, false, isRecycling);
1125 mount(nextChildren, dom, lifecycle, context, isSVG);
1127 else if (isVNode(nextChildren)) {
1128 if (isVNode(lastChildren)) {
1129 patch(lastChildren, nextChildren, dom, lifecycle, context, isSVG, isRecycling);
1132 unmountChildren(lastChildren, dom, lifecycle, isRecycling);
1133 mount(nextChildren, dom, lifecycle, context, isSVG);
1136 else if (isVNode(lastChildren)) {
1142 patchKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, isSVG, isRecycling);
1145 patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, isSVG, isRecycling);
1149 function patchComponent(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG, isClass, isRecycling) {
1150 var lastType = lastVNode.type;
1151 var nextType = nextVNode.type;
1152 var nextProps = nextVNode.props || EMPTY_OBJ;
1153 var lastKey = lastVNode.key;
1154 var nextKey = nextVNode.key;
1155 if (lastType !== nextType) {
1157 replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG, isRecycling);
1160 var lastInput = lastVNode.children._lastInput || lastVNode.children;
1161 var nextInput = createStatelessComponentInput(nextVNode, nextType, nextProps, context);
1162 patch(lastInput, nextInput, parentDom, lifecycle, context, isSVG, isRecycling);
1163 var dom = nextVNode.dom = nextInput.dom;
1164 nextVNode.children = nextInput;
1165 mountStatelessComponentCallbacks(nextVNode.ref, dom, lifecycle);
1166 unmount(lastVNode, null, lifecycle, false, true, isRecycling);
1171 if (lastKey !== nextKey) {
1172 replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG, isRecycling);
1175 var instance = lastVNode.children;
1176 if (instance._unmounted) {
1177 if (isNull(parentDom)) {
1180 replaceChild(parentDom, mountComponent(nextVNode, null, lifecycle, context, isSVG, nextVNode.flags & 4 /* ComponentClass */), lastVNode.dom);
1183 var defaultProps = nextType.defaultProps;
1184 var lastProps = instance.props;
1185 if (instance._devToolsStatus.connected && !instance._devToolsId) {
1186 componentIdMap.set(instance._devToolsId = getIncrementalId(), instance);
1188 lifecycle.fastUnmount = false;
1189 if (!isUndefined(defaultProps)) {
1190 copyPropsTo(lastProps, nextProps);
1191 nextVNode.props = nextProps;
1193 var lastState = instance.state;
1194 var nextState = instance.state;
1195 var childContext = instance.getChildContext();
1196 nextVNode.children = instance;
1197 instance._isSVG = isSVG;
1198 if (!isNullOrUndef(childContext)) {
1199 childContext = Object.assign({}, context, childContext);
1202 childContext = context;
1204 var lastInput$1 = instance._lastInput;
1205 var nextInput$1 = instance._updateComponent(lastState, nextState, lastProps, nextProps, context, false);
1206 var didUpdate = true;
1207 instance._childContext = childContext;
1208 if (isInvalid(nextInput$1)) {
1209 nextInput$1 = createVoidVNode();
1211 else if (isArray(nextInput$1)) {
1213 throwError('a valid Inferno VNode (or null) must be returned from a component render. You may have returned an array or an invalid object.');
1217 else if (nextInput$1 === NO_OP) {
1218 nextInput$1 = lastInput$1;
1221 else if (isObject(nextInput$1) && nextInput$1.dom) {
1222 nextInput$1 = cloneVNode(nextInput$1);
1224 if (nextInput$1.flags & 28 /* Component */) {
1225 nextInput$1.parentVNode = nextVNode;
1227 else if (lastInput$1.flags & 28 /* Component */) {
1228 lastInput$1.parentVNode = nextVNode;
1230 instance._lastInput = nextInput$1;
1231 instance._vNode = nextVNode;
1233 var fastUnmount = lifecycle.fastUnmount;
1234 var subLifecycle = instance._lifecycle;
1235 lifecycle.fastUnmount = subLifecycle.fastUnmount;
1236 patch(lastInput$1, nextInput$1, parentDom, lifecycle, childContext, isSVG, isRecycling);
1237 subLifecycle.fastUnmount = lifecycle.unmount;
1238 lifecycle.fastUnmount = fastUnmount;
1239 instance.componentDidUpdate(lastProps, lastState);
1240 findDOMNodeEnabled && componentToDOMNodeMap.set(instance, nextInput$1.dom);
1242 nextVNode.dom = nextInput$1.dom;
1246 var shouldUpdate = true;
1247 var lastProps$1 = lastVNode.props;
1248 var nextHooks = nextVNode.ref;
1249 var nextHooksDefined = !isNullOrUndef(nextHooks);
1250 var lastInput$2 = lastVNode.children;
1251 var nextInput$2 = lastInput$2;
1252 nextVNode.dom = lastVNode.dom;
1253 nextVNode.children = lastInput$2;
1254 if (lastKey !== nextKey) {
1255 shouldUpdate = true;
1258 if (nextHooksDefined && !isNullOrUndef(nextHooks.onComponentShouldUpdate)) {
1259 shouldUpdate = nextHooks.onComponentShouldUpdate(lastProps$1, nextProps);
1262 if (shouldUpdate !== false) {
1263 if (nextHooksDefined && !isNullOrUndef(nextHooks.onComponentWillUpdate)) {
1264 lifecycle.fastUnmount = false;
1265 nextHooks.onComponentWillUpdate(lastProps$1, nextProps);
1267 nextInput$2 = nextType(nextProps, context);
1268 if (isInvalid(nextInput$2)) {
1269 nextInput$2 = createVoidVNode();
1271 else if (isArray(nextInput$2)) {
1273 throwError('a valid Inferno VNode (or null) must be returned from a component render. You may have returned an array or an invalid object.');
1277 else if (isObject(nextInput$2) && nextInput$2.dom) {
1278 nextInput$2 = cloneVNode(nextInput$2);
1280 if (nextInput$2 !== NO_OP) {
1281 patch(lastInput$2, nextInput$2, parentDom, lifecycle, context, isSVG, isRecycling);
1282 nextVNode.children = nextInput$2;
1283 if (nextHooksDefined && !isNullOrUndef(nextHooks.onComponentDidUpdate)) {
1284 lifecycle.fastUnmount = false;
1285 nextHooks.onComponentDidUpdate(lastProps$1, nextProps);
1287 nextVNode.dom = nextInput$2.dom;
1290 if (nextInput$2.flags & 28 /* Component */) {
1291 nextInput$2.parentVNode = nextVNode;
1293 else if (lastInput$2.flags & 28 /* Component */) {
1294 lastInput$2.parentVNode = nextVNode;
1300 function patchText(lastVNode, nextVNode) {
1301 var nextText = nextVNode.children;
1302 var dom = lastVNode.dom;
1303 nextVNode.dom = dom;
1304 if (lastVNode.children !== nextText) {
1305 dom.nodeValue = nextText;
1308 function patchVoid(lastVNode, nextVNode) {
1309 nextVNode.dom = lastVNode.dom;
1311 function patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, isSVG, isRecycling) {
1312 var lastChildrenLength = lastChildren.length;
1313 var nextChildrenLength = nextChildren.length;
1314 var commonLength = lastChildrenLength > nextChildrenLength ? nextChildrenLength : lastChildrenLength;
1316 var nextNode = null;
1318 // Loop backwards so we can use insertBefore
1319 if (lastChildrenLength < nextChildrenLength) {
1320 for (i = nextChildrenLength - 1; i >= commonLength; i--) {
1321 var child = nextChildren[i];
1322 if (!isInvalid(child)) {
1324 nextChildren[i] = child = cloneVNode(child);
1326 newNode = mount(child, null, lifecycle, context, isSVG);
1327 insertOrAppend(dom, newNode, nextNode);
1332 else if (nextChildrenLength === 0) {
1333 removeAllChildren(dom, lastChildren, lifecycle, false, isRecycling);
1335 else if (lastChildrenLength > nextChildrenLength) {
1336 for (i = commonLength; i < lastChildrenLength; i++) {
1337 var child$1 = lastChildren[i];
1338 if (!isInvalid(child$1)) {
1339 unmount(lastChildren[i], dom, lifecycle, false, false, isRecycling);
1343 for (i = commonLength - 1; i >= 0; i--) {
1344 var lastChild = lastChildren[i];
1345 var nextChild = nextChildren[i];
1346 if (isInvalid(nextChild)) {
1347 if (!isInvalid(lastChild)) {
1348 unmount(lastChild, dom, lifecycle, true, false, isRecycling);
1352 if (nextChild.dom) {
1353 nextChildren[i] = nextChild = cloneVNode(nextChild);
1355 if (isInvalid(lastChild)) {
1356 newNode = mount(nextChild, null, lifecycle, context, isSVG);
1357 insertOrAppend(dom, newNode, nextNode);
1361 patch(lastChild, nextChild, dom, lifecycle, context, isSVG, isRecycling);
1362 nextNode = nextChild.dom;
1367 function patchKeyedChildren(a, b, dom, lifecycle, context, isSVG, isRecycling) {
1368 var aLength = a.length;
1369 var bLength = b.length;
1370 var aEnd = aLength - 1;
1371 var bEnd = bLength - 1;
1381 if (aLength === 0) {
1382 if (bLength !== 0) {
1383 mountArrayChildren(b, dom, lifecycle, context, isSVG);
1387 else if (bLength === 0) {
1388 removeAllChildren(dom, a, lifecycle, false, isRecycling);
1391 var aStartNode = a[aStart];
1392 var bStartNode = b[bStart];
1393 var aEndNode = a[aEnd];
1394 var bEndNode = b[bEnd];
1395 if (bStartNode.dom) {
1396 b[bStart] = bStartNode = cloneVNode(bStartNode);
1399 b[bEnd] = bEndNode = cloneVNode(bEndNode);
1402 /* eslint no-constant-condition: 0 */
1403 outer: while (true) {
1404 // Sync nodes with the same key at the beginning.
1405 while (aStartNode.key === bStartNode.key) {
1406 patch(aStartNode, bStartNode, dom, lifecycle, context, isSVG, isRecycling);
1409 if (aStart > aEnd || bStart > bEnd) {
1412 aStartNode = a[aStart];
1413 bStartNode = b[bStart];
1414 if (bStartNode.dom) {
1415 b[bStart] = bStartNode = cloneVNode(bStartNode);
1418 // Sync nodes with the same key at the end.
1419 while (aEndNode.key === bEndNode.key) {
1420 patch(aEndNode, bEndNode, dom, lifecycle, context, isSVG, isRecycling);
1423 if (aStart > aEnd || bStart > bEnd) {
1429 b[bEnd] = bEndNode = cloneVNode(bEndNode);
1432 // Move and sync nodes from right to left.
1433 if (aEndNode.key === bStartNode.key) {
1434 patch(aEndNode, bStartNode, dom, lifecycle, context, isSVG, isRecycling);
1435 insertOrAppend(dom, bStartNode.dom, aStartNode.dom);
1439 bStartNode = b[bStart];
1440 if (bStartNode.dom) {
1441 b[bStart] = bStartNode = cloneVNode(bStartNode);
1445 // Move and sync nodes from left to right.
1446 if (aStartNode.key === bEndNode.key) {
1447 patch(aStartNode, bEndNode, dom, lifecycle, context, isSVG, isRecycling);
1449 nextNode = nextPos < b.length ? b[nextPos].dom : null;
1450 insertOrAppend(dom, bEndNode.dom, nextNode);
1453 aStartNode = a[aStart];
1456 b[bEnd] = bEndNode = cloneVNode(bEndNode);
1462 if (aStart > aEnd) {
1463 if (bStart <= bEnd) {
1465 nextNode = nextPos < b.length ? b[nextPos].dom : null;
1466 while (bStart <= bEnd) {
1469 b[bStart] = node = cloneVNode(node);
1472 insertOrAppend(dom, mount(node, null, lifecycle, context, isSVG), nextNode);
1476 else if (bStart > bEnd) {
1477 while (aStart <= aEnd) {
1478 unmount(a[aStart++], dom, lifecycle, false, false, isRecycling);
1482 aLength = aEnd - aStart + 1;
1483 bLength = bEnd - bStart + 1;
1485 var sources = new Array(bLength);
1486 // Mark all nodes as inserted.
1487 for (i = 0; i < bLength; i++) {
1493 if ((bLength <= 4) || (aLength * bLength <= 16)) {
1494 for (i = aStart; i <= aEnd; i++) {
1496 if (patched < bLength) {
1497 for (j = bStart; j <= bEnd; j++) {
1499 if (aNode.key === bNode.key) {
1500 sources[j - bStart] = i;
1508 b[j] = bNode = cloneVNode(bNode);
1510 patch(aNode, bNode, dom, lifecycle, context, isSVG, isRecycling);
1512 aNullable[i] = null;
1520 var keyIndex = new Map();
1521 for (i = bStart; i <= bEnd; i++) {
1523 keyIndex.set(node.key, i);
1525 for (i = aStart; i <= aEnd; i++) {
1527 if (patched < bLength) {
1528 j = keyIndex.get(aNode.key);
1529 if (!isUndefined(j)) {
1531 sources[j - bStart] = i;
1539 b[j] = bNode = cloneVNode(bNode);
1541 patch(aNode, bNode, dom, lifecycle, context, isSVG, isRecycling);
1543 aNullable[i] = null;
1548 if (aLength === a.length && patched === 0) {
1549 removeAllChildren(dom, a, lifecycle, false, isRecycling);
1550 while (bStart < bLength) {
1553 b[bStart] = node = cloneVNode(node);
1556 insertOrAppend(dom, mount(node, null, lifecycle, context, isSVG), null);
1560 i = aLength - patched;
1562 aNode = aNullable[aStart++];
1563 if (!isNull(aNode)) {
1564 unmount(aNode, dom, lifecycle, false, false, isRecycling);
1569 var seq = lis_algorithm(sources);
1571 for (i = bLength - 1; i >= 0; i--) {
1572 if (sources[i] === -1) {
1576 b[pos] = node = cloneVNode(node);
1579 nextNode = nextPos < b.length ? b[nextPos].dom : null;
1580 insertOrAppend(dom, mount(node, dom, lifecycle, context, isSVG), nextNode);
1583 if (j < 0 || i !== seq[j]) {
1587 nextNode = nextPos < b.length ? b[nextPos].dom : null;
1588 insertOrAppend(dom, node.dom, nextNode);
1596 else if (patched !== bLength) {
1597 for (i = bLength - 1; i >= 0; i--) {
1598 if (sources[i] === -1) {
1602 b[pos] = node = cloneVNode(node);
1605 nextNode = nextPos < b.length ? b[nextPos].dom : null;
1606 insertOrAppend(dom, mount(node, null, lifecycle, context, isSVG), nextNode);
1613 // // https://en.wikipedia.org/wiki/Longest_increasing_subsequence
1614 function lis_algorithm(a) {
1623 for (i = 0; i < a.length; i++) {
1627 j = result[result.length - 1];
1634 v = result.length - 1;
1636 c = ((u + v) / 2) | 0;
1637 if (a[result[c]] < a[i]) {
1644 if (a[i] < a[result[u]]) {
1646 p[i] = result[u - 1];
1659 function patchProp(prop, lastValue, nextValue, dom, isSVG, lifecycle) {
1660 if (skipProps[prop]) {
1663 if (booleanProps[prop]) {
1664 dom[prop] = nextValue ? true : false;
1666 else if (strictProps[prop]) {
1667 var value = isNullOrUndef(nextValue) ? '' : nextValue;
1668 if (dom[prop] !== value) {
1672 else if (isAttrAnEvent(prop)) {
1673 patchEvent(prop, lastValue, nextValue, dom, lifecycle);
1675 else if (lastValue !== nextValue) {
1676 if (isNullOrUndef(nextValue)) {
1677 dom.removeAttribute(prop);
1679 else if (prop === 'className') {
1681 dom.setAttribute('class', nextValue);
1684 dom.className = nextValue;
1687 else if (prop === 'style') {
1688 patchStyle(lastValue, nextValue, dom);
1690 else if (prop === 'dangerouslySetInnerHTML') {
1691 var lastHtml = lastValue && lastValue.__html;
1692 var nextHtml = nextValue && nextValue.__html;
1693 if (lastHtml !== nextHtml) {
1694 if (!isNullOrUndef(nextHtml)) {
1695 dom.innerHTML = nextHtml;
1699 else if (prop !== 'childrenType' && prop !== 'ref' && prop !== 'key') {
1700 var dehyphenProp = dehyphenProps[prop];
1701 var ns = namespaces[prop];
1703 dom.setAttributeNS(ns, dehyphenProp || prop, nextValue);
1706 dom.setAttribute(dehyphenProp || prop, nextValue);
1711 function patchEvents(lastEvents, nextEvents, dom, lifecycle) {
1712 lastEvents = lastEvents || EMPTY_OBJ;
1713 nextEvents = nextEvents || EMPTY_OBJ;
1714 if (nextEvents !== EMPTY_OBJ) {
1715 for (var name in nextEvents) {
1716 // do not add a hasOwnProperty check here, it affects performance
1717 patchEvent(name, lastEvents[name], nextEvents[name], dom, lifecycle);
1720 if (lastEvents !== EMPTY_OBJ) {
1721 for (var name$1 in lastEvents) {
1722 // do not add a hasOwnProperty check here, it affects performance
1723 if (isNullOrUndef(nextEvents[name$1])) {
1724 patchEvent(name$1, lastEvents[name$1], null, dom, lifecycle);
1729 function patchEvent(name, lastValue, nextValue, dom, lifecycle) {
1730 if (lastValue !== nextValue) {
1731 var nameLowerCase = name.toLowerCase();
1732 var domEvent = dom[nameLowerCase];
1733 // if the function is wrapped, that means it's been controlled by a wrapper
1734 if (domEvent && domEvent.wrapped) {
1737 if (delegatedProps[name]) {
1738 lifecycle.fastUnmount = false;
1739 handleEvent(name, lastValue, nextValue, dom);
1742 dom[nameLowerCase] = nextValue;
1746 function patchProps(lastProps, nextProps, dom, lifecycle, context, isSVG) {
1747 lastProps = lastProps || EMPTY_OBJ;
1748 nextProps = nextProps || EMPTY_OBJ;
1749 if (nextProps !== EMPTY_OBJ) {
1750 for (var prop in nextProps) {
1751 // do not add a hasOwnProperty check here, it affects performance
1752 var nextValue = nextProps[prop];
1753 var lastValue = lastProps[prop];
1754 if (isNullOrUndef(nextValue)) {
1755 removeProp(prop, dom);
1758 patchProp(prop, lastValue, nextValue, dom, isSVG, lifecycle);
1762 if (lastProps !== EMPTY_OBJ) {
1763 for (var prop$1 in lastProps) {
1764 // do not add a hasOwnProperty check here, it affects performance
1765 if (isNullOrUndef(nextProps[prop$1])) {
1766 removeProp(prop$1, dom);
1771 // We are assuming here that we come from patchProp routine
1772 // -nextAttrValue cannot be null or undefined
1773 function patchStyle(lastAttrValue, nextAttrValue, dom) {
1774 if (isString(nextAttrValue)) {
1775 dom.style.cssText = nextAttrValue;
1778 for (var style in nextAttrValue) {
1779 // do not add a hasOwnProperty check here, it affects performance
1780 var value = nextAttrValue[style];
1781 if (isNumber(value) && !isUnitlessNumber[style]) {
1782 dom.style[style] = value + 'px';
1785 dom.style[style] = value;
1788 if (!isNullOrUndef(lastAttrValue)) {
1789 for (var style$1 in lastAttrValue) {
1790 if (isNullOrUndef(nextAttrValue[style$1])) {
1791 dom.style[style$1] = '';
1796 function removeProp(prop, dom) {
1797 if (prop === 'className') {
1798 dom.removeAttribute('class');
1800 else if (prop === 'value') {
1803 else if (prop === 'style') {
1804 dom.style.cssText = null;
1805 dom.removeAttribute('style');
1807 else if (delegatedProps[prop]) {
1808 handleEvent(prop, null, null, dom);
1811 dom.removeAttribute(prop);
1815 var recyclingEnabled = true;
1816 var componentPools = new Map();
1817 var elementPools = new Map();
1818 function disableRecycling() {
1819 recyclingEnabled = false;
1820 componentPools.clear();
1821 elementPools.clear();
1824 function recycleElement(vNode, lifecycle, context, isSVG) {
1825 var tag = vNode.type;
1826 var key = vNode.key;
1827 var pools = elementPools.get(tag);
1828 if (!isUndefined(pools)) {
1829 var pool = key === null ? pools.nonKeyed : pools.keyed.get(key);
1830 if (!isUndefined(pool)) {
1831 var recycledVNode = pool.pop();
1832 if (!isUndefined(recycledVNode)) {
1833 patchElement(recycledVNode, vNode, null, lifecycle, context, isSVG, true);
1840 function poolElement(vNode) {
1841 var tag = vNode.type;
1842 var key = vNode.key;
1843 var pools = elementPools.get(tag);
1844 if (isUndefined(pools)) {
1849 elementPools.set(tag, pools);
1852 pools.nonKeyed.push(vNode);
1855 var pool = pools.keyed.get(key);
1856 if (isUndefined(pool)) {
1858 pools.keyed.set(key, pool);
1863 function recycleComponent(vNode, lifecycle, context, isSVG) {
1864 var type = vNode.type;
1865 var key = vNode.key;
1866 var pools = componentPools.get(type);
1867 if (!isUndefined(pools)) {
1868 var pool = key === null ? pools.nonKeyed : pools.keyed.get(key);
1869 if (!isUndefined(pool)) {
1870 var recycledVNode = pool.pop();
1871 if (!isUndefined(recycledVNode)) {
1872 var flags = vNode.flags;
1873 var failed = patchComponent(recycledVNode, vNode, null, lifecycle, context, isSVG, flags & 4 /* ComponentClass */, true);
1882 function poolComponent(vNode) {
1883 var type = vNode.type;
1884 var key = vNode.key;
1885 var hooks = vNode.ref;
1886 var nonRecycleHooks = hooks && (hooks.onComponentWillMount ||
1887 hooks.onComponentWillUnmount ||
1888 hooks.onComponentDidMount ||
1889 hooks.onComponentWillUpdate ||
1890 hooks.onComponentDidUpdate);
1891 if (nonRecycleHooks) {
1894 var pools = componentPools.get(type);
1895 if (isUndefined(pools)) {
1900 componentPools.set(type, pools);
1903 pools.nonKeyed.push(vNode);
1906 var pool = pools.keyed.get(key);
1907 if (isUndefined(pool)) {
1909 pools.keyed.set(key, pool);
1915 function mount(vNode, parentDom, lifecycle, context, isSVG) {
1916 var flags = vNode.flags;
1917 if (flags & 3970 /* Element */) {
1918 return mountElement(vNode, parentDom, lifecycle, context, isSVG);
1920 else if (flags & 28 /* Component */) {
1921 return mountComponent(vNode, parentDom, lifecycle, context, isSVG, flags & 4 /* ComponentClass */);
1923 else if (flags & 4096 /* Void */) {
1924 return mountVoid(vNode, parentDom);
1926 else if (flags & 1 /* Text */) {
1927 return mountText(vNode, parentDom);
1931 throwError(("mount() expects a valid VNode, instead it received an object with the type \"" + (typeof vNode) + "\"."));
1936 function mountText(vNode, parentDom) {
1937 var dom = document.createTextNode(vNode.children);
1940 appendChild(parentDom, dom);
1944 function mountVoid(vNode, parentDom) {
1945 var dom = document.createTextNode('');
1948 appendChild(parentDom, dom);
1952 function mountElement(vNode, parentDom, lifecycle, context, isSVG) {
1953 if (recyclingEnabled) {
1954 var dom$1 = recycleElement(vNode, lifecycle, context, isSVG);
1955 if (!isNull(dom$1)) {
1956 if (!isNull(parentDom)) {
1957 appendChild(parentDom, dom$1);
1962 var tag = vNode.type;
1963 var flags = vNode.flags;
1964 if (isSVG || (flags & 128 /* SvgElement */)) {
1967 var dom = documentCreateElement(tag, isSVG);
1968 var children = vNode.children;
1969 var props = vNode.props;
1970 var events = vNode.events;
1971 var ref = vNode.ref;
1973 if (!isNull(children)) {
1974 if (isStringOrNumber(children)) {
1975 setTextContent(dom, children);
1977 else if (isArray(children)) {
1978 mountArrayChildren(children, dom, lifecycle, context, isSVG);
1980 else if (isVNode(children)) {
1981 mount(children, dom, lifecycle, context, isSVG);
1984 if (!(flags & 2 /* HtmlElement */)) {
1985 processElement(flags, vNode, dom);
1987 if (!isNull(props)) {
1988 for (var prop in props) {
1989 // do not add a hasOwnProperty check here, it affects performance
1990 patchProp(prop, null, props[prop], dom, isSVG, lifecycle);
1993 if (!isNull(events)) {
1994 for (var name in events) {
1995 // do not add a hasOwnProperty check here, it affects performance
1996 patchEvent(name, null, events[name], dom, lifecycle);
2000 mountRef(dom, ref, lifecycle);
2002 if (!isNull(parentDom)) {
2003 appendChild(parentDom, dom);
2007 function mountArrayChildren(children, dom, lifecycle, context, isSVG) {
2008 for (var i = 0; i < children.length; i++) {
2009 var child = children[i];
2010 if (!isInvalid(child)) {
2012 children[i] = child = cloneVNode(child);
2014 mount(children[i], dom, lifecycle, context, isSVG);
2018 function mountComponent(vNode, parentDom, lifecycle, context, isSVG, isClass) {
2019 if (recyclingEnabled) {
2020 var dom$1 = recycleComponent(vNode, lifecycle, context, isSVG);
2021 if (!isNull(dom$1)) {
2022 if (!isNull(parentDom)) {
2023 appendChild(parentDom, dom$1);
2028 var type = vNode.type;
2029 var props = vNode.props || EMPTY_OBJ;
2030 var ref = vNode.ref;
2033 var defaultProps = type.defaultProps;
2034 lifecycle.fastUnmount = false;
2035 if (!isUndefined(defaultProps)) {
2036 copyPropsTo(defaultProps, props);
2037 vNode.props = props;
2039 var instance = createStatefulComponentInstance(vNode, type, props, context, isSVG, devToolsStatus);
2040 var input = instance._lastInput;
2041 var fastUnmount = lifecycle.fastUnmount;
2042 // we store the fastUnmount value, but we set it back to true on the lifecycle
2043 // we do this so we can determine if the component render has a fastUnmount or not
2044 lifecycle.fastUnmount = true;
2045 instance._vNode = vNode;
2046 vNode.dom = dom = mount(input, null, lifecycle, instance._childContext, isSVG);
2047 // we now create a lifecycle for this component and store the fastUnmount value
2048 var subLifecycle = instance._lifecycle = new Lifecycle();
2049 subLifecycle.fastUnmount = lifecycle.fastUnmount;
2050 // we then set the lifecycle fastUnmount value back to what it was before the mount
2051 lifecycle.fastUnmount = fastUnmount;
2052 if (!isNull(parentDom)) {
2053 appendChild(parentDom, dom);
2055 mountStatefulComponentCallbacks(ref, instance, lifecycle);
2056 findDOMNodeEnabled && componentToDOMNodeMap.set(instance, dom);
2057 vNode.children = instance;
2060 var input$1 = createStatelessComponentInput(vNode, type, props, context);
2061 vNode.dom = dom = mount(input$1, null, lifecycle, context, isSVG);
2062 vNode.children = input$1;
2063 mountStatelessComponentCallbacks(ref, dom, lifecycle);
2064 if (!isNull(parentDom)) {
2065 appendChild(parentDom, dom);
2070 function mountStatefulComponentCallbacks(ref, instance, lifecycle) {
2072 if (isFunction(ref)) {
2077 throwError('string "refs" are not supported in Inferno 1.0. Use callback "refs" instead.');
2082 if (!isNull(instance.componentDidMount)) {
2083 lifecycle.addListener(function () {
2084 instance.componentDidMount();
2088 function mountStatelessComponentCallbacks(ref, dom, lifecycle) {
2090 if (!isNullOrUndef(ref.onComponentWillMount)) {
2091 lifecycle.fastUnmount = false;
2092 ref.onComponentWillMount();
2094 if (!isNullOrUndef(ref.onComponentDidMount)) {
2095 lifecycle.fastUnmount = false;
2096 lifecycle.addListener(function () { return ref.onComponentDidMount(dom); });
2100 function mountRef(dom, value, lifecycle) {
2101 if (isFunction(value)) {
2102 lifecycle.fastUnmount = false;
2103 lifecycle.addListener(function () { return value(dom); });
2106 if (isInvalid(value)) {
2110 throwError('string "refs" are not supported in Inferno 1.0. Use callback "refs" instead.');
2116 function copyPropsTo(copyFrom, copyTo) {
2117 for (var prop in copyFrom) {
2118 if (isUndefined(copyTo[prop])) {
2119 copyTo[prop] = copyFrom[prop];
2123 function createStatefulComponentInstance(vNode, Component, props, context, isSVG, devToolsStatus) {
2124 if (isUndefined(context)) {
2127 var instance = new Component(props, context);
2128 instance.context = context;
2129 if (instance.props === EMPTY_OBJ) {
2130 instance.props = props;
2132 instance._patch = patch;
2133 instance._devToolsStatus = devToolsStatus;
2134 if (findDOMNodeEnabled) {
2135 instance._componentToDOMNodeMap = componentToDOMNodeMap;
2137 var childContext = instance.getChildContext();
2138 if (!isNullOrUndef(childContext)) {
2139 instance._childContext = Object.assign({}, context, childContext);
2142 instance._childContext = context;
2144 instance._unmounted = false;
2145 instance._pendingSetState = true;
2146 instance._isSVG = isSVG;
2147 instance.componentWillMount();
2148 instance._beforeRender && instance._beforeRender();
2149 var input = instance.render(props, instance.state, context);
2150 instance._afterRender && instance._afterRender();
2151 if (isArray(input)) {
2153 throwError('a valid Inferno VNode (or null) must be returned from a component render. You may have returned an array or an invalid object.');
2157 else if (isInvalid(input)) {
2158 input = createVoidVNode();
2162 input = cloneVNode(input);
2164 if (input.flags & 28 /* Component */) {
2165 // if we have an input that is also a component, we run into a tricky situation
2166 // where the root vNode needs to always have the correct DOM entry
2167 // so we break monomorphism on our input and supply it our vNode as parentVNode
2168 // we can optimise this in the future, but this gets us out of a lot of issues
2169 input.parentVNode = vNode;
2172 instance._pendingSetState = false;
2173 instance._lastInput = input;
2176 function replaceLastChildAndUnmount(lastInput, nextInput, parentDom, lifecycle, context, isSVG, isRecycling) {
2177 replaceVNode(parentDom, mount(nextInput, null, lifecycle, context, isSVG), lastInput, lifecycle, isRecycling);
2179 function replaceVNode(parentDom, dom, vNode, lifecycle, isRecycling) {
2180 var shallowUnmount = false;
2181 // we cannot cache nodeType here as vNode might be re-assigned below
2182 if (vNode.flags & 28 /* Component */) {
2183 // if we are accessing a stateful or stateless component, we want to access their last rendered input
2184 // accessing their DOM node is not useful to us here
2185 unmount(vNode, null, lifecycle, false, false, isRecycling);
2186 vNode = vNode.children._lastInput || vNode.children;
2187 shallowUnmount = true;
2189 replaceChild(parentDom, dom, vNode.dom);
2190 unmount(vNode, null, lifecycle, false, shallowUnmount, isRecycling);
2192 function createStatelessComponentInput(vNode, component, props, context) {
2193 var input = component(props, context);
2194 if (isArray(input)) {
2196 throwError('a valid Inferno VNode (or null) must be returned from a component render. You may have returned an array or an invalid object.');
2200 else if (isInvalid(input)) {
2201 input = createVoidVNode();
2205 input = cloneVNode(input);
2207 if (input.flags & 28 /* Component */) {
2208 // if we have an input that is also a component, we run into a tricky situation
2209 // where the root vNode needs to always have the correct DOM entry
2210 // so we break monomorphism on our input and supply it our vNode as parentVNode
2211 // we can optimise this in the future, but this gets us out of a lot of issues
2212 input.parentVNode = vNode;
2217 function setTextContent(dom, text) {
2219 dom.textContent = text;
2222 dom.appendChild(document.createTextNode(''));
2225 function updateTextContent(dom, text) {
2226 dom.firstChild.nodeValue = text;
2228 function appendChild(parentDom, dom) {
2229 parentDom.appendChild(dom);
2231 function insertOrAppend(parentDom, newNode, nextNode) {
2232 if (isNullOrUndef(nextNode)) {
2233 appendChild(parentDom, newNode);
2236 parentDom.insertBefore(newNode, nextNode);
2239 function documentCreateElement(tag, isSVG) {
2240 if (isSVG === true) {
2241 return document.createElementNS(svgNS, tag);
2244 return document.createElement(tag);
2247 function replaceWithNewNode(lastNode, nextNode, parentDom, lifecycle, context, isSVG, isRecycling) {
2248 unmount(lastNode, null, lifecycle, false, false, isRecycling);
2249 var dom = mount(nextNode, null, lifecycle, context, isSVG);
2251 replaceChild(parentDom, dom, lastNode.dom);
2253 function replaceChild(parentDom, nextDom, lastDom) {
2255 parentDom = lastDom.parentNode;
2257 parentDom.replaceChild(nextDom, lastDom);
2259 function removeChild(parentDom, dom) {
2260 parentDom.removeChild(dom);
2262 function removeAllChildren(dom, children, lifecycle, shallowUnmount, isRecycling) {
2263 dom.textContent = '';
2264 if (!lifecycle.fastUnmount) {
2265 removeChildren(null, children, lifecycle, shallowUnmount, isRecycling);
2268 function removeChildren(dom, children, lifecycle, shallowUnmount, isRecycling) {
2269 for (var i = 0; i < children.length; i++) {
2270 var child = children[i];
2271 if (!isInvalid(child)) {
2272 unmount(child, dom, lifecycle, true, shallowUnmount, isRecycling);
2276 function isKeyed(lastChildren, nextChildren) {
2277 return nextChildren.length && !isNullOrUndef(nextChildren[0]) && !isNullOrUndef(nextChildren[0].key)
2278 && lastChildren.length && !isNullOrUndef(lastChildren[0]) && !isNullOrUndef(lastChildren[0].key);
2281 function normaliseChildNodes(dom) {
2282 var rawChildNodes = dom.childNodes;
2283 var length = rawChildNodes.length;
2285 while (i < length) {
2286 var rawChild = rawChildNodes[i];
2287 if (rawChild.nodeType === 8) {
2288 if (rawChild.data === '!') {
2289 var placeholder = document.createTextNode('');
2290 dom.replaceChild(placeholder, rawChild);
2294 dom.removeChild(rawChild);
2303 function hydrateComponent(vNode, dom, lifecycle, context, isSVG, isClass) {
2304 var type = vNode.type;
2305 var props = vNode.props || {};
2306 var ref = vNode.ref;
2309 var _isSVG = dom.namespaceURI === svgNS;
2310 var defaultProps = type.defaultProps;
2311 lifecycle.fastUnmount = false;
2312 if (!isUndefined(defaultProps)) {
2313 copyPropsTo(defaultProps, props);
2314 vNode.props = props;
2316 var instance = createStatefulComponentInstance(vNode, type, props, context, _isSVG, devToolsStatus);
2317 var input = instance._lastInput;
2318 var fastUnmount = lifecycle.fastUnmount;
2319 // we store the fastUnmount value, but we set it back to true on the lifecycle
2320 // we do this so we can determine if the component render has a fastUnmount or not
2321 lifecycle.fastUnmount = true;
2322 instance._vComponent = vNode;
2323 instance._vNode = vNode;
2324 hydrate(input, dom, lifecycle, instance._childContext, _isSVG);
2325 var subLifecycle = instance._lifecycle = new Lifecycle();
2326 subLifecycle.fastUnmount = lifecycle.fastUnmount;
2327 // we then set the lifecycle fastUnmount value back to what it was before the mount
2328 lifecycle.fastUnmount = fastUnmount;
2329 mountStatefulComponentCallbacks(ref, instance, lifecycle);
2330 findDOMNodeEnabled && componentToDOMNodeMap.set(instance, dom);
2331 vNode.children = instance;
2334 var input$1 = createStatelessComponentInput(vNode, type, props, context);
2335 hydrate(input$1, dom, lifecycle, context, isSVG);
2336 vNode.children = input$1;
2337 vNode.dom = input$1.dom;
2338 mountStatelessComponentCallbacks(ref, dom, lifecycle);
2341 function hydrateElement(vNode, dom, lifecycle, context, isSVG) {
2342 var tag = vNode.type;
2343 var children = vNode.children;
2344 var props = vNode.props;
2345 var events = vNode.events;
2346 var flags = vNode.flags;
2347 if (isSVG || (flags & 128 /* SvgElement */)) {
2350 if (dom.nodeType !== 1 || dom.tagName.toLowerCase() !== tag) {
2351 var newDom = mountElement(vNode, null, lifecycle, context, isSVG);
2353 replaceChild(dom.parentNode, newDom, dom);
2358 hydrateChildren(children, dom, lifecycle, context, isSVG);
2360 if (!(flags & 2 /* HtmlElement */)) {
2361 processElement(flags, vNode, dom);
2363 for (var prop in props) {
2364 patchProp(prop, null, props[prop], dom, isSVG, lifecycle);
2366 for (var name in events) {
2367 patchEvent(name, null, events[name], dom, lifecycle);
2371 function hydrateChildren(children, dom, lifecycle, context, isSVG) {
2372 normaliseChildNodes(dom);
2373 var domNodes = Array.prototype.slice.call(dom.childNodes);
2374 var childNodeIndex = 0;
2375 if (isArray(children)) {
2376 for (var i = 0; i < children.length; i++) {
2377 var child = children[i];
2378 if (isObject(child) && !isNull(child)) {
2379 hydrate(child, domNodes[childNodeIndex++], lifecycle, context, isSVG);
2383 else if (isObject(children)) {
2384 hydrate(children, dom.firstChild, lifecycle, context, isSVG);
2387 function hydrateText(vNode, dom) {
2388 if (dom.nodeType === 3) {
2389 var newDom = mountText(vNode, null);
2391 replaceChild(dom.parentNode, newDom, dom);
2397 function hydrateVoid(vNode, dom) {
2400 function hydrate(vNode, dom, lifecycle, context, isSVG) {
2402 if (isInvalid(dom)) {
2403 throwError("failed to hydrate. The server-side render doesn't match client side.");
2406 var flags = vNode.flags;
2407 if (flags & 28 /* Component */) {
2408 return hydrateComponent(vNode, dom, lifecycle, context, isSVG, flags & 4 /* ComponentClass */);
2410 else if (flags & 3970 /* Element */) {
2411 return hydrateElement(vNode, dom, lifecycle, context, isSVG);
2413 else if (flags & 1 /* Text */) {
2414 return hydrateText(vNode, dom);
2416 else if (flags & 4096 /* Void */) {
2417 return hydrateVoid(vNode, dom);
2421 throwError(("hydrate() expects a valid VNode, instead it received an object with the type \"" + (typeof vNode) + "\"."));
2426 function hydrateRoot(input, parentDom, lifecycle) {
2427 if (parentDom && parentDom.nodeType === 1 && parentDom.firstChild) {
2428 hydrate(input, parentDom.firstChild, lifecycle, {}, false);
2434 // rather than use a Map, like we did before, we can use an array here
2435 // given there shouldn't be THAT many roots on the page, the difference
2436 // in performance is huge: https://esbench.com/bench/5802a691330ab09900a1a2da
2438 var componentToDOMNodeMap = new Map();
2439 var findDOMNodeEnabled = false;
2440 function enableFindDOMNode() {
2441 findDOMNodeEnabled = true;
2443 function findDOMNode(ref) {
2444 if (!findDOMNodeEnabled) {
2446 throwError('findDOMNode() has been disabled, use enableFindDOMNode() enabled findDOMNode(). Warning this can significantly impact performance!');
2450 var dom = ref && ref.nodeType ? ref : null;
2451 return componentToDOMNodeMap.get(ref) || dom;
2453 function getRoot(dom) {
2454 for (var i = 0; i < roots.length; i++) {
2455 var root = roots[i];
2456 if (root.dom === dom) {
2462 function setRoot(dom, input, lifecycle) {
2466 lifecycle: lifecycle
2469 function removeRoot(root) {
2470 for (var i = 0; i < roots.length; i++) {
2471 if (roots[i] === root) {
2477 var documentBody = isBrowser ? document.body : null;
2478 function render(input, parentDom) {
2479 if (documentBody === parentDom) {
2481 throwError('you cannot render() to the "document.body". Use an empty element as a container instead.');
2485 if (input === NO_OP) {
2488 var root = getRoot(parentDom);
2490 var lifecycle = new Lifecycle();
2491 if (!isInvalid(input)) {
2493 input = cloneVNode(input);
2495 if (!hydrateRoot(input, parentDom, lifecycle)) {
2496 mount(input, parentDom, lifecycle, {}, false);
2498 lifecycle.trigger();
2499 setRoot(parentDom, input, lifecycle);
2503 var lifecycle$1 = root.lifecycle;
2504 lifecycle$1.listeners = [];
2505 if (isNullOrUndef(input)) {
2506 unmount(root.input, parentDom, lifecycle$1, false, false, false);
2511 input = cloneVNode(input);
2513 patch(root.input, input, parentDom, lifecycle$1, {}, false, false);
2515 lifecycle$1.trigger();
2518 if (devToolsStatus.connected) {
2522 function createRenderer() {
2524 return function renderer(lastInput, nextInput) {
2526 parentDom = lastInput;
2528 render(nextInput, parentDom);
2532 function linkEvent(data, event) {
2533 return { data: data, event: event };
2539 NODE_ENV: 'development'
2542 initDevToolsHooks(window);
2546 var testFunc = function testFn() {};
2548 (testFunc.name || testFunc.toString()).indexOf('testFn') !== -1,
2549 'It looks like you\'re using a minified copy of the development build ' +
2550 'of Inferno. When deploying Inferno apps to production, make sure to use ' +
2551 'the production build which skips development warnings and is faster. ' +
2552 'See http://infernojs.org for more details.'
2556 // we duplicate it so it plays nicely with different module loading systems
2558 linkEvent: linkEvent,
2560 createVNode: createVNode,
2563 cloneVNode: cloneVNode,
2565 // used to shared common items between Inferno libs
2567 EMPTY_OBJ: EMPTY_OBJ,
2571 findDOMNode: findDOMNode,
2572 createRenderer: createRenderer,
2573 disableRecycling: disableRecycling,
2574 enableFindDOMNode: enableFindDOMNode
2577 exports['default'] = index;
2578 exports.linkEvent = linkEvent;
2579 exports.createVNode = createVNode;
2580 exports.cloneVNode = cloneVNode;
2581 exports.NO_OP = NO_OP;
2582 exports.EMPTY_OBJ = EMPTY_OBJ;
2583 exports.render = render;
2584 exports.findDOMNode = findDOMNode;
2585 exports.createRenderer = createRenderer;
2586 exports.disableRecycling = disableRecycling;
2587 exports.enableFindDOMNode = enableFindDOMNode;
2589 Object.defineProperty(exports, '__esModule', { value: true });
2596 /***/ function(module, exports, __webpack_require__) {
2598 module.exports = __webpack_require__(4);
2603 /***/ function(module, exports, __webpack_require__) {
2606 * inferno-component v1.0.0-beta32
2607 * (c) 2016 Dominic Gannaway
2608 * Released under the MIT License.
2610 (function (global, factory) {
2611 true ? module.exports = factory(__webpack_require__(2)) :
2612 typeof define === 'function' && define.amd ? define(['inferno'], factory) :
2613 (global.Inferno = global.Inferno || {}, global.Inferno.Component = factory(global.Inferno));
2614 }(this, (function (inferno) { 'use strict';
2616 var ERROR_MSG = 'a runtime error occured! Use Inferno in development environment to find the error.';
2619 // this is MUCH faster than .constructor === Array and instanceof Array
2620 // in Node 7 and the later versions of V8, slower in older versions though
2621 var isArray = Array.isArray;
2624 function isNullOrUndef(obj) {
2625 return isUndefined(obj) || isNull(obj);
2627 function isInvalid(obj) {
2628 return isNull(obj) || obj === false || isTrue(obj) || isUndefined(obj);
2630 function isFunction(obj) {
2631 return typeof obj === 'function';
2636 function isNull(obj) {
2637 return obj === null;
2639 function isTrue(obj) {
2640 return obj === true;
2642 function isUndefined(obj) {
2643 return obj === undefined;
2646 function throwError(message) {
2648 message = ERROR_MSG;
2650 throw new Error(("Inferno Error: " + message));
2653 var Lifecycle = function Lifecycle() {
2654 this.listeners = [];
2655 this.fastUnmount = true;
2657 Lifecycle.prototype.addListener = function addListener (callback) {
2658 this.listeners.push(callback);
2660 Lifecycle.prototype.trigger = function trigger () {
2663 for (var i = 0; i < this.listeners.length; i++) {
2664 this$1.listeners[i]();
2668 var noOp = ERROR_MSG;
2670 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.';
2672 var componentCallbackQueue = new Map();
2673 // when a components root VNode is also a component, we can run into issues
2674 // this will recursively look for vNode.parentNode if the VNode is a component
2675 function updateParentComponentVNodes(vNode, dom) {
2676 if (vNode.flags & 28 /* Component */) {
2677 var parentVNode = vNode.parentVNode;
2679 parentVNode.dom = dom;
2680 updateParentComponentVNodes(parentVNode, dom);
2684 // this is in shapes too, but we don't want to import from shapes as it will pull in a duplicate of createVNode
2685 function createVoidVNode() {
2686 return inferno.createVNode(4096 /* Void */);
2688 function addToQueue(component, force, callback) {
2689 // TODO this function needs to be revised and improved on
2690 var queue = componentCallbackQueue.get(component);
2693 componentCallbackQueue.set(component, queue);
2694 Promise.resolve().then(function () {
2695 applyState(component, force, function () {
2696 for (var i = 0; i < queue.length; i++) {
2700 componentCallbackQueue.delete(component);
2701 component._processingSetState = false;
2705 queue.push(callback);
2708 function queueStateChanges(component, newState, callback) {
2709 if (isFunction(newState)) {
2710 newState = newState(component.state);
2712 for (var stateKey in newState) {
2713 component._pendingState[stateKey] = newState[stateKey];
2715 if (!component._pendingSetState) {
2716 if (component._processingSetState || callback) {
2717 addToQueue(component, false, callback);
2720 component._pendingSetState = true;
2721 component._processingSetState = true;
2722 applyState(component, false, callback);
2723 component._processingSetState = false;
2727 component.state = Object.assign({}, component.state, component._pendingState);
2728 component._pendingState = {};
2731 function applyState(component, force, callback) {
2732 if ((!component._deferSetState || force) && !component._blockRender) {
2733 component._pendingSetState = false;
2734 var pendingState = component._pendingState;
2735 var prevState = component.state;
2736 var nextState = Object.assign({}, prevState, pendingState);
2737 var props = component.props;
2738 var context = component.context;
2739 component._pendingState = {};
2740 var nextInput = component._updateComponent(prevState, nextState, props, props, context, force);
2741 var didUpdate = true;
2742 if (isInvalid(nextInput)) {
2743 nextInput = createVoidVNode();
2745 else if (isArray(nextInput)) {
2747 throwError('a valid Inferno VNode (or null) must be returned from a component render. You may have returned an array or an invalid object.');
2751 else if (nextInput === inferno.NO_OP) {
2752 nextInput = component._lastInput;
2755 var lastInput = component._lastInput;
2756 var parentDom = lastInput.dom.parentNode;
2757 component._lastInput = nextInput;
2759 var subLifecycle = component._lifecycle;
2760 if (!subLifecycle) {
2761 subLifecycle = new Lifecycle();
2764 subLifecycle.listeners = [];
2766 component._lifecycle = subLifecycle;
2767 var childContext = component.getChildContext();
2768 if (!isNullOrUndef(childContext)) {
2769 childContext = Object.assign({}, context, component._childContext, childContext);
2772 childContext = Object.assign({}, context, component._childContext);
2774 component._patch(lastInput, nextInput, parentDom, subLifecycle, childContext, component._isSVG, false);
2775 subLifecycle.trigger();
2776 component.componentDidUpdate(props, prevState);
2778 var vNode = component._vNode;
2779 var dom = vNode.dom = nextInput.dom;
2780 var componentToDOMNodeMap = component._componentToDOMNodeMap;
2781 componentToDOMNodeMap && componentToDOMNodeMap.set(component, nextInput.dom);
2782 updateParentComponentVNodes(vNode, dom);
2783 if (!isNullOrUndef(callback)) {
2788 var Component$1 = function Component$1(props, context) {
2791 this._processingSetState = false;
2792 this._blockRender = false;
2793 this._ignoreSetState = false;
2794 this._blockSetState = false;
2795 this._deferSetState = false;
2796 this._pendingSetState = false;
2797 this._pendingState = {};
2798 this._lastInput = null;
2800 this._unmounted = true;
2801 this._devToolsStatus = null;
2802 this._devToolsId = null;
2803 this._lifecycle = null;
2804 this._childContext = null;
2806 this._isSVG = false;
2807 this._componentToDOMNodeMap = null;
2808 /** @type {object} */
2809 this.props = props || inferno.EMPTY_OBJ;
2810 /** @type {object} */
2811 this.context = context || {};
2812 if (!this.componentDidMount) {
2813 this.componentDidMount = null;
2816 Component$1.prototype.render = function render (nextProps, nextState, nextContext) {
2818 Component$1.prototype.forceUpdate = function forceUpdate (callback) {
2819 if (this._unmounted) {
2822 applyState(this, true, callback);
2824 Component$1.prototype.setState = function setState (newState, callback) {
2825 if (this._unmounted) {
2828 if (!this._blockSetState) {
2829 if (!this._ignoreSetState) {
2830 queueStateChanges(this, newState, callback);
2835 throwError('cannot update state via setState() in componentWillUpdate().');
2840 Component$1.prototype.componentWillMount = function componentWillMount () {
2842 Component$1.prototype.componentDidMount = function componentDidMount () {
2844 Component$1.prototype.componentWillUnmount = function componentWillUnmount () {
2846 Component$1.prototype.componentDidUpdate = function componentDidUpdate (prevProps, prevState, prevContext) {
2848 Component$1.prototype.shouldComponentUpdate = function shouldComponentUpdate (nextProps, nextState, context) {
2851 Component$1.prototype.componentWillReceiveProps = function componentWillReceiveProps (nextProps, context) {
2853 Component$1.prototype.componentWillUpdate = function componentWillUpdate (nextProps, nextState, nextContext) {
2855 Component$1.prototype.getChildContext = function getChildContext () {
2857 Component$1.prototype._updateComponent = function _updateComponent (prevState, nextState, prevProps, nextProps, context, force) {
2858 if (this._unmounted === true) {
2864 if ((prevProps !== nextProps || nextProps === inferno.EMPTY_OBJ) || prevState !== nextState || force) {
2865 if (prevProps !== nextProps || nextProps === inferno.EMPTY_OBJ) {
2866 this._blockRender = true;
2867 this.componentWillReceiveProps(nextProps, context);
2868 this._blockRender = false;
2869 if (this._pendingSetState) {
2870 nextState = Object.assign({}, nextState, this._pendingState);
2871 this._pendingSetState = false;
2872 this._pendingState = {};
2875 var shouldUpdate = this.shouldComponentUpdate(nextProps, nextState, context);
2876 if (shouldUpdate !== false || force) {
2877 this._blockSetState = true;
2878 this.componentWillUpdate(nextProps, nextState, context);
2879 this._blockSetState = false;
2880 this.props = nextProps;
2881 var state = this.state = nextState;
2882 this.context = context;
2883 this._beforeRender && this._beforeRender();
2884 var render = this.render(nextProps, state, context);
2885 this._afterRender && this._afterRender();
2889 return inferno.NO_OP;
2899 /***/ function(module, exports) {
2903 exports.__esModule = true;
2904 exports.read = read;
2905 exports.assign = assign;
2906 exports.isEqual = isEqual;
2908 * Shared funcs/values