Skip to content

Commit

Permalink
fix: skip non-existent elements (#6417)
Browse files Browse the repository at this point in the history
  • Loading branch information
yvonneyx authored Oct 17, 2024
1 parent 0ab5f8d commit dab826a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/g6/src/behaviors/fix-element-size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export class FixElementSize extends BaseBehavior<FixElementSizeOptions> {
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)));
Expand All @@ -234,7 +234,7 @@ export class FixElementSize extends BaseBehavior<FixElementSizeOptions> {
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) {
Expand Down
4 changes: 2 additions & 2 deletions packages/g6/src/plugins/edge-bundling/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ export class EdgeBundling extends BasePlugin<EdgeBundlingOptions> {

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]) });
});
};

Expand Down
2 changes: 1 addition & 1 deletion packages/g6/src/plugins/fisheye/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export class Fisheye extends BasePlugin<FisheyeOptions> {

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));
Expand Down

0 comments on commit dab826a

Please sign in to comment.