diff --git a/packages/inferno/dist/inferno.js b/packages/inferno/dist/inferno.js index 4f57eb6b8..3bd62c407 100644 --- a/packages/inferno/dist/inferno.js +++ b/packages/inferno/dist/inferno.js @@ -1114,7 +1114,7 @@ function patchComponent(lastVNode, nextVNode, parentDom, lifecycle, context, isS var subLifecycle = instance._lifecycle; lifecycle.fastUnmount = subLifecycle.fastUnmount; patch(lastInput$1, nextInput$1, parentDom, lifecycle, childContext, isSVG, isRecycling); - subLifecycle.fastUnmount = lifecycle.unmount; + subLifecycle.fastUnmount = lifecycle.fastUnmount; lifecycle.fastUnmount = fastUnmount; instance.componentDidUpdate(lastProps, lastState); findDOMNodeEnabled && componentToDOMNodeMap.set(instance, nextInput$1.dom); diff --git a/packages/inferno/dist/inferno.min.js b/packages/inferno/dist/inferno.min.js index 8c901bba0..b4b31b77a 100644 --- a/packages/inferno/dist/inferno.min.js +++ b/packages/inferno/dist/inferno.min.js @@ -1 +1 @@ -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.Inferno=e.Inferno||{})}(this,function(e){"use strict";function n(e){return!c(e.prototype)&&!c(e.prototype.render)}function t(e){return a(e)||u(e)}function o(e){return c(e)||f(e)}function r(e){return f(e)||e===!1||d(e)||c(e)}function i(e){return"function"==typeof e}function l(e){return"o"===e[0]&&"n"===e[1]&&e.length>3}function a(e){return"string"==typeof e}function u(e){return"number"==typeof e}function f(e){return null===e}function d(e){return e===!0}function c(e){return void 0===e}function s(e){return"object"==typeof e}function p(e){throw e||(e=gn),new Error("Inferno Error: "+e)}function v(e,n){for(var t=[],i=arguments.length-2;i-- >0;)t[i]=arguments[i+2];var l=t;t.length>0&&!f(t[0])&&(n||(n={}),1===t.length&&(l=t[0]),c(n.children)?n.children=l:kn(l)?kn(n.children)?n.children=n.children.concat(l):n.children=[n.children].concat(l):kn(n.children)?n.children.push(l):(n.children=[n.children],n.children.push(l))),l=null;var a,u=e.flags,d=e.events||n&&n.events||null;if(kn(e))a=e.map(function(e){return v(e)});else if(o(n)&&o(l))a=Object.assign({},e);else{var s=o(e.key)?n.key:e.key,p=e.ref||n.ref;28&u?a=_(u,e.type,Object.assign({},e.props,n),null,d,s,p,!0):3970&u&&(l=n&&n.children||e.children,a=_(u,e.type,Object.assign({},e.props,n),l,d,s,p,!l))}if(28&u){var m=a.props;if(m){var h=m.children;if(h)if(kn(h))for(var g=0;g0&&(l||l===document.body)&&P(e,l,t,o,r)}}function L(e){return e.substr(2).toLowerCase()}function V(e,n){var t=function(e){var t={stopPropagation:!1,dom:document};Object.defineProperty(e,"currentTarget",{configurable:!0,get:function(){return t.dom}}),e.stopPropagation=function(){t.stopPropagation=!0};var o=n.count;o>0&&P(e,e.target,n.items,o,t)};return document.addEventListener(L(e),t),t}function R(e){return"checkbox"===e||"radio"===e}function W(e){var n=R(e.type);return n?!o(e.checked):!o(e.value)}function K(e){var n=this.vNode,t=n.events||wn,o=n.dom;if(t.onInput){var r=t.onInput;r.event?r.event(r.data,e):r(e)}else t.oninput&&t.oninput(e);G(this.vNode,o)}function j(e){var n=this.vNode,t=n.events||wn,o=t.onChange;o.event?o.event(o.data,e):o(e)}function B(e){var n=this.vNode,t=n.events||wn,o=n.dom;if(t.onClick){var r=t.onClick;r.event?r.event(r.data,e):r(e)}else t.onclick&&t.onclick(e);G(this.vNode,o)}function F(e){var n=document.querySelectorAll('input[type="radio"][name="'+e+'"]');[].forEach.call(n,function(e){var n=Vn.get(e);if(n){var t=n.vNode.props;t&&(e.checked=n.vNode.props.checked)}})}function H(e,n){var t=e.props||wn;if(G(e,n),W(t)){var o=Vn.get(n);o||(o={vNode:e},R(t.type)?(n.onclick=B.bind(o),n.onclick.wrapped=!0):(n.oninput=K.bind(o),n.oninput.wrapped=!0),t.onChange&&(n.onchange=j.bind(o),n.onchange.wrapped=!0),Vn.set(n,o)),o.vNode=e}}function G(e,n){var t=e.props||wn,r=t.type,i=t.value,l=t.checked,a=t.multiple;r&&r!==n.type&&(n.type=r),a&&a!==n.multiple&&(n.multiple=a),R(r)?(o(i)||(n.value=i),n.checked=l,"radio"===r&&t.name&&F(t.name)):o(i)||n.value===i?o(l)||(n.checked=l):n.value=i}function z(e){return!o(e.value)}function $(e,n){var t=e.props||wn,o=e.dom;o.value=t.value,kn(n)&&n.indexOf(t.value)!==-1||t.value===n?o.selected=!0:o.selected=t.selected||!1}function q(e){var n=this.vNode,t=n.events||wn,o=n.dom;if(t.onChange){var r=t.onChange;r.event?r.event(r.data,e):r(e)}else t.onchange&&t.onchange(e);Y(this.vNode,o)}function J(e,n){var t=e.props||wn;if(Y(e,n),z(t)){var o=Vn.get(n);o||(o={vNode:e},n.onchange=q.bind(o),n.onchange.wrapped=!0,Vn.set(n,o)),o.vNode=e}}function Y(e,n){var t=e.props||wn;t.multiple!==n.multiple&&(n.multiple=t.multiple);var o=e.children,r=t.value;if(kn(o))for(var i=0;iu?u:a,d=0;du)for(d=f;dk||N>w)break e;_=e[C],b=n[N],b.dom&&(n[N]=b=v(b))}for(;x.key===U.key;){if(ue(x,U,t,o,r,i,l),k--,w--,C>k||N>w)break e;x=e[k],U=n[w],U.dom&&(n[w]=U=v(U))}if(x.key!==b.key){if(_.key!==U.key)break;ue(_,U,t,o,r,i,l),m=w+1,p=mk){if(N<=w)for(m=w+1,p=mw)for(;C<=k;)te(e[C++],t,o,!1,!1,l);else{g=k-C+1,y=w-N+1;var O=e,M=new Array(y);for(a=0;au?I=!0:S=u,s.dom&&(n[u]=s=v(s)),ue(d,s,t,o,r,i,l),E++,O[a]=null;break}}else{var T=new Map;for(a=N;a<=w;a++)h=n[a],T.set(h.key,a);for(a=C;a<=k;a++)d=e[a],Eu?I=!0:S=u,s.dom&&(n[u]=s=v(s)),ue(d,s,t,o,r,i,l),E++,O[a]=null))}if(g===e.length&&0===E)for(Ye(t,e,o,!1,l);N0;)d=O[C++],f(d)||(te(d,t,o,!1,!1,l),a--);if(I){var D=ge(M);for(u=D.length-1,a=y-1;a>=0;a--)M[a]===-1?(S=a+N,h=n[S],h.dom&&(n[S]=h=v(h)),m=S+1,p=m=0;a--)M[a]===-1&&(S=a+N,h=n[S],h.dom&&(n[S]=h=v(h)),m=S+1,p=m0&&(n[o]=t[i-1]),t[i]=o)}for(i=t.length,l=t[i-1];i-- >0;)t[i]=l,l=n[l];return t}function ye(e,n,t,r,i,a){if(!Tn[e])if(In[e])r[e]=!!t;else if(Mn[e]){var u=o(t)?"":t;r[e]!==u&&(r[e]=u)}else if(n!==t)if(l(e))we(e,n,t,r,a);else if(o(t))r.removeAttribute(e);else if("className"===e)i?r.setAttribute("class",t):r.className=t;else if("style"===e)Ne(n,t,r);else if("dangerouslySetInnerHTML"===e){var f=n&&n.__html,d=t&&t.__html;f!==d&&(o(d)||(r.innerHTML=d))}else if("childrenType"!==e&&"ref"!==e&&"key"!==e){var c;Dn[e]?c=Dn[e]:i&&e.match(An)?(c=e.replace(/([a-z])([A-Z]|1)/g,D),Dn[e]=c):c=e;var s=Sn[e];s?r.setAttributeNS(s,c,t):r.setAttribute(c,t)}}function ke(e,n,t,r){if(e=e||wn,n=n||wn,n!==wn)for(var i in n)we(i,e[i],n[i],t,r);if(e!==wn)for(var l in e)o(n[l])&&we(l,e[l],null,t,r)}function we(e,n,t,r,l){if(n!==t){var a=e.toLowerCase(),u=r[a];if(u&&u.wrapped)return;Pn[e]?(l.fastUnmount=!1,A(e,n,t,r)):(i(t)||o(t)||p(),r[a]=t)}}function Ce(e,n,t,r,i,l){if(e=e||wn,n=n||wn,n!==wn)for(var a in n){var u=n[a],f=e[a];o(u)?_e(a,u,t):ye(a,f,u,t,l,r)}if(e!==wn)for(var d in e)o(n[d])&&_e(d,e[d],t)}function Ne(e,n,t){if(a(n))return void(t.style.cssText=n);for(var r in n){var i=n[r];u(i)&&!En[r]?t.style[r]=i+"px":t.style[r]=i}if(!o(e))for(var l in e)o(n[l])&&(t.style[l]="")}function _e(e,n,t){"className"===e?t.removeAttribute("class"):"value"===e?t.value="":"style"===e?t.removeAttribute("style"):l(e)?A(name,n,null,t):t.removeAttribute(e)}function be(){Rn=!1,Wn.clear(),Kn.clear()}function xe(e,n,t,o){var r=e.type,i=e.key,l=Kn.get(r);if(!c(l)){var a=null===i?l.nonKeyed:l.keyed.get(i);if(!c(a)){var u=a.pop();if(!c(u))return de(u,e,null,n,t,o,!0),e.dom}}return null}function Ue(e){var n=e.type,t=e.key,o=Kn.get(n);if(c(o)&&(o={nonKeyed:[],keyed:new Map},Kn.set(n,o)),f(t))o.nonKeyed.push(e);else{var r=o.keyed.get(t);c(r)&&(r=[],o.keyed.set(t,r)),r.push(e)}}function Oe(e,n,t,o){var r=e.type,i=e.key,l=Wn.get(r);if(!c(l)){var a=null===i?l.nonKeyed:l.keyed.get(i);if(!c(a)){var u=a.pop();if(!c(u)){var f=e.flags,d=se(u,e,null,n,t,o,4&f,!0);if(!d)return e.dom}}}return null}function Me(e){var n=e.type,t=e.key,o=e.ref,r=o&&(o.onComponentWillMount||o.onComponentWillUnmount||o.onComponentDidMount||o.onComponentWillUpdate||o.onComponentDidUpdate);if(!r){var i=Wn.get(n);if(c(i)&&(i={nonKeyed:[],keyed:new Map},Wn.set(n,i)),f(t))i.nonKeyed.push(e);else{var l=i.keyed.get(t);c(l)&&(l=[],i.keyed.set(t,l)),l.push(e)}}}function Ie(e,n,t,o,r){var i=e.flags;return 3970&i?Te(e,n,t,o,r):28&i?Ae(e,n,t,o,r,4&i):4096&i?Ee(e,n):1&i?Se(e,n):void p()}function Se(e,n){var t=document.createTextNode(e.children);return e.dom=t,n&&He(n,t),t}function Ee(e,n){var t=document.createTextNode("");return e.dom=t,n&&He(n,t),t}function Te(e,n,o,r,i){if(Rn){var l=xe(e,o,r,i);if(!f(l))return f(n)||He(n,l),l}var a=e.type,u=e.flags;(i||128&u)&&(i=!0);var d=ze(a,i),c=e.children,s=e.props,p=e.events,v=e.ref;if(e.dom=d,f(c)||(t(c)?Be(d,c):kn(c)?De(c,d,o,r,i):U(c)&&Ie(c,d,o,r,i)),2&u||ne(u,e,d),!f(s))for(var m in s)ye(m,null,s[m],d,i,o);if(!f(p))for(var h in p)we(h,null,p[h],d,o);return f(v)||Ve(d,v,o),f(n)||He(n,d),d}function De(e,n,t,o,i){for(var l=0;l3}function a(e){return"string"==typeof e}function u(e){return"number"==typeof e}function f(e){return null===e}function d(e){return e===!0}function c(e){return void 0===e}function s(e){return"object"==typeof e}function p(e){throw e||(e=gn),new Error("Inferno Error: "+e)}function v(e,n){for(var t=[],i=arguments.length-2;i-- >0;)t[i]=arguments[i+2];var l=t;t.length>0&&!f(t[0])&&(n||(n={}),1===t.length&&(l=t[0]),c(n.children)?n.children=l:kn(l)?kn(n.children)?n.children=n.children.concat(l):n.children=[n.children].concat(l):kn(n.children)?n.children.push(l):(n.children=[n.children],n.children.push(l))),l=null;var a,u=e.flags,d=e.events||n&&n.events||null;if(kn(e))a=e.map(function(e){return v(e)});else if(o(n)&&o(l))a=Object.assign({},e);else{var s=o(e.key)?n.key:e.key,p=e.ref||n.ref;28&u?a=_(u,e.type,Object.assign({},e.props,n),null,d,s,p,!0):3970&u&&(l=n&&n.children||e.children,a=_(u,e.type,Object.assign({},e.props,n),l,d,s,p,!l))}if(28&u){var m=a.props;if(m){var h=m.children;if(h)if(kn(h))for(var g=0;g0&&(l||l===document.body)&&P(e,l,t,o,r)}}function L(e){return e.substr(2).toLowerCase()}function V(e,n){var t=function(e){var t={stopPropagation:!1,dom:document};Object.defineProperty(e,"currentTarget",{configurable:!0,get:function(){return t.dom}}),e.stopPropagation=function(){t.stopPropagation=!0};var o=n.count;o>0&&P(e,e.target,n.items,o,t)};return document.addEventListener(L(e),t),t}function R(e){return"checkbox"===e||"radio"===e}function W(e){var n=R(e.type);return n?!o(e.checked):!o(e.value)}function K(e){var n=this.vNode,t=n.events||wn,o=n.dom;if(t.onInput){var r=t.onInput;r.event?r.event(r.data,e):r(e)}else t.oninput&&t.oninput(e);G(this.vNode,o)}function j(e){var n=this.vNode,t=n.events||wn,o=t.onChange;o.event?o.event(o.data,e):o(e)}function B(e){var n=this.vNode,t=n.events||wn,o=n.dom;if(t.onClick){var r=t.onClick;r.event?r.event(r.data,e):r(e)}else t.onclick&&t.onclick(e);G(this.vNode,o)}function F(e){var n=document.querySelectorAll('input[type="radio"][name="'+e+'"]');[].forEach.call(n,function(e){var n=Vn.get(e);if(n){var t=n.vNode.props;t&&(e.checked=n.vNode.props.checked)}})}function H(e,n){var t=e.props||wn;if(G(e,n),W(t)){var o=Vn.get(n);o||(o={vNode:e},R(t.type)?(n.onclick=B.bind(o),n.onclick.wrapped=!0):(n.oninput=K.bind(o),n.oninput.wrapped=!0),t.onChange&&(n.onchange=j.bind(o),n.onchange.wrapped=!0),Vn.set(n,o)),o.vNode=e}}function G(e,n){var t=e.props||wn,r=t.type,i=t.value,l=t.checked,a=t.multiple;r&&r!==n.type&&(n.type=r),a&&a!==n.multiple&&(n.multiple=a),R(r)?(o(i)||(n.value=i),n.checked=l,"radio"===r&&t.name&&F(t.name)):o(i)||n.value===i?o(l)||(n.checked=l):n.value=i}function z(e){return!o(e.value)}function $(e,n){var t=e.props||wn,o=e.dom;o.value=t.value,kn(n)&&n.indexOf(t.value)!==-1||t.value===n?o.selected=!0:o.selected=t.selected||!1}function q(e){var n=this.vNode,t=n.events||wn,o=n.dom;if(t.onChange){var r=t.onChange;r.event?r.event(r.data,e):r(e)}else t.onchange&&t.onchange(e);Y(this.vNode,o)}function J(e,n){var t=e.props||wn;if(Y(e,n),z(t)){var o=Vn.get(n);o||(o={vNode:e},n.onchange=q.bind(o),n.onchange.wrapped=!0,Vn.set(n,o)),o.vNode=e}}function Y(e,n){var t=e.props||wn;t.multiple!==n.multiple&&(n.multiple=t.multiple);var o=e.children,r=t.value;if(kn(o))for(var i=0;iu?u:a,d=0;du)for(d=f;dk||N>w)break e;_=e[C],b=n[N],b.dom&&(n[N]=b=v(b))}for(;x.key===U.key;){if(ue(x,U,t,o,r,i,l),k--,w--,C>k||N>w)break e;x=e[k],U=n[w],U.dom&&(n[w]=U=v(U))}if(x.key!==b.key){if(_.key!==U.key)break;ue(_,U,t,o,r,i,l),m=w+1,p=mk){if(N<=w)for(m=w+1,p=mw)for(;C<=k;)te(e[C++],t,o,!1,!1,l);else{g=k-C+1,y=w-N+1;var O=e,M=new Array(y);for(a=0;au?I=!0:S=u,s.dom&&(n[u]=s=v(s)),ue(d,s,t,o,r,i,l),E++,O[a]=null;break}}else{var T=new Map;for(a=N;a<=w;a++)h=n[a],T.set(h.key,a);for(a=C;a<=k;a++)d=e[a],Eu?I=!0:S=u,s.dom&&(n[u]=s=v(s)),ue(d,s,t,o,r,i,l),E++,O[a]=null))}if(g===e.length&&0===E)for(Ye(t,e,o,!1,l);N0;)d=O[C++],f(d)||(te(d,t,o,!1,!1,l),a--);if(I){var D=ge(M);for(u=D.length-1,a=y-1;a>=0;a--)M[a]===-1?(S=a+N,h=n[S],h.dom&&(n[S]=h=v(h)),m=S+1,p=m=0;a--)M[a]===-1&&(S=a+N,h=n[S],h.dom&&(n[S]=h=v(h)),m=S+1,p=m0&&(n[o]=t[i-1]),t[i]=o)}for(i=t.length,l=t[i-1];i-- >0;)t[i]=l,l=n[l];return t}function ye(e,n,t,r,i,a){if(!Tn[e])if(In[e])r[e]=!!t;else if(Mn[e]){var u=o(t)?"":t;r[e]!==u&&(r[e]=u)}else if(n!==t)if(l(e))we(e,n,t,r,a);else if(o(t))r.removeAttribute(e);else if("className"===e)i?r.setAttribute("class",t):r.className=t;else if("style"===e)Ne(n,t,r);else if("dangerouslySetInnerHTML"===e){var f=n&&n.__html,d=t&&t.__html;f!==d&&(o(d)||(r.innerHTML=d))}else if("childrenType"!==e&&"ref"!==e&&"key"!==e){var c;Dn[e]?c=Dn[e]:i&&e.match(An)?(c=e.replace(/([a-z])([A-Z]|1)/g,D),Dn[e]=c):c=e;var s=Sn[e];s?r.setAttributeNS(s,c,t):r.setAttribute(c,t)}}function ke(e,n,t,r){if(e=e||wn,n=n||wn,n!==wn)for(var i in n)we(i,e[i],n[i],t,r);if(e!==wn)for(var l in e)o(n[l])&&we(l,e[l],null,t,r)}function we(e,n,t,r,l){if(n!==t){var a=e.toLowerCase(),u=r[a];if(u&&u.wrapped)return;Pn[e]?(l.fastUnmount=!1,A(e,n,t,r)):(i(t)||o(t)||p(),r[a]=t)}}function Ce(e,n,t,r,i,l){if(e=e||wn,n=n||wn,n!==wn)for(var a in n){var u=n[a],f=e[a];o(u)?_e(a,u,t):ye(a,f,u,t,l,r)}if(e!==wn)for(var d in e)o(n[d])&&_e(d,e[d],t)}function Ne(e,n,t){if(a(n))return void(t.style.cssText=n);for(var r in n){var i=n[r];u(i)&&!En[r]?t.style[r]=i+"px":t.style[r]=i}if(!o(e))for(var l in e)o(n[l])&&(t.style[l]="")}function _e(e,n,t){"className"===e?t.removeAttribute("class"):"value"===e?t.value="":"style"===e?t.removeAttribute("style"):l(e)?A(name,n,null,t):t.removeAttribute(e)}function be(){Rn=!1,Wn.clear(),Kn.clear()}function xe(e,n,t,o){var r=e.type,i=e.key,l=Kn.get(r);if(!c(l)){var a=null===i?l.nonKeyed:l.keyed.get(i);if(!c(a)){var u=a.pop();if(!c(u))return de(u,e,null,n,t,o,!0),e.dom}}return null}function Ue(e){var n=e.type,t=e.key,o=Kn.get(n);if(c(o)&&(o={nonKeyed:[],keyed:new Map},Kn.set(n,o)),f(t))o.nonKeyed.push(e);else{var r=o.keyed.get(t);c(r)&&(r=[],o.keyed.set(t,r)),r.push(e)}}function Oe(e,n,t,o){var r=e.type,i=e.key,l=Wn.get(r);if(!c(l)){var a=null===i?l.nonKeyed:l.keyed.get(i);if(!c(a)){var u=a.pop();if(!c(u)){var f=e.flags,d=se(u,e,null,n,t,o,4&f,!0);if(!d)return e.dom}}}return null}function Me(e){var n=e.type,t=e.key,o=e.ref,r=o&&(o.onComponentWillMount||o.onComponentWillUnmount||o.onComponentDidMount||o.onComponentWillUpdate||o.onComponentDidUpdate);if(!r){var i=Wn.get(n);if(c(i)&&(i={nonKeyed:[],keyed:new Map},Wn.set(n,i)),f(t))i.nonKeyed.push(e);else{var l=i.keyed.get(t);c(l)&&(l=[],i.keyed.set(t,l)),l.push(e)}}}function Ie(e,n,t,o,r){var i=e.flags;return 3970&i?Te(e,n,t,o,r):28&i?Ae(e,n,t,o,r,4&i):4096&i?Ee(e,n):1&i?Se(e,n):void p()}function Se(e,n){var t=document.createTextNode(e.children);return e.dom=t,n&&He(n,t),t}function Ee(e,n){var t=document.createTextNode("");return e.dom=t,n&&He(n,t),t}function Te(e,n,o,r,i){if(Rn){var l=xe(e,o,r,i);if(!f(l))return f(n)||He(n,l),l}var a=e.type,u=e.flags;(i||128&u)&&(i=!0);var d=ze(a,i),c=e.children,s=e.props,p=e.events,v=e.ref;if(e.dom=d,f(c)||(t(c)?Be(d,c):kn(c)?De(c,d,o,r,i):U(c)&&Ie(c,d,o,r,i)),2&u||ne(u,e,d),!f(s))for(var m in s)ye(m,null,s[m],d,i,o);if(!f(p))for(var h in p)we(h,null,p[h],d,o);return f(v)||Ve(d,v,o),f(n)||He(n,d),d}function De(e,n,t,o,i){for(var l=0;l value(dom)); diff --git a/src/DOM/patching.ts b/src/DOM/patching.ts index 9b2f19bdf..898c5bb2b 100644 --- a/src/DOM/patching.ts +++ b/src/DOM/patching.ts @@ -70,7 +70,7 @@ import { componentToDOMNodeMap, findDOMNodeEnabled } from './rendering'; import processElement from './wrappers/processElement'; import { unmount } from './unmounting'; -export function patch(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG: boolean, isRecycling: boolean) { +export function patch(lastVNode, nextVNode, parentDom, lifecycle: Lifecycle, context, isSVG: boolean, isRecycling: boolean) { if (lastVNode !== nextVNode) { const lastFlags = lastVNode.flags; const nextFlags = nextVNode.flags; @@ -140,7 +140,7 @@ export function patch(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG } } -function unmountChildren(children, dom, lifecycle, isRecycling) { +function unmountChildren(children, dom, lifecycle: Lifecycle, isRecycling: boolean) { if (isVNode(children)) { unmount(children, dom, lifecycle, true, false, isRecycling); } else if (isArray(children)) { @@ -200,7 +200,7 @@ export function patchElement(lastVNode: VNode, nextVNode: VNode, parentDom: Node } } -function patchChildren(lastFlags, nextFlags, lastChildren, nextChildren, dom, lifecycle, context, isSVG, isRecycling) { +function patchChildren(lastFlags: VNodeFlags, nextFlags: VNodeFlags, lastChildren, nextChildren, dom, lifecycle: Lifecycle, context, isSVG: boolean, isRecycling: boolean) { let patchArray = false; let patchKeyed = false; @@ -263,7 +263,7 @@ function patchChildren(lastFlags, nextFlags, lastChildren, nextChildren, dom, li } } -export function patchComponent(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG, isClass, isRecycling: boolean) { +export function patchComponent(lastVNode, nextVNode, parentDom, lifecycle: Lifecycle, context, isSVG: boolean, isClass: number, isRecycling: boolean) { const lastType = lastVNode.type; const nextType = nextVNode.type; const nextProps = nextVNode.props || EMPTY_OBJ; @@ -362,7 +362,7 @@ export function patchComponent(lastVNode, nextVNode, parentDom, lifecycle, conte lifecycle.fastUnmount = subLifecycle.fastUnmount; patch(lastInput, nextInput, parentDom, lifecycle, childContext, isSVG, isRecycling); - subLifecycle.fastUnmount = lifecycle.unmount; + subLifecycle.fastUnmount = lifecycle.fastUnmount; lifecycle.fastUnmount = fastUnmount; instance.componentDidUpdate(lastProps, lastState); findDOMNodeEnabled && componentToDOMNodeMap.set(instance, nextInput.dom); @@ -434,11 +434,11 @@ export function patchText(lastVNode: VNode, nextVNode: VNode) { } } -export function patchVoid(lastVNode, nextVNode) { +export function patchVoid(lastVNode: VNode, nextVNode: VNode) { nextVNode.dom = lastVNode.dom; } -export function patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, isSVG, isRecycling) { +export function patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle: Lifecycle, context, isSVG: boolean, isRecycling: boolean) { let lastChildrenLength = lastChildren.length; let nextChildrenLength = nextChildren.length; let commonLength = lastChildrenLength > nextChildrenLength ? nextChildrenLength : lastChildrenLength; @@ -781,7 +781,7 @@ function lis_algorithm(a) { return result; } -export function patchProp(prop, lastValue, nextValue, dom, isSVG: boolean, lifecycle) { +export function patchProp(prop, lastValue, nextValue, dom, isSVG: boolean, lifecycle: Lifecycle) { if (skipProps[prop]) { return; } @@ -879,7 +879,7 @@ export function patchEvent(name, lastValue, nextValue, dom, lifecycle) { } } -function patchProps(lastProps, nextProps, dom, lifecycle, context, isSVG) { +function patchProps(lastProps, nextProps, dom, lifecycle: Lifecycle, context, isSVG: boolean) { lastProps = lastProps || EMPTY_OBJ; nextProps = nextProps || EMPTY_OBJ; diff --git a/src/DOM/recycling.ts b/src/DOM/recycling.ts index 799e11797..2769dc5f1 100644 --- a/src/DOM/recycling.ts +++ b/src/DOM/recycling.ts @@ -7,6 +7,7 @@ import { patchComponent, patchElement, } from './patching'; +import Lifecycle from "./lifecycle"; export let recyclingEnabled = true; let componentPools = new Map(); @@ -27,7 +28,7 @@ export function enableRecycling() { recyclingEnabled = true; } -export function recycleElement(vNode, lifecycle, context, isSVG) { +export function recycleElement(vNode, lifecycle: Lifecycle, context, isSVG) { const tag = vNode.type; const key = vNode.key; let pools: Pools = elementPools.get(tag); @@ -72,7 +73,7 @@ export function poolElement(vNode) { } } -export function recycleComponent(vNode: VNode, lifecycle, context, isSVG) { +export function recycleComponent(vNode: VNode, lifecycle: Lifecycle, context, isSVG) { const type = vNode.type as Function; const key = vNode.key; let pools: Pools = componentPools.get(type); diff --git a/src/DOM/unmounting.ts b/src/DOM/unmounting.ts index 3b0ed88ca..935f49ae1 100644 --- a/src/DOM/unmounting.ts +++ b/src/DOM/unmounting.ts @@ -19,8 +19,9 @@ import { import { VNodeFlags } from '../core/shapes'; import { componentToDOMNodeMap, findDOMNodeEnabled } from './rendering'; import { removeChild } from './utils'; +import Lifecycle from "./lifecycle"; -export function unmount(vNode, parentDom, lifecycle, canRecycle, shallowUnmount, isRecycling) { +export function unmount(vNode, parentDom, lifecycle: Lifecycle, canRecycle, shallowUnmount, isRecycling) { const flags = vNode.flags; if (flags & VNodeFlags.Component) { @@ -38,7 +39,7 @@ function unmountVoidOrText(vNode, parentDom) { } } -export function unmountComponent(vNode, parentDom, lifecycle, canRecycle, shallowUnmount, isRecycling) { +export function unmountComponent(vNode, parentDom, lifecycle: Lifecycle, canRecycle, shallowUnmount, isRecycling) { const instance = vNode.children; const flags = vNode.flags; const isStatefulComponent = flags & VNodeFlags.ComponentClass; @@ -87,7 +88,7 @@ export function unmountComponent(vNode, parentDom, lifecycle, canRecycle, shallo } } -export function unmountElement(vNode, parentDom, lifecycle, canRecycle, shallowUnmount, isRecycling) { +export function unmountElement(vNode, parentDom, lifecycle: Lifecycle, canRecycle, shallowUnmount, isRecycling) { const dom = vNode.dom; const ref = vNode.ref; const events = vNode.events; @@ -117,7 +118,7 @@ export function unmountElement(vNode, parentDom, lifecycle, canRecycle, shallowU } } -function unmountChildren(children, lifecycle, shallowUnmount, isRecycling) { +function unmountChildren(children, lifecycle: Lifecycle, shallowUnmount, isRecycling) { if (isArray(children)) { for (let i = 0; i < children.length; i++) { const child = children[i]; diff --git a/src/DOM/utils.ts b/src/DOM/utils.ts index 851f887a5..6a0b8bc8a 100644 --- a/src/DOM/utils.ts +++ b/src/DOM/utils.ts @@ -1,6 +1,6 @@ import { VNodeFlags, - createVoidVNode, + createVoidVNode, VNode, } from '../core/shapes'; import { isArray, @@ -19,8 +19,9 @@ import { svgNS } from './constants'; import { unmount, } from './unmounting'; +import Lifecycle from "./lifecycle"; -export function createStatefulComponentInstance(vNode, Component, props, context, isSVG, devToolsStatus) { +export function createStatefulComponentInstance(vNode: VNode, Component, props, context, isSVG: boolean, devToolsStatus) { if (isUndefined(context)) { context = {}; } @@ -73,11 +74,11 @@ export function createStatefulComponentInstance(vNode, Component, props, context instance._lastInput = input; return instance; } -export function replaceLastChildAndUnmount(lastInput, nextInput, parentDom, lifecycle, context, isSVG, isRecycling) { +export function replaceLastChildAndUnmount(lastInput, nextInput, parentDom, lifecycle: Lifecycle, context, isSVG, isRecycling) { replaceVNode(parentDom, mount(nextInput, null, lifecycle, context, isSVG), lastInput, lifecycle, isRecycling); } -export function replaceVNode(parentDom, dom, vNode, lifecycle, isRecycling) { +export function replaceVNode(parentDom, dom, vNode, lifecycle: Lifecycle, isRecycling) { let shallowUnmount = false; // we cannot cache nodeType here as vNode might be re-assigned below if (vNode.flags & VNodeFlags.Component) { @@ -148,7 +149,7 @@ export function documentCreateElement(tag, isSVG) { } } -export function replaceWithNewNode(lastNode, nextNode, parentDom, lifecycle, context, isSVG, isRecycling) { +export function replaceWithNewNode(lastNode, nextNode, parentDom, lifecycle: Lifecycle, context, isSVG, isRecycling) { unmount(lastNode, null, lifecycle, false, false, isRecycling); const dom = mount(nextNode, null, lifecycle, context, isSVG); @@ -167,14 +168,14 @@ export function removeChild(parentDom, dom) { parentDom.removeChild(dom); } -export function removeAllChildren(dom, children, lifecycle, shallowUnmount, isRecycling) { +export function removeAllChildren(dom, children, lifecycle: Lifecycle, shallowUnmount, isRecycling) { dom.textContent = ''; if (!lifecycle.fastUnmount) { removeChildren(null, children, lifecycle, shallowUnmount, isRecycling); } } -export function removeChildren(dom, children, lifecycle, shallowUnmount, isRecycling) { +export function removeChildren(dom, children, lifecycle: Lifecycle, shallowUnmount, isRecycling) { for (let i = 0; i < children.length; i++) { const child = children[i];