diff --git a/debug/src/component-stack.js b/debug/src/component-stack.js index 52a1801273..91a5464766 100644 --- a/debug/src/component-stack.js +++ b/debug/src/component-stack.js @@ -118,11 +118,11 @@ export function setupComponentStack() { if (oldDiffed) oldDiffed(vnode); }; - options._diff = vnode => { + options._diff = (vnode, oldVnode) => { if (isPossibleOwner(vnode)) { renderStack.push(vnode); } - if (oldDiff) oldDiff(vnode); + if (oldDiff) oldDiff(vnode, oldVnode); }; options._root = (vnode, parent) => { diff --git a/debug/src/debug.js b/debug/src/debug.js index 1d8eb7c0e6..7c22d86211 100644 --- a/debug/src/debug.js +++ b/debug/src/debug.js @@ -145,7 +145,7 @@ export function initDebug() { if (oldRoot) oldRoot(vnode, parentNode); }; - options._diff = vnode => { + options._diff = (vnode, oldVNode) => { let { type } = vnode; hooksAllowed = true; @@ -241,7 +241,7 @@ export function initDebug() { ); } - if (oldBeforeDiff) oldBeforeDiff(vnode); + if (oldBeforeDiff) oldBeforeDiff(vnode, oldVNode); }; let renderCount = 0; diff --git a/hooks/src/index.js b/hooks/src/index.js index d6e66dfe7f..8ce52c2ad9 100644 --- a/hooks/src/index.js +++ b/hooks/src/index.js @@ -34,9 +34,9 @@ const RAF_TIMEOUT = 35; let prevRaf; /** @type {(vnode: import('./internal').VNode) => void} */ -options._diff = vnode => { +options._diff = (vnode, oldVNode) => { currentComponent = null; - if (oldBeforeDiff) oldBeforeDiff(vnode); + if (oldBeforeDiff) oldBeforeDiff(vnode, oldVNode); }; options._root = (vnode, parentDom) => { diff --git a/hooks/src/internal.d.ts b/hooks/src/internal.d.ts index c51fc13a50..695aabe406 100644 --- a/hooks/src/internal.d.ts +++ b/hooks/src/internal.d.ts @@ -12,7 +12,7 @@ export { PreactContext }; export interface Options extends PreactOptions { /** Attach a hook that is invoked before a vnode is diffed. */ - _diff?(vnode: VNode): void; + _diff?(vnode: VNode, oldVNode: VNode): void; diffed?(vnode: VNode): void; /** Attach a hook that is invoked before a vnode has rendered. */ _render?(vnode: VNode): void; diff --git a/src/diff/index.js b/src/diff/index.js index 30eed07d62..015f783d39 100644 --- a/src/diff/index.js +++ b/src/diff/index.js @@ -76,7 +76,7 @@ export function diff( } } - if ((tmp = options._diff)) tmp(newVNode); + if ((tmp = options._diff)) tmp(newVNode, oldVNode); outer: if (typeof newType == 'function') { try { diff --git a/src/internal.d.ts b/src/internal.d.ts index 72215d066a..087e36cfe1 100644 --- a/src/internal.d.ts +++ b/src/internal.d.ts @@ -30,7 +30,7 @@ export interface Options extends preact.Options { /** Attach a hook that is invoked before render, mainly to check the arguments. */ _root?(vnode: ComponentChild, parent: preact.ContainerNode): void; /** Attach a hook that is invoked before a vnode is diffed. */ - _diff?(vnode: VNode): void; + _diff?(vnode: VNode, oldVNode: VNode): void; /** Attach a hook that is invoked after a tree was mounted or was updated. */ _commit?(vnode: VNode, commitQueue: Component[]): void; /** Attach a hook that is invoked before a vnode has rendered. */