From 8a0c1a3803b5f998e3e67580dd94ac9734df2c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Souchet=20C=C3=A9line?= Date: Wed, 6 Sep 2023 11:26:03 +0200 Subject: [PATCH] fix: `collapsedSubProcessIds` should be a `Set`, and use `collapsedSubProcessIds.has()` to check existence or non-existence unicorn/prefer-set-has --- src/component/registry/bpmn-model-registry.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/component/registry/bpmn-model-registry.ts b/src/component/registry/bpmn-model-registry.ts index 83e1a26e55..b22c4f3790 100644 --- a/src/component/registry/bpmn-model-registry.ts +++ b/src/component/registry/bpmn-model-registry.ts @@ -66,12 +66,14 @@ export class BpmnModelRegistry { } function toRenderedModel(bpmnModel: BpmnModel): RenderedModel { - const collapsedSubProcessIds: string[] = bpmnModel.flowNodes - .filter(shape => { - const bpmnElement = shape.bpmnElement; - return ShapeUtil.isSubProcess(bpmnElement.kind) && (bpmnElement as ShapeBpmnSubProcess).markers.includes(ShapeBpmnMarkerKind.EXPAND); - }) - .map(shape => shape.bpmnElement.id); + const collapsedSubProcessIds = new Set( + bpmnModel.flowNodes + .filter(shape => { + const bpmnElement = shape.bpmnElement; + return ShapeUtil.isSubProcess(bpmnElement.kind) && (bpmnElement as ShapeBpmnSubProcess).markers.includes(ShapeBpmnMarkerKind.EXPAND); + }) + .map(shape => shape.bpmnElement.id), + ); const subprocesses: Shape[] = []; const boundaryEvents: Shape[] = []; @@ -82,7 +84,7 @@ function toRenderedModel(bpmnModel: BpmnModel): RenderedModel { subprocesses.push(shape); } else if (ShapeUtil.isBoundaryEvent(kind)) { boundaryEvents.push(shape); - } else if (!collapsedSubProcessIds.includes(shape.bpmnElement.parentId)) { + } else if (!collapsedSubProcessIds.has(shape.bpmnElement.parentId)) { otherFlowNodes.push(shape); } }