Skip to content

Commit 34e37c5

Browse files
authored
reduce stack size of try catch by excluding non components (#4067)
* reduce stack size of try catch by excluding non components * reduce stack size * Revert "reduce stack size" This reverts commit 644c0a3.
1 parent 2258d7d commit 34e37c5

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

src/diff/index.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ export function diff(
5353

5454
if ((tmp = options._diff)) tmp(newVNode);
5555

56-
try {
57-
outer: if (typeof newType == 'function') {
56+
outer: if (typeof newType == 'function') {
57+
try {
5858
let c, isNew, oldProps, oldState, snapshot, clearProcessingException;
5959
let newProps = newVNode.props;
6060

@@ -257,39 +257,39 @@ export function diff(
257257
if (clearProcessingException) {
258258
c._pendingError = c._processingException = null;
259259
}
260-
} else if (
261-
excessDomChildren == null &&
262-
newVNode._original === oldVNode._original
263-
) {
264-
newVNode._children = oldVNode._children;
265-
newVNode._dom = oldVNode._dom;
266-
} else {
267-
newVNode._dom = diffElementNodes(
268-
oldVNode._dom,
269-
newVNode,
270-
oldVNode,
271-
globalContext,
272-
isSvg,
273-
excessDomChildren,
274-
commitQueue,
275-
isHydrating,
276-
refQueue
277-
);
278-
}
279-
280-
if ((tmp = options.diffed)) tmp(newVNode);
281-
} catch (e) {
282-
newVNode._original = null;
283-
// if hydrating or creating initial tree, bailout preserves DOM:
284-
if (isHydrating || excessDomChildren != null) {
285-
newVNode._dom = oldDom;
286-
newVNode._hydrating = !!isHydrating;
287-
excessDomChildren[excessDomChildren.indexOf(oldDom)] = null;
288-
// ^ could possibly be simplified to:
289-
// excessDomChildren.length = 0;
260+
} catch (e) {
261+
newVNode._original = null;
262+
// if hydrating or creating initial tree, bailout preserves DOM:
263+
if (isHydrating || excessDomChildren != null) {
264+
newVNode._dom = oldDom;
265+
newVNode._hydrating = !!isHydrating;
266+
excessDomChildren[excessDomChildren.indexOf(oldDom)] = null;
267+
// ^ could possibly be simplified to:
268+
// excessDomChildren.length = 0;
269+
}
270+
options._catchError(e, newVNode, oldVNode);
290271
}
291-
options._catchError(e, newVNode, oldVNode);
272+
} else if (
273+
excessDomChildren == null &&
274+
newVNode._original === oldVNode._original
275+
) {
276+
newVNode._children = oldVNode._children;
277+
newVNode._dom = oldVNode._dom;
278+
} else {
279+
newVNode._dom = diffElementNodes(
280+
oldVNode._dom,
281+
newVNode,
282+
oldVNode,
283+
globalContext,
284+
isSvg,
285+
excessDomChildren,
286+
commitQueue,
287+
isHydrating,
288+
refQueue
289+
);
292290
}
291+
292+
if ((tmp = options.diffed)) tmp(newVNode);
293293
}
294294

295295
/**

0 commit comments

Comments
 (0)