Skip to content

Commit

Permalink
reduce stack size of try catch by excluding non components (#4067)
Browse files Browse the repository at this point in the history
* reduce stack size of try catch by excluding non components

* reduce stack size

* Revert "reduce stack size"

This reverts commit 644c0a3.
  • Loading branch information
JoviDeCroock committed Jul 14, 2023
1 parent 2258d7d commit 34e37c5
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions src/diff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export function diff(

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

try {
outer: if (typeof newType == 'function') {
outer: if (typeof newType == 'function') {
try {
let c, isNew, oldProps, oldState, snapshot, clearProcessingException;
let newProps = newVNode.props;

Expand Down Expand Up @@ -257,39 +257,39 @@ export function diff(
if (clearProcessingException) {
c._pendingError = c._processingException = null;
}
} else if (
excessDomChildren == null &&
newVNode._original === oldVNode._original
) {
newVNode._children = oldVNode._children;
newVNode._dom = oldVNode._dom;
} else {
newVNode._dom = diffElementNodes(
oldVNode._dom,
newVNode,
oldVNode,
globalContext,
isSvg,
excessDomChildren,
commitQueue,
isHydrating,
refQueue
);
}

if ((tmp = options.diffed)) tmp(newVNode);
} catch (e) {
newVNode._original = null;
// if hydrating or creating initial tree, bailout preserves DOM:
if (isHydrating || excessDomChildren != null) {
newVNode._dom = oldDom;
newVNode._hydrating = !!isHydrating;
excessDomChildren[excessDomChildren.indexOf(oldDom)] = null;
// ^ could possibly be simplified to:
// excessDomChildren.length = 0;
} catch (e) {
newVNode._original = null;
// if hydrating or creating initial tree, bailout preserves DOM:
if (isHydrating || excessDomChildren != null) {
newVNode._dom = oldDom;
newVNode._hydrating = !!isHydrating;
excessDomChildren[excessDomChildren.indexOf(oldDom)] = null;
// ^ could possibly be simplified to:
// excessDomChildren.length = 0;
}
options._catchError(e, newVNode, oldVNode);
}
options._catchError(e, newVNode, oldVNode);
} else if (
excessDomChildren == null &&
newVNode._original === oldVNode._original
) {
newVNode._children = oldVNode._children;
newVNode._dom = oldVNode._dom;
} else {
newVNode._dom = diffElementNodes(
oldVNode._dom,
newVNode,
oldVNode,
globalContext,
isSvg,
excessDomChildren,
commitQueue,
isHydrating,
refQueue
);
}

if ((tmp = options.diffed)) tmp(newVNode);
}

/**
Expand Down

0 comments on commit 34e37c5

Please sign in to comment.