Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions debug/src/component-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions debug/src/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export function initDebug() {
if (oldRoot) oldRoot(vnode, parentNode);
};

options._diff = vnode => {
options._diff = (vnode, oldVNode) => {
let { type } = vnode;

hooksAllowed = true;
Expand Down Expand Up @@ -241,7 +241,7 @@ export function initDebug() {
);
}

if (oldBeforeDiff) oldBeforeDiff(vnode);
if (oldBeforeDiff) oldBeforeDiff(vnode, oldVNode);
};

let renderCount = 0;
Expand Down
4 changes: 2 additions & 2 deletions hooks/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion hooks/src/internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/diff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down