Skip to content

Commit 7fd5489

Browse files
Merge pull request #362 from preactjs/drop-ancestor-binding
2 parents 426efb6 + 355a1af commit 7fd5489

File tree

4 files changed

+4
-31
lines changed

4 files changed

+4
-31
lines changed

src/adapter/10/bindings.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -148,18 +148,6 @@ export function findRoot(vnode: VNode, config: RendererConfig): VNode {
148148
return vnode;
149149
}
150150

151-
/**
152-
* Get the ancestor component that rendered the current vnode
153-
*/
154-
export function getAncestor(vnode: VNode): VNode | null {
155-
let next: VNode | null = vnode;
156-
while ((next = getVNodeParent(next)) != null) {
157-
return next;
158-
}
159-
160-
return null;
161-
}
162-
163151
/**
164152
* Get human readable name of the component/dom element
165153
*/
@@ -287,7 +275,6 @@ export const bindingsV10: PreactBindings<VNode> = {
287275
getDisplayName,
288276
getPropsVNodeDisplayName: getDisplayName,
289277
getActualChildren,
290-
getAncestor,
291278
getDom,
292279
isTextVNode,
293280
getInstance,

src/adapter/11/bindings.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -257,18 +257,6 @@ export function getHookState(
257257
return [];
258258
}
259259

260-
/**
261-
* Get the ancestor component that rendered the current vnode
262-
*/
263-
export function getAncestor(vnode: Internal): Internal | null {
264-
let next: Internal | null = vnode;
265-
while ((next = getVNodeParent(next)) != null) {
266-
return next;
267-
}
268-
269-
return null;
270-
}
271-
272260
export function createSuspenseState(vnode: Internal, suspended: boolean) {
273261
const c = getComponent(vnode) as Component;
274262
const key = getSuspenseStateKey(c);
@@ -302,7 +290,6 @@ export const bindingsV11: PreactBindings<Internal> = {
302290
getDisplayName,
303291
getPropsVNodeDisplayName,
304292
getActualChildren,
305-
getAncestor,
306293
getDom,
307294
isTextVNode: isTextInternal,
308295
getInstance,

src/adapter/shared/bindings.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export type ComponentHooks = Record<string, any>;
1111
export type HookState = Record<string, any>;
1212

1313
export interface PreactBindings<T extends SharedVNode = SharedVNode> {
14-
getAncestor(vnode: T): T | null;
1514
getDisplayName(vnode: T, config: RendererConfig): string;
1615
getPropsVNodeDisplayName(vnode: any, config: RendererConfig): string;
1716
isRoot(vnode: T, config: RendererConfig): boolean;

src/adapter/shared/traverse.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,14 +513,14 @@ function findClosestNonFilteredParent<T extends SharedVNode>(
513513
vnode: T,
514514
) {
515515
let parentId = -1;
516-
let ancestor: T | null = helpers.getAncestor(vnode);
517-
while (ancestor !== null) {
518-
parentId = getVNodeId(ids, ancestor);
516+
let parent: T | null = helpers.getVNodeParent(vnode);
517+
while (parent !== null) {
518+
parentId = getVNodeId(ids, parent);
519519
if (parentId !== -1) {
520520
break;
521521
}
522522

523-
ancestor = helpers.getAncestor(ancestor);
523+
parent = helpers.getVNodeParent(parent);
524524
}
525525

526526
return parentId;

0 commit comments

Comments
 (0)