Skip to content

Commit

Permalink
reduce stack size
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Jul 11, 2023
1 parent d425d65 commit 644c0a3
Showing 1 changed file with 33 additions and 32 deletions.
65 changes: 33 additions & 32 deletions src/diff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export function diff(
if ((tmp = options._diff)) tmp(newVNode);

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

// Necessary for createContext api. Setting this property will pass
Expand Down Expand Up @@ -226,37 +226,6 @@ export function diff(
if (!isNew && c.getSnapshotBeforeUpdate != null) {
snapshot = c.getSnapshotBeforeUpdate(oldProps, oldState);
}

let isTopLevelFragment =
tmp != null && tmp.type === Fragment && tmp.key == null;
let renderResult = isTopLevelFragment ? tmp.props.children : tmp;

diffChildren(
parentDom,
isArray(renderResult) ? renderResult : [renderResult],
newVNode,
oldVNode,
globalContext,
isSvg,
excessDomChildren,
commitQueue,
oldDom,
isHydrating,
refQueue
);

c.base = newVNode._dom;

// We successfully rendered this VNode, unset any stored hydration/bailout state:
newVNode._hydrating = null;

if (c._renderCallbacks.length) {
commitQueue.push(c);
}

if (clearProcessingException) {
c._pendingError = c._processingException = null;
}
} catch (e) {
newVNode._original = null;
// if hydrating or creating initial tree, bailout preserves DOM:
Expand All @@ -268,6 +237,38 @@ export function diff(
// excessDomChildren.length = 0;
}
options._catchError(e, newVNode, oldVNode);
return;
}

let isTopLevelFragment =
tmp != null && tmp.type === Fragment && tmp.key == null;
let renderResult = isTopLevelFragment ? tmp.props.children : tmp;

diffChildren(
parentDom,
isArray(renderResult) ? renderResult : [renderResult],
newVNode,
oldVNode,
globalContext,
isSvg,
excessDomChildren,
commitQueue,
oldDom,
isHydrating,
refQueue
);

c.base = newVNode._dom;

// We successfully rendered this VNode, unset any stored hydration/bailout state:
newVNode._hydrating = null;

if (c._renderCallbacks.length) {
commitQueue.push(c);
}

if (clearProcessingException) {
c._pendingError = c._processingException = null;
}
} else if (
excessDomChildren == null &&
Expand Down

0 comments on commit 644c0a3

Please sign in to comment.