@joint/core 4.2.3 → 4.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /*! JointJS v4.2.3 (2026-01-21) - JavaScript diagramming library
1
+ /*! JointJS v4.2.4 (2026-02-13) - JavaScript diagramming library
2
2
 
3
3
  This Source Code Form is subject to the terms of the Mozilla Public
4
4
  License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -9709,6 +9709,25 @@ var joint = (function (exports) {
9709
9709
  return `matrix(${a},${b},${c},${d},${e},${f})`;
9710
9710
  }
9711
9711
 
9712
+ /**
9713
+ * @param {SVGElement} node
9714
+ * @returns {SVGSVGElement|null}
9715
+ * @description Returns the root SVG element for the given node,
9716
+ * walking up through nested SVG elements.
9717
+ * Returns `null` if the node is not part of an SVG document.
9718
+ */
9719
+ function getRootSVG(node) {
9720
+ let svg = node.ownerSVGElement;
9721
+ if (!svg) {
9722
+ // The node itself may be an <svg> element
9723
+ return node instanceof SVGSVGElement ? node : null;
9724
+ }
9725
+ while (svg.ownerSVGElement) {
9726
+ svg = svg.ownerSVGElement;
9727
+ }
9728
+ return svg;
9729
+ }
9730
+
9712
9731
  /**
9713
9732
  *
9714
9733
  * @param {SVGElement} a
@@ -9719,9 +9738,12 @@ var joint = (function (exports) {
9719
9738
  * in order to calculate the correct transformation matrix.
9720
9739
  */
9721
9740
  function getRelativeTransformation(a, b) {
9722
- // Different SVG elements, no transformation possible
9723
- // Note: SVGSVGElement has no `ownerSVGElement`
9724
- if ((a.ownerSVGElement || a) !== (b.ownerSVGElement || b)) return null;
9741
+ // Elements must be part of an SVG document
9742
+ const rootA = getRootSVG(a);
9743
+ const rootB = getRootSVG(b);
9744
+ if (!rootA || !rootB) return null;
9745
+ // Different SVG documents, no transformation possible
9746
+ if (rootA !== rootB) return null;
9725
9747
  // Get the transformation matrix from `a` to `b`.
9726
9748
  const am = b.getScreenCTM();
9727
9749
  if (!am) return null;
@@ -14544,7 +14566,9 @@ var joint = (function (exports) {
14544
14566
  if (this.idAttribute in attrs) {
14545
14567
  var prevId = this.id;
14546
14568
  this.id = this.get(this.idAttribute);
14547
- this.trigger(this.eventPrefix + 'changeId', this, prevId, options);
14569
+ if (this.id !== prevId) {
14570
+ this.trigger(this.eventPrefix + 'changeId', this, prevId, options);
14571
+ }
14548
14572
  }
14549
14573
 
14550
14574
  // Trigger all relevant attribute changes.
@@ -27683,7 +27707,7 @@ var joint = (function (exports) {
27683
27707
  // links first.
27684
27708
  this.layerCollection.removeCell(sortedCells.shift(), opt);
27685
27709
  } while (sortedCells.length > 0);
27686
- this.stopBatch('clear');
27710
+ this.stopBatch('clear', opt);
27687
27711
  return this;
27688
27712
  },
27689
27713
  _prepareCell: function (cellInit, opt) {
@@ -27851,7 +27875,7 @@ var joint = (function (exports) {
27851
27875
  removeCells: function (cellRefs, options) {
27852
27876
  if (!cellRefs.length) return this;
27853
27877
  // Remove multiple cells in a single batch
27854
- this.startBatch('remove');
27878
+ this.startBatch('remove', options);
27855
27879
  for (const cellRef of cellRefs) {
27856
27880
  if (!cellRef) continue;
27857
27881
  let cell;
@@ -27866,7 +27890,7 @@ var joint = (function (exports) {
27866
27890
  }
27867
27891
  this.layerCollection.removeCell(cell, options);
27868
27892
  }
27869
- this.stopBatch('remove');
27893
+ this.stopBatch('remove', options);
27870
27894
  return this;
27871
27895
  },
27872
27896
  /**
@@ -27896,7 +27920,7 @@ var joint = (function (exports) {
27896
27920
 
27897
27921
  // 3. Add the replacement cell
27898
27922
  this.addCell(replacement, replaceOptions);
27899
- this.stopBatch(batchName);
27923
+ this.stopBatch(batchName, opt);
27900
27924
  },
27901
27925
  /**
27902
27926
  * @protected
@@ -27985,7 +28009,7 @@ var joint = (function (exports) {
27985
28009
  this.getLayer(layerId).cellCollection.sort(opt);
27986
28010
  }
27987
28011
  }
27988
- this.stopBatch(batchName);
28012
+ this.stopBatch(batchName, opt);
27989
28013
  },
27990
28014
  /**
27991
28015
  * @public
@@ -28011,13 +28035,13 @@ var joint = (function (exports) {
28011
28035
  throw new Error('dia.Graph: cell to remove does not exist in the graph.');
28012
28036
  }
28013
28037
  if (cell.graph !== this) return;
28014
- this.startBatch('remove');
28038
+ this.startBatch('remove', options);
28015
28039
  cell.collection.remove(cell, options);
28016
- this.stopBatch('remove');
28040
+ this.stopBatch('remove', options);
28017
28041
  },
28018
28042
  transferCellEmbeds: function (sourceCell, targetCell, opt = {}) {
28019
28043
  const batchName = 'transfer-embeds';
28020
- this.startBatch(batchName);
28044
+ this.startBatch(batchName, opt);
28021
28045
 
28022
28046
  // Embed children of the source cell in the target cell.
28023
28047
  const children = sourceCell.getEmbeddedCells();
@@ -28025,11 +28049,11 @@ var joint = (function (exports) {
28025
28049
  ...opt,
28026
28050
  reparent: true
28027
28051
  });
28028
- this.stopBatch(batchName);
28052
+ this.stopBatch(batchName, opt);
28029
28053
  },
28030
28054
  transferCellConnectedLinks: function (sourceCell, targetCell, opt = {}) {
28031
28055
  const batchName = 'transfer-connected-links';
28032
- this.startBatch(batchName);
28056
+ this.startBatch(batchName, opt);
28033
28057
 
28034
28058
  // Reconnect all the links connected to the old cell to the new cell.
28035
28059
  const connectedLinks = this.getConnectedLinks(sourceCell, opt);
@@ -28041,7 +28065,7 @@ var joint = (function (exports) {
28041
28065
  link.prop(['target', 'id'], targetCell.id, opt);
28042
28066
  }
28043
28067
  });
28044
- this.stopBatch(batchName);
28068
+ this.stopBatch(batchName, opt);
28045
28069
  },
28046
28070
  /**
28047
28071
  * @private
@@ -36768,7 +36792,8 @@ var joint = (function (exports) {
36768
36792
  if (view) {
36769
36793
  // The view could have been disposed during dragging
36770
36794
  // e.g. dragged outside of the viewport and hidden
36771
- view = this.findViewByModel(view.model);
36795
+ // The model can be removed in previous mousemove event handlers
36796
+ view = this.findViewByModel(view.model) || view;
36772
36797
  view.pointermove(evt, localPoint.x, localPoint.y);
36773
36798
  } else {
36774
36799
  this.trigger('blank:pointermove', evt, localPoint.x, localPoint.y);
@@ -36783,7 +36808,8 @@ var joint = (function (exports) {
36783
36808
  if (view) {
36784
36809
  // The view could have been disposed during dragging
36785
36810
  // e.g. dragged outside of the viewport and hidden
36786
- view = this.findViewByModel(view.model);
36811
+ // The model can be removed in previous mouseup event handlers (e.g. when deleting an element after dragging)
36812
+ view = this.findViewByModel(view.model) || view;
36787
36813
  view.pointerup(normalizedEvt, localPoint.x, localPoint.y);
36788
36814
  } else {
36789
36815
  this.trigger('blank:pointerup', normalizedEvt, localPoint.x, localPoint.y);
@@ -39675,7 +39701,7 @@ var joint = (function (exports) {
39675
39701
  Remove: Remove
39676
39702
  };
39677
39703
 
39678
- var version = "4.2.3";
39704
+ var version = "4.2.4";
39679
39705
 
39680
39706
  const Vectorizer = V;
39681
39707
  const layout$1 = {