diff --git a/packages/g6/src/behaviors/fix-element-size.ts b/packages/g6/src/behaviors/fix-element-size.ts index 7b2f5404dc0..40778885c21 100644 --- a/packages/g6/src/behaviors/fix-element-size.ts +++ b/packages/g6/src/behaviors/fix-element-size.ts @@ -217,7 +217,7 @@ export class FixElementSize extends BaseBehavior { const { element, model } = this.context; const el = element!.getElement(id) as Node | Combo; - if (this.skipIfExceedViewport(el)) return; + if (!el || this.skipIfExceedViewport(el)) return; const edges = model.getRelatedEdgesData(id); edges.forEach((edge) => this.relatedEdgeToUpdate.add(idOf(edge))); @@ -234,7 +234,7 @@ export class FixElementSize extends BaseBehavior { const id = idOf(datum); const el = this.context.element!.getElement(id) as Edge; - if (this.skipIfExceedViewport(el)) return; + if (!el || this.skipIfExceedViewport(el)) return; const config = this.options.edge; if (!config) { diff --git a/packages/g6/src/plugins/edge-bundling/index.ts b/packages/g6/src/plugins/edge-bundling/index.ts index b1691fd1911..eb69b9675a1 100644 --- a/packages/g6/src/plugins/edge-bundling/index.ts +++ b/packages/g6/src/plugins/edge-bundling/index.ts @@ -284,8 +284,8 @@ export class EdgeBundling extends BasePlugin { edges.forEach((edge) => { const edgeId = idOf(edge); - const edgeEl = element!.getElement(edgeId)!; - edgeEl.update({ d: getPolylinePath(this.edgePoints[edgeId]) }); + const edgeEl = element!.getElement(edgeId); + edgeEl?.update({ d: getPolylinePath(this.edgePoints[edgeId]) }); }); }; diff --git a/packages/g6/src/plugins/fisheye/index.ts b/packages/g6/src/plugins/fisheye/index.ts index fe310bf27d3..0a563518bdd 100644 --- a/packages/g6/src/plugins/fisheye/index.ts +++ b/packages/g6/src/plugins/fisheye/index.ts @@ -277,7 +277,7 @@ export class Fisheye extends BasePlugin { const update = (nodeId: ID, style: NodeStyle) => { const node = element!.getElement(nodeId) as Node; - node.update(style); + node?.update(style); graph.getRelatedEdgesData(nodeId).forEach((datum) => { relatedEdges.add(idOf(datum));