Skip to content

Commit 721d9c1

Browse files
committed
Add parameter oldVNode when calling options._diff
1 parent 3675a09 commit 721d9c1

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

debug/src/component-stack.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ export function setupComponentStack() {
118118
if (oldDiffed) oldDiffed(vnode);
119119
};
120120

121-
options._diff = vnode => {
121+
options._diff = (vnode, oldVnode) => {
122122
if (isPossibleOwner(vnode)) {
123123
renderStack.push(vnode);
124124
}
125-
if (oldDiff) oldDiff(vnode);
125+
if (oldDiff) oldDiff(vnode, oldVnode);
126126
};
127127

128128
options._root = (vnode, parent) => {

debug/src/debug.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export function initDebug() {
145145
if (oldRoot) oldRoot(vnode, parentNode);
146146
};
147147

148-
options._diff = vnode => {
148+
options._diff = (vnode, oldVNode) => {
149149
let { type } = vnode;
150150

151151
hooksAllowed = true;
@@ -241,7 +241,7 @@ export function initDebug() {
241241
);
242242
}
243243

244-
if (oldBeforeDiff) oldBeforeDiff(vnode);
244+
if (oldBeforeDiff) oldBeforeDiff(vnode, oldVNode);
245245
};
246246

247247
let renderCount = 0;

hooks/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ const RAF_TIMEOUT = 35;
3434
let prevRaf;
3535

3636
/** @type {(vnode: import('./internal').VNode) => void} */
37-
options._diff = vnode => {
37+
options._diff = (vnode, oldVNode) => {
3838
currentComponent = null;
39-
if (oldBeforeDiff) oldBeforeDiff(vnode);
39+
if (oldBeforeDiff) oldBeforeDiff(vnode, oldVNode);
4040
};
4141

4242
options._root = (vnode, parentDom) => {

hooks/src/internal.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export { PreactContext };
1212

1313
export interface Options extends PreactOptions {
1414
/** Attach a hook that is invoked before a vnode is diffed. */
15-
_diff?(vnode: VNode): void;
15+
_diff?(vnode: VNode, oldVNode: VNode): void;
1616
diffed?(vnode: VNode): void;
1717
/** Attach a hook that is invoked before a vnode has rendered. */
1818
_render?(vnode: VNode): void;

src/diff/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export function diff(
7676
}
7777
}
7878

79-
if ((tmp = options._diff)) tmp(newVNode);
79+
if ((tmp = options._diff)) tmp(newVNode, oldVNode);
8080

8181
outer: if (typeof newType == 'function') {
8282
try {

src/internal.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface Options extends preact.Options {
3030
/** Attach a hook that is invoked before render, mainly to check the arguments. */
3131
_root?(vnode: ComponentChild, parent: preact.ContainerNode): void;
3232
/** Attach a hook that is invoked before a vnode is diffed. */
33-
_diff?(vnode: VNode): void;
33+
_diff?(vnode: VNode, oldVNode: VNode): void;
3434
/** Attach a hook that is invoked after a tree was mounted or was updated. */
3535
_commit?(vnode: VNode, commitQueue: Component[]): void;
3636
/** Attach a hook that is invoked before a vnode has rendered. */

0 commit comments

Comments
 (0)