@joint/core 4.1.1 → 4.1.2

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.1.1 (2024-12-02) - JavaScript diagramming library
1
+ /*! JointJS v4.1.2 (2025-01-16) - JavaScript diagramming library
2
2
 
3
3
 
4
4
  This Source Code Form is subject to the terms of the Mozilla Public
@@ -5721,8 +5721,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
5721
5721
  case 'bottom':
5722
5722
  dy = -(0.25 * llMaxFont) - rLineHeights;
5723
5723
  break;
5724
- default:
5725
5724
  case 'top':
5725
+ default:
5726
5726
  dy = 0.8 * flMaxFont;
5727
5727
  break;
5728
5728
  }
@@ -1,4 +1,4 @@
1
- /*! JointJS v4.1.1 (2024-12-02) - JavaScript diagramming library
1
+ /*! JointJS v4.1.2 (2025-01-16) - JavaScript diagramming library
2
2
 
3
3
 
4
4
  This Source Code Form is subject to the terms of the Mozilla Public
package/dist/version.mjs CHANGED
@@ -1,3 +1,3 @@
1
- var version = "4.1.1";
1
+ var version = "4.1.2";
2
2
 
3
3
  export { version };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@joint/core",
3
3
  "title": "JointJS",
4
- "version": "4.1.1",
4
+ "version": "4.1.2",
5
5
  "description": "JavaScript diagramming library",
6
6
  "sideEffects": false,
7
7
  "main": "./dist/joint.min.js",
package/src/V/index.mjs CHANGED
@@ -472,8 +472,8 @@ const V = (function() {
472
472
  case 'bottom':
473
473
  dy = -(0.25 * llMaxFont) - rLineHeights;
474
474
  break;
475
- default:
476
475
  case 'top':
476
+ default:
477
477
  dy = (0.8 * flMaxFont);
478
478
  break;
479
479
  }
@@ -142,7 +142,7 @@ export const ElementView = CellView.extend({
142
142
  * @abstract
143
143
  */
144
144
  _initializePorts: function() {
145
-
145
+ // implemented in ports.js
146
146
  },
147
147
 
148
148
  update: function(_, renderingOnlyAttrs) {
@@ -42,13 +42,13 @@ export const HighlighterView = mvc.View.extend({
42
42
  // The cellView is now rendered/updated since it has a higher update priority.
43
43
  this.updateRequested = false;
44
44
  const { cellView, nodeSelector } = this;
45
- if (!cellView.isMounted()) {
45
+ if (cellView.isMounted()) {
46
+ this.update(cellView, nodeSelector);
47
+ this.mount();
48
+ this.transform();
49
+ } else {
46
50
  this.postponedUpdate = true;
47
- return 0;
48
51
  }
49
- this.update(cellView, nodeSelector);
50
- this.mount();
51
- this.transform();
52
52
  return 0;
53
53
  },
54
54
 
@@ -59,11 +59,15 @@ assign(Collection.prototype, Events, {
59
59
 
60
60
  // preinitialize is an empty function by default. You can override it with a function
61
61
  // or object. preinitialize will run before any instantiation logic is run in the Collection.
62
- preinitialize: function(){},
62
+ preinitialize: function(){
63
+ // No implementation.
64
+ },
63
65
 
64
66
  // Initialize is an empty function by default. Override it with your own
65
67
  // initialization logic.
66
- initialize: function(){},
68
+ initialize: function(){
69
+ // No implementation.
70
+ },
67
71
 
68
72
  // The JSON representation of a Collection is an array of the
69
73
  // models' attributes.
@@ -109,8 +109,8 @@ $.fn.find = function(selector) {
109
109
  return ret;
110
110
  };
111
111
 
112
- $.fn.add = function(selector, context) {
113
- const newElements = $(selector, context).toArray();
112
+ $.fn.add = function(selector) {
113
+ const newElements = $(selector).toArray();
114
114
  const prevElements = this.toArray();
115
115
  const ret = this.pushStack([]);
116
116
  $.merge(ret, uniq(prevElements.concat(newElements)));
@@ -65,7 +65,7 @@ export function html(html) {
65
65
  if (!el) return null;
66
66
  if (arguments.length === 0) return el.innerHTML;
67
67
  if (html === undefined) return this; // do nothing
68
- cleanNodesData(dataPriv, el.getElementsByTagName('*'));
68
+ cleanNodesData(el.getElementsByTagName('*'));
69
69
  if (typeof html === 'string' || typeof html === 'number') {
70
70
  el.innerHTML = html;
71
71
  } else {
@@ -336,17 +336,19 @@ export function position() {
336
336
  // when a statically positioned element is identified
337
337
  doc = el.ownerDocument;
338
338
  offsetParent = el.offsetParent || doc.documentElement;
339
- const $parentOffset = $(offsetParent);
340
- const parentOffsetElementPosition = $parentOffset.css('position') || 'static';
341
- while ( offsetParent && (offsetParent === doc.body || offsetParent === doc.documentElement) && parentOffsetElementPosition === 'static') {
342
- offsetParent = offsetParent.parentNode;
339
+ const isStaticallyPositioned = (el) => {
340
+ const { position } = el.style;
341
+ return !position || position === 'static';
342
+ };
343
+ while (offsetParent && offsetParent !== doc.documentElement && isStaticallyPositioned(offsetParent)) {
344
+ offsetParent = offsetParent.offsetParent || doc.documentElement;
343
345
  }
344
- if (offsetParent && offsetParent !== el && offsetParent.nodeType === 1) {
346
+ if (offsetParent && offsetParent !== el && offsetParent.nodeType === 1 && !isStaticallyPositioned(offsetParent)) {
345
347
  // Incorporate borders into its offset, since they are outside its content origin
346
348
  const offsetParentStyles = window.getComputedStyle(offsetParent);
347
349
  const borderTopWidth = parseFloat(offsetParentStyles.borderTopWidth) || 0;
348
350
  const borderLeftWidth = parseFloat(offsetParentStyles.borderLeftWidth) || 0;
349
- parentOffset = $parentOffset.offset();
351
+ parentOffset = $(offsetParent).offset();
350
352
  parentOffset.top += borderTopWidth;
351
353
  parentOffset.left += borderLeftWidth;
352
354
  }
@@ -1,4 +1,3 @@
1
- import V from '../V/index.mjs';
2
1
  import { Events } from './Events.mjs';
3
2
 
4
3
  export class Listener {
@@ -9,7 +8,7 @@ export class Listener {
9
8
  listenTo(object, evt, ...args) {
10
9
  const { callbackArguments } = this;
11
10
  // signature 1 - (object, eventHashMap, context)
12
- if (V.isObject(evt)) {
11
+ if (evt && typeof evt === 'object') {
13
12
  const [context = null] = args;
14
13
  Object.entries(evt).forEach(([eventName, cb]) => {
15
14
  if (typeof cb !== 'function') return;
package/src/mvc/Model.mjs CHANGED
@@ -59,11 +59,15 @@ assign(Model.prototype, Events, {
59
59
 
60
60
  // preinitialize is an empty function by default. You can override it with a function
61
61
  // or object. preinitialize will run before any instantiation logic is run in the Model.
62
- preinitialize: function(){},
62
+ preinitialize: function(){
63
+ // No implementation.
64
+ },
63
65
 
64
66
  // Initialize is an empty function by default. Override it with your own
65
67
  // initialization logic.
66
- initialize: function(){},
68
+ initialize: function(){
69
+ // No implementation.
70
+ },
67
71
 
68
72
  // Return a copy of the model's `attributes` object.
69
73
  toJSON: function(options) {
@@ -52,11 +52,15 @@ assign(ViewBase.prototype, Events, {
52
52
 
53
53
  // preinitialize is an empty function by default. You can override it with a function
54
54
  // or object. preinitialize will run before any instantiation logic is run in the View
55
- preinitialize: function(){},
55
+ preinitialize: function(){
56
+ // No implementation.
57
+ },
56
58
 
57
59
  // Initialize is an empty function by default. Override it with your own
58
60
  // initialization logic.
59
- initialize: function(){},
61
+ initialize: function(){
62
+ // No implementation.
63
+ },
60
64
 
61
65
  // **render** is the core function that your view should override, in order
62
66
  // to populate its element (`this.el`), with the appropriate HTML. The
package/src/util/util.mjs CHANGED
@@ -79,10 +79,10 @@ export const parseDOMJSON = function(json, namespace) {
79
79
  const groupSelectors = {};
80
80
  const svgNamespace = V.namespace.svg;
81
81
 
82
- const ns = namespace || svgNamespace;
82
+ const initialNS = namespace || svgNamespace;
83
83
  const fragment = document.createDocumentFragment();
84
84
 
85
- const parseNode = function(siblingsDef, parentNode, ns) {
85
+ const parseNode = function(siblingsDef, parentNode, parentNS) {
86
86
  for (let i = 0; i < siblingsDef.length; i++) {
87
87
  const nodeDef = siblingsDef[i];
88
88
 
@@ -100,7 +100,7 @@ export const parseDOMJSON = function(json, namespace) {
100
100
  let node;
101
101
 
102
102
  // Namespace URI
103
- if (nodeDef.hasOwnProperty('namespaceURI')) ns = nodeDef.namespaceURI;
103
+ const ns = (nodeDef.hasOwnProperty('namespaceURI')) ? nodeDef.namespaceURI : parentNS;
104
104
  node = document.createElementNS(ns, tagName);
105
105
  const svg = (ns === svgNamespace);
106
106
 
@@ -152,7 +152,7 @@ export const parseDOMJSON = function(json, namespace) {
152
152
  }
153
153
  }
154
154
  };
155
- parseNode(json, fragment, ns);
155
+ parseNode(json, fragment, initialNS);
156
156
  return {
157
157
  fragment: fragment,
158
158
  selectors: selectors,
@@ -1790,4 +1790,5 @@ export {
1790
1790
  };
1791
1791
 
1792
1792
  export const noop = function() {
1793
+ // Do nothing.
1793
1794
  };
@@ -389,7 +389,7 @@ const initCloneByTag = (object, tag, isDeep) => {
389
389
  const Constructor = object.constructor;
390
390
  switch(tag) {
391
391
  case arrayBufferTag:
392
- return cloneArrayBuffer(object, isDeep);
392
+ return cloneArrayBuffer(object);
393
393
  case boolTag:
394
394
  case dateTag:
395
395
  return new Constructor(+object);
@@ -1168,7 +1168,7 @@ const baseMerge = (object, source, srcIndex, customizer, stack) => {
1168
1168
 
1169
1169
  assignMergeValue(object, key, newValue);
1170
1170
  }
1171
- }, keysIn);
1171
+ });
1172
1172
  };
1173
1173
 
1174
1174
  const baseMergeDeep = (object, source, key, srcIndex, mergeFunc, customizer, stack) => {
@@ -1281,7 +1281,7 @@ function last(array) {
1281
1281
 
1282
1282
  const createSet = (Set && (1 / setToArray(new Set([undefined,-0]))[1]) == 1 / 0)
1283
1283
  ? (values) => new Set(values)
1284
- : () => {};
1284
+ : () => { /* no-op */ };
1285
1285
 
1286
1286
  function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
1287
1287
  if (isObject(objValue) && isObject(srcValue)) {
@@ -2236,8 +2236,8 @@ export function debounce(func, wait, opt) {
2236
2236
  export const groupBy = (collection, iteratee) => {
2237
2237
  iteratee = getIteratee(iteratee, 2);
2238
2238
 
2239
- return reduce(collection, (result, value, key) => {
2240
- key = iteratee(value);
2239
+ return reduce(collection, (result, value) => {
2240
+ const key = iteratee(value);
2241
2241
  if (hasOwnProperty.call(result, key)) {
2242
2242
  result[key].push(value);
2243
2243
  } else {