Skip to content

Commit e072ab9

Browse files
committed
fixed typo with fastUnmount and added types for Lifecycle to avoid regression
1 parent 00f5c72 commit e072ab9

File tree

8 files changed

+38
-35
lines changed

8 files changed

+38
-35
lines changed

packages/inferno/dist/inferno.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ function patchComponent(lastVNode, nextVNode, parentDom, lifecycle, context, isS
11141114
var subLifecycle = instance._lifecycle;
11151115
lifecycle.fastUnmount = subLifecycle.fastUnmount;
11161116
patch(lastInput$1, nextInput$1, parentDom, lifecycle, childContext, isSVG, isRecycling);
1117-
subLifecycle.fastUnmount = lifecycle.unmount;
1117+
subLifecycle.fastUnmount = lifecycle.fastUnmount;
11181118
lifecycle.fastUnmount = fastUnmount;
11191119
instance.componentDidUpdate(lastProps, lastState);
11201120
findDOMNodeEnabled && componentToDOMNodeMap.set(instance, nextInput$1.dom);

packages/inferno/dist/inferno.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/DOM/hydration.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function normalizeChildNodes(dom) {
5757
}
5858
}
5959

60-
function hydrateComponent(vNode, dom, lifecycle, context, isSVG, isClass) {
60+
function hydrateComponent(vNode, dom, lifecycle: Lifecycle, context, isSVG, isClass) {
6161
const type = vNode.type;
6262
const props = vNode.props || EMPTY_OBJ;
6363
const ref = vNode.ref;
@@ -100,7 +100,7 @@ function hydrateComponent(vNode, dom, lifecycle, context, isSVG, isClass) {
100100
}
101101
}
102102

103-
function hydrateElement(vNode, dom, lifecycle, context, isSVG) {
103+
function hydrateElement(vNode, dom, lifecycle: Lifecycle, context, isSVG) {
104104
const tag = vNode.type;
105105
const children = vNode.children;
106106
const props = vNode.props;
@@ -132,7 +132,7 @@ function hydrateElement(vNode, dom, lifecycle, context, isSVG) {
132132
}
133133
}
134134

135-
function hydrateChildren(children, dom, lifecycle, context, isSVG) {
135+
function hydrateChildren(children, dom, lifecycle: Lifecycle, context, isSVG) {
136136
normalizeChildNodes(dom);
137137
const domNodes = Array.prototype.slice.call(dom.childNodes);
138138
let childNodeIndex = 0;
@@ -165,7 +165,7 @@ function hydrateVoid(vNode, dom) {
165165
vNode.dom = dom;
166166
}
167167

168-
function hydrate(vNode, dom, lifecycle, context, isSVG) {
168+
function hydrate(vNode, dom, lifecycle: Lifecycle, context, isSVG) {
169169
if (process.env.NODE_ENV !== 'production') {
170170
if (isInvalid(dom)) {
171171
throwError(`failed to hydrate. The server-side render doesn't match client side.`);

src/DOM/mounting.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
} from './patching';
3434
import processElement from './wrappers/processElement';
3535

36-
export function mount(vNode, parentDom, lifecycle, context, isSVG) {
36+
export function mount(vNode, parentDom, lifecycle: Lifecycle, context, isSVG) {
3737
const flags = vNode.flags;
3838

3939
if (flags & VNodeFlags.Element) {
@@ -72,7 +72,7 @@ export function mountVoid(vNode, parentDom) {
7272
return dom;
7373
}
7474

75-
export function mountElement(vNode, parentDom, lifecycle, context, isSVG) {
75+
export function mountElement(vNode, parentDom, lifecycle: Lifecycle, context, isSVG) {
7676
if (recyclingEnabled) {
7777
const dom = recycleElement(vNode, lifecycle, context, isSVG);
7878

@@ -129,7 +129,7 @@ export function mountElement(vNode, parentDom, lifecycle, context, isSVG) {
129129
return dom;
130130
}
131131

132-
export function mountArrayChildren(children, dom, lifecycle, context, isSVG) {
132+
export function mountArrayChildren(children, dom, lifecycle: Lifecycle, context, isSVG) {
133133
for (let i = 0; i < children.length; i++) {
134134
let child = children[i];
135135

@@ -142,7 +142,7 @@ export function mountArrayChildren(children, dom, lifecycle, context, isSVG) {
142142
}
143143
}
144144

145-
export function mountComponent(vNode, parentDom, lifecycle, context, isSVG, isClass) {
145+
export function mountComponent(vNode, parentDom, lifecycle: Lifecycle, context, isSVG: boolean, isClass: number) {
146146
if (recyclingEnabled) {
147147
const dom = recycleComponent(vNode, lifecycle, context, isSVG);
148148

@@ -199,7 +199,7 @@ export function mountComponent(vNode, parentDom, lifecycle, context, isSVG, isCl
199199
return dom;
200200
}
201201

202-
export function mountStatefulComponentCallbacks(ref, instance, lifecycle) {
202+
export function mountStatefulComponentCallbacks(ref, instance, lifecycle: Lifecycle) {
203203
if (ref) {
204204
if (isFunction(ref)) {
205205
ref(instance);
@@ -217,7 +217,7 @@ export function mountStatefulComponentCallbacks(ref, instance, lifecycle) {
217217
}
218218
}
219219

220-
export function mountStatelessComponentCallbacks(ref, dom, lifecycle) {
220+
export function mountStatelessComponentCallbacks(ref, dom, lifecycle: Lifecycle) {
221221
if (ref) {
222222
if (!isNullOrUndef(ref.onComponentWillMount)) {
223223
lifecycle.fastUnmount = false;
@@ -230,7 +230,7 @@ export function mountStatelessComponentCallbacks(ref, dom, lifecycle) {
230230
}
231231
}
232232

233-
export function mountRef(dom, value, lifecycle) {
233+
export function mountRef(dom, value, lifecycle: Lifecycle) {
234234
if (isFunction(value)) {
235235
lifecycle.fastUnmount = false;
236236
lifecycle.addListener(() => value(dom));

src/DOM/patching.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ import { componentToDOMNodeMap, findDOMNodeEnabled } from './rendering';
7070
import processElement from './wrappers/processElement';
7171
import { unmount } from './unmounting';
7272

73-
export function patch(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG: boolean, isRecycling: boolean) {
73+
export function patch(lastVNode, nextVNode, parentDom, lifecycle: Lifecycle, context, isSVG: boolean, isRecycling: boolean) {
7474
if (lastVNode !== nextVNode) {
7575
const lastFlags = lastVNode.flags;
7676
const nextFlags = nextVNode.flags;
@@ -140,7 +140,7 @@ export function patch(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG
140140
}
141141
}
142142

143-
function unmountChildren(children, dom, lifecycle, isRecycling) {
143+
function unmountChildren(children, dom, lifecycle: Lifecycle, isRecycling: boolean) {
144144
if (isVNode(children)) {
145145
unmount(children, dom, lifecycle, true, false, isRecycling);
146146
} else if (isArray(children)) {
@@ -200,7 +200,7 @@ export function patchElement(lastVNode: VNode, nextVNode: VNode, parentDom: Node
200200
}
201201
}
202202

203-
function patchChildren(lastFlags, nextFlags, lastChildren, nextChildren, dom, lifecycle, context, isSVG, isRecycling) {
203+
function patchChildren(lastFlags: VNodeFlags, nextFlags: VNodeFlags, lastChildren, nextChildren, dom, lifecycle: Lifecycle, context, isSVG: boolean, isRecycling: boolean) {
204204
let patchArray = false;
205205
let patchKeyed = false;
206206

@@ -263,7 +263,7 @@ function patchChildren(lastFlags, nextFlags, lastChildren, nextChildren, dom, li
263263
}
264264
}
265265

266-
export function patchComponent(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG, isClass, isRecycling: boolean) {
266+
export function patchComponent(lastVNode, nextVNode, parentDom, lifecycle: Lifecycle, context, isSVG: boolean, isClass: number, isRecycling: boolean) {
267267
const lastType = lastVNode.type;
268268
const nextType = nextVNode.type;
269269
const nextProps = nextVNode.props || EMPTY_OBJ;
@@ -362,7 +362,7 @@ export function patchComponent(lastVNode, nextVNode, parentDom, lifecycle, conte
362362

363363
lifecycle.fastUnmount = subLifecycle.fastUnmount;
364364
patch(lastInput, nextInput, parentDom, lifecycle, childContext, isSVG, isRecycling);
365-
subLifecycle.fastUnmount = lifecycle.unmount;
365+
subLifecycle.fastUnmount = lifecycle.fastUnmount;
366366
lifecycle.fastUnmount = fastUnmount;
367367
instance.componentDidUpdate(lastProps, lastState);
368368
findDOMNodeEnabled && componentToDOMNodeMap.set(instance, nextInput.dom);
@@ -434,11 +434,11 @@ export function patchText(lastVNode: VNode, nextVNode: VNode) {
434434
}
435435
}
436436

437-
export function patchVoid(lastVNode, nextVNode) {
437+
export function patchVoid(lastVNode: VNode, nextVNode: VNode) {
438438
nextVNode.dom = lastVNode.dom;
439439
}
440440

441-
export function patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, isSVG, isRecycling) {
441+
export function patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle: Lifecycle, context, isSVG: boolean, isRecycling: boolean) {
442442
let lastChildrenLength = lastChildren.length;
443443
let nextChildrenLength = nextChildren.length;
444444
let commonLength = lastChildrenLength > nextChildrenLength ? nextChildrenLength : lastChildrenLength;
@@ -781,7 +781,7 @@ function lis_algorithm(a) {
781781
return result;
782782
}
783783

784-
export function patchProp(prop, lastValue, nextValue, dom, isSVG: boolean, lifecycle) {
784+
export function patchProp(prop, lastValue, nextValue, dom, isSVG: boolean, lifecycle: Lifecycle) {
785785
if (skipProps[prop]) {
786786
return;
787787
}
@@ -879,7 +879,7 @@ export function patchEvent(name, lastValue, nextValue, dom, lifecycle) {
879879
}
880880
}
881881

882-
function patchProps(lastProps, nextProps, dom, lifecycle, context, isSVG) {
882+
function patchProps(lastProps, nextProps, dom, lifecycle: Lifecycle, context, isSVG: boolean) {
883883
lastProps = lastProps || EMPTY_OBJ;
884884
nextProps = nextProps || EMPTY_OBJ;
885885

src/DOM/recycling.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
patchComponent,
88
patchElement,
99
} from './patching';
10+
import Lifecycle from "./lifecycle";
1011

1112
export let recyclingEnabled = true;
1213
let componentPools = new Map<Function | null, Pools>();
@@ -27,7 +28,7 @@ export function enableRecycling() {
2728
recyclingEnabled = true;
2829
}
2930

30-
export function recycleElement(vNode, lifecycle, context, isSVG) {
31+
export function recycleElement(vNode, lifecycle: Lifecycle, context, isSVG) {
3132
const tag = vNode.type;
3233
const key = vNode.key;
3334
let pools: Pools = elementPools.get(tag);
@@ -72,7 +73,7 @@ export function poolElement(vNode) {
7273
}
7374
}
7475

75-
export function recycleComponent(vNode: VNode, lifecycle, context, isSVG) {
76+
export function recycleComponent(vNode: VNode, lifecycle: Lifecycle, context, isSVG) {
7677
const type = vNode.type as Function;
7778
const key = vNode.key;
7879
let pools: Pools = componentPools.get(type);

src/DOM/unmounting.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ import {
1919
import { VNodeFlags } from '../core/shapes';
2020
import { componentToDOMNodeMap, findDOMNodeEnabled } from './rendering';
2121
import { removeChild } from './utils';
22+
import Lifecycle from "./lifecycle";
2223

23-
export function unmount(vNode, parentDom, lifecycle, canRecycle, shallowUnmount, isRecycling) {
24+
export function unmount(vNode, parentDom, lifecycle: Lifecycle, canRecycle, shallowUnmount, isRecycling) {
2425
const flags = vNode.flags;
2526

2627
if (flags & VNodeFlags.Component) {
@@ -38,7 +39,7 @@ function unmountVoidOrText(vNode, parentDom) {
3839
}
3940
}
4041

41-
export function unmountComponent(vNode, parentDom, lifecycle, canRecycle, shallowUnmount, isRecycling) {
42+
export function unmountComponent(vNode, parentDom, lifecycle: Lifecycle, canRecycle, shallowUnmount, isRecycling) {
4243
const instance = vNode.children;
4344
const flags = vNode.flags;
4445
const isStatefulComponent = flags & VNodeFlags.ComponentClass;
@@ -87,7 +88,7 @@ export function unmountComponent(vNode, parentDom, lifecycle, canRecycle, shallo
8788
}
8889
}
8990

90-
export function unmountElement(vNode, parentDom, lifecycle, canRecycle, shallowUnmount, isRecycling) {
91+
export function unmountElement(vNode, parentDom, lifecycle: Lifecycle, canRecycle, shallowUnmount, isRecycling) {
9192
const dom = vNode.dom;
9293
const ref = vNode.ref;
9394
const events = vNode.events;
@@ -117,7 +118,7 @@ export function unmountElement(vNode, parentDom, lifecycle, canRecycle, shallowU
117118
}
118119
}
119120

120-
function unmountChildren(children, lifecycle, shallowUnmount, isRecycling) {
121+
function unmountChildren(children, lifecycle: Lifecycle, shallowUnmount, isRecycling) {
121122
if (isArray(children)) {
122123
for (let i = 0; i < children.length; i++) {
123124
const child = children[i];

src/DOM/utils.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
VNodeFlags,
3-
createVoidVNode,
3+
createVoidVNode, VNode,
44
} from '../core/shapes';
55
import {
66
isArray,
@@ -19,8 +19,9 @@ import { svgNS } from './constants';
1919
import {
2020
unmount,
2121
} from './unmounting';
22+
import Lifecycle from "./lifecycle";
2223

23-
export function createStatefulComponentInstance(vNode, Component, props, context, isSVG, devToolsStatus) {
24+
export function createStatefulComponentInstance(vNode: VNode, Component, props, context, isSVG: boolean, devToolsStatus) {
2425
if (isUndefined(context)) {
2526
context = {};
2627
}
@@ -73,11 +74,11 @@ export function createStatefulComponentInstance(vNode, Component, props, context
7374
instance._lastInput = input;
7475
return instance;
7576
}
76-
export function replaceLastChildAndUnmount(lastInput, nextInput, parentDom, lifecycle, context, isSVG, isRecycling) {
77+
export function replaceLastChildAndUnmount(lastInput, nextInput, parentDom, lifecycle: Lifecycle, context, isSVG, isRecycling) {
7778
replaceVNode(parentDom, mount(nextInput, null, lifecycle, context, isSVG), lastInput, lifecycle, isRecycling);
7879
}
7980

80-
export function replaceVNode(parentDom, dom, vNode, lifecycle, isRecycling) {
81+
export function replaceVNode(parentDom, dom, vNode, lifecycle: Lifecycle, isRecycling) {
8182
let shallowUnmount = false;
8283
// we cannot cache nodeType here as vNode might be re-assigned below
8384
if (vNode.flags & VNodeFlags.Component) {
@@ -148,7 +149,7 @@ export function documentCreateElement(tag, isSVG) {
148149
}
149150
}
150151

151-
export function replaceWithNewNode(lastNode, nextNode, parentDom, lifecycle, context, isSVG, isRecycling) {
152+
export function replaceWithNewNode(lastNode, nextNode, parentDom, lifecycle: Lifecycle, context, isSVG, isRecycling) {
152153
unmount(lastNode, null, lifecycle, false, false, isRecycling);
153154
const dom = mount(nextNode, null, lifecycle, context, isSVG);
154155

@@ -167,14 +168,14 @@ export function removeChild(parentDom, dom) {
167168
parentDom.removeChild(dom);
168169
}
169170

170-
export function removeAllChildren(dom, children, lifecycle, shallowUnmount, isRecycling) {
171+
export function removeAllChildren(dom, children, lifecycle: Lifecycle, shallowUnmount, isRecycling) {
171172
dom.textContent = '';
172173
if (!lifecycle.fastUnmount) {
173174
removeChildren(null, children, lifecycle, shallowUnmount, isRecycling);
174175
}
175176
}
176177

177-
export function removeChildren(dom, children, lifecycle, shallowUnmount, isRecycling) {
178+
export function removeChildren(dom, children, lifecycle: Lifecycle, shallowUnmount, isRecycling) {
178179
for (let i = 0; i < children.length; i++) {
179180
const child = children[i];
180181

0 commit comments

Comments
 (0)