# all files / diagram-js/lib/features/modeling/cmd/ DeleteElementsHandler.js

92.31% Statements 12/13
75% Branches 3/4
100% Functions 3/3
92.31% Lines 12/13

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35

    1189×
    1189×

    1×

    1×

    19×
    19×
    19×

    19×

    23×

    23×
    4×

    19×

     import { forEach } from 'min-dash';

    export default function DeleteElementsHandler(modeling, elementRegistry) {
      this._modeling = modeling;
      this._elementRegistry = elementRegistry;
    }

    DeleteElementsHandler.$inject = [
      'modeling',
      'elementRegistry'
    ];

    DeleteElementsHandler.prototype.postExecute = function(context) {

      var modeling = this._modeling,
          elementRegistry = this._elementRegistry,
          elements = context.elements;

      forEach(elements, function(element) {

        // element may have been removed with previous
        // remove operations already (e.g. in case of nesting)
        Iif (!elementRegistry.get(element.id)) {
          return;
        }

        if (element.waypoints) {
          modeling.removeConnection(element);
        } else {
          modeling.removeShape(element);
        }
      });
    };