@mocanvas/editor · function

hasAncestor

declare function hasAncestor(editor: Editor, shape: ShapeRef | undefined, ancestorId: ShapeId): boolean

Whether ancestorId is somewhere above shape in the tree.

False for a shape asked about itself: "is my own descendant" is the question a reparent guard is really asking, and answering true there would let a shape be dropped into itself.

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.