bpmn-js 18.28.0 → 18.29.0

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,5 +1,5 @@
1
1
  /*!
2
- * bpmn-js - bpmn-modeler v18.28.0
2
+ * bpmn-js - bpmn-modeler v18.29.0
3
3
  *
4
4
  * Copyright (c) 2014-present, camunda Services GmbH
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Source Code: https://github.com/bpmn-io/bpmn-js
10
10
  *
11
- * Date: 2026-09-04
11
+ * Date: 2026-09-21
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -10210,18 +10210,42 @@
10210
10210
  };
10211
10211
  }
10212
10212
 
10213
- function cloneNsMatrix(nsMatrix) {
10214
- var clone = Object.create(null), key;
10215
- for (key in nsMatrix) {
10216
- clone[key] = nsMatrix[key];
10213
+ /**
10214
+ * Set a namespace matrix entry, recording the previous
10215
+ * value on the given change log for later restoration.
10216
+ *
10217
+ * @param {Object} nsMatrix
10218
+ * @param {Object<string, ?string>} changes
10219
+ * @param {string} key
10220
+ * @param {string} value
10221
+ */
10222
+ function setNsEntry(nsMatrix, changes, key, value) {
10223
+ if (!(key in changes)) {
10224
+ changes[key] = key in nsMatrix ? nsMatrix[key] : null;
10217
10225
  }
10218
- return clone;
10226
+
10227
+ nsMatrix[key] = value;
10219
10228
  }
10220
10229
 
10221
- // per-matrix element name cache; stored under a symbol so it is
10222
- // invisible to the `for (key in nsMatrix)` clone above and gets
10223
- // collected together with the matrix it belongs to
10224
- var NAME_CACHE = Symbol('nameCache');
10230
+ /**
10231
+ * Restore a namespace matrix, applying the given change log.
10232
+ *
10233
+ * @param {Object} nsMatrix
10234
+ * @param {Object<string, ?string>} changes
10235
+ */
10236
+ function restoreNsMatrix(nsMatrix, changes) {
10237
+ var key, value;
10238
+
10239
+ for (key in changes) {
10240
+ value = changes[key];
10241
+
10242
+ if (value === null) {
10243
+ delete nsMatrix[key];
10244
+ } else {
10245
+ nsMatrix[key] = value;
10246
+ }
10247
+ }
10248
+ }
10225
10249
 
10226
10250
  function uriPrefix(prefix) {
10227
10251
  return prefix + '$uri';
@@ -10334,7 +10358,7 @@
10334
10358
  /**
10335
10359
  * Namespace + node state shared across (streamed) parse runs.
10336
10360
  */
10337
- var nsMatrixStack,
10361
+ var nsChangesStack,
10338
10362
  nsMatrix,
10339
10363
  nodeStack;
10340
10364
 
@@ -10452,7 +10476,7 @@
10452
10476
  * Reset the parser state before a (streamed) parse run.
10453
10477
  */
10454
10478
  function resetState() {
10455
- nsMatrixStack = isNamespace ? [] : null;
10479
+ nsChangesStack = isNamespace ? [] : null;
10456
10480
  nsMatrix = isNamespace ? buildNsMatrix(nsUriToPrefix) : null;
10457
10481
  nodeStack = [];
10458
10482
 
@@ -10569,10 +10593,10 @@
10569
10593
  */
10570
10594
  function parse(xml, streaming = false) {
10571
10595
 
10572
- var elNameCache = null,
10573
- elNameCacheMatrix = null;
10596
+ var elNameCache = null;
10574
10597
 
10575
- var _nsMatrix,
10598
+ var nsChanges,
10599
+ nsSnapshot,
10576
10600
  anonymousNsCount = 0,
10577
10601
  tagStart = false,
10578
10602
  tagEnd = false,
@@ -10639,7 +10663,6 @@
10639
10663
  i = attrsStart,
10640
10664
  s = attrsString,
10641
10665
  l = s.length,
10642
- hasNewMatrix,
10643
10666
  newalias,
10644
10667
  value,
10645
10668
  alias,
@@ -10701,6 +10724,7 @@
10701
10724
 
10702
10725
  name = s.substring(i, j);
10703
10726
 
10727
+ // by definition bound to `xmlns`, must not be declared - https://www.w3.org/TR/xml-names/#ns-decl
10704
10728
  if (name === 'xmlns:xmlns') {
10705
10729
  handleWarning('illegal declaration of xmlns');
10706
10730
  skipAttr = true;
@@ -10758,6 +10782,11 @@
10758
10782
  value = s.substring(i, j);
10759
10783
  }
10760
10784
 
10785
+ // namespace fixed, must not be re-declared - https://www.w3.org/TR/xml-names/#ns-decl
10786
+ if (name === 'xmlns:xml' && value !== 'http://www.w3.org/XML/1998/namespace') {
10787
+ handleError('illegal value of xmlns:xml');
10788
+ }
10789
+
10761
10790
  i = j;
10762
10791
 
10763
10792
  // ensure SPACE follows attribute
@@ -10834,18 +10863,25 @@
10834
10863
  }
10835
10864
 
10836
10865
  if (nsMatrix[newalias] !== alias) {
10837
- if (!hasNewMatrix) {
10838
- nsMatrix = cloneNsMatrix(nsMatrix);
10839
- hasNewMatrix = true;
10866
+
10867
+ // mutate matrix in place, tracking changes
10868
+ // for restoration once the element closes;
10869
+ // null prototype guards against special keys
10870
+ if (!nsChanges) {
10871
+ nsChanges = Object.create(null);
10840
10872
  }
10841
10873
 
10842
- nsMatrix[newalias] = alias;
10874
+ // invalidate cached element names + ns snapshot
10875
+ elNameCache = null;
10876
+ nsSnapshot = null;
10877
+
10878
+ setNsEntry(nsMatrix, nsChanges, newalias, alias);
10843
10879
  if (newalias === 'xmlns') {
10844
- nsMatrix[uriPrefix(alias)] = nsUri;
10880
+ setNsEntry(nsMatrix, nsChanges, uriPrefix(alias), nsUri);
10845
10881
  defaultAlias = alias;
10846
10882
  }
10847
10883
 
10848
- nsMatrix[nsUriPrefix] = nsUri;
10884
+ setNsEntry(nsMatrix, nsChanges, nsUriPrefix, nsUri);
10849
10885
  }
10850
10886
 
10851
10887
  // expose xmlns(:asd)="..." in attributes
@@ -10968,7 +11004,14 @@
10968
11004
  }),
10969
11005
  'attrs': getter(getAttrs),
10970
11006
  'ns': getter(function() {
10971
- return nsMatrix;
11007
+
11008
+ // expose a stable snapshot of the current namespace
11009
+ // matrix, cached until the matrix changes
11010
+ if (!nsSnapshot) {
11011
+ nsSnapshot = Object.assign(Object.create(null), nsMatrix);
11012
+ }
11013
+
11014
+ return nsSnapshot;
10972
11015
  })
10973
11016
  });
10974
11017
  }
@@ -11225,15 +11268,11 @@
11225
11268
 
11226
11269
  if (isNamespace) {
11227
11270
 
11228
- _nsMatrix = nsMatrix;
11229
-
11230
11271
  if (tagStart) {
11231
11272
 
11232
- // remember old namespace
11233
- // unless we're self-closing
11234
- if (!tagEnd) {
11235
- nsMatrixStack.push(_nsMatrix);
11236
- }
11273
+ // track namespace changes on this element
11274
+ // for later restoration
11275
+ nsChanges = null;
11237
11276
 
11238
11277
  if (cachedAttrs === null) {
11239
11278
 
@@ -11249,18 +11288,21 @@
11249
11288
  maybeNS = false;
11250
11289
  }
11251
11290
  }
11291
+
11292
+ // remember changes made by this element
11293
+ // unless we're self-closing
11294
+ if (!tagEnd) {
11295
+ nsChangesStack.push(nsChanges);
11296
+ }
11252
11297
  }
11253
11298
 
11254
11299
  _elementName = elementName;
11255
11300
 
11256
- // memoize normalized names per namespace matrix; tag names
11301
+ // memoize normalized names per namespace state; tag names
11257
11302
  // typically repeat heavily and the matrix rarely changes.
11258
- if (elNameCacheMatrix !== nsMatrix) {
11259
- elNameCache = nsMatrix[NAME_CACHE];
11260
- if (elNameCache === undefined) {
11261
- elNameCache = nsMatrix[NAME_CACHE] = Object.create(null);
11262
- }
11263
- elNameCacheMatrix = nsMatrix;
11303
+ // the cache is rebuilt whenever the matrix changed.
11304
+ if (elNameCache === null) {
11305
+ elNameCache = Object.create(null);
11264
11306
  }
11265
11307
 
11266
11308
  var _cachedName = elNameCache[elementName];
@@ -11331,9 +11373,16 @@
11331
11373
  // restore old namespace
11332
11374
  if (isNamespace) {
11333
11375
  if (!tagStart) {
11334
- nsMatrix = nsMatrixStack.pop();
11335
- } else {
11336
- nsMatrix = _nsMatrix;
11376
+ nsChanges = nsChangesStack.pop();
11377
+ }
11378
+
11379
+ if (nsChanges) {
11380
+ restoreNsMatrix(nsMatrix, nsChanges);
11381
+ nsChanges = null;
11382
+
11383
+ // invalidate cached element names + ns snapshot
11384
+ elNameCache = null;
11385
+ nsSnapshot = null;
11337
11386
  }
11338
11387
  }
11339
11388
  }