From 34e37c5691789c2af50776d011b5e0ffec4fae1e Mon Sep 17 00:00:00 2001 From: Jovi De Croock Date: Fri, 14 Jul 2023 09:18:58 +0200 Subject: [PATCH] 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 644c0a3be8fdd824bce12d0cc7a19921d811c1fb. --- src/diff/index.js | 66 +++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/diff/index.js b/src/diff/index.js index 2537a1b35b..2cd24bbb0f 100644 --- a/src/diff/index.js +++ b/src/diff/index.js @@ -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; @@ -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); } /**