JointJS+ Changelog v4.3.4
JointJS+ 4.3.4 ships with @joint/core 4.3.4, @joint/react 4.3.7, and the new @joint/layout-elk 4.3.4.
This release fixes security issues with graph JSON from an untrusted source (CVE pending). JointJS renders the cell attributes as they are, so such JSON must still be sanitized before it enters the graph, see Sanitization.
Overview
Introducing @joint/layout-elk
A new open-source package, @joint/layout-elk, lays out JointJS graphs with the Eclipse Layout Kernel (ELK) through its JavaScript port elkjs. ELK is a collection of layout algorithms - layered (the default), mrtree, radial, force, stress, rectpacking and more.
Beyond positioning elements, the package takes the whole diagram into account: embedded elements become nested containers sized to fit their content, links are routed to the exact port they connect to, and link labels (and, on request, port and element labels) are placed by ELK. layout() is asynchronous, and ELK can run on the main thread or in a Web Worker.
- Learn: ELK layout
- API reference:
@joint/layout-elk - React: ELK with
@joint/react
The package depends on @joint/core ~4.3.4.
dia
Cell
dia.Cell – fix removeAttr() to pass its options on when the path is an array
Fix an issue where removeAttr() ignored its options when the path was given as an array.
dia.Cell – fix removeProp() to remove a top-level property given as an array path
Fix an issue where removeProp() did not remove a top-level property when the path was given as an array (e.g.
cell.removeProp(['myProperty'])).
Element
dia.Element – fix port lookups to match a port id by value and type
Fix an issue where port lookups compared port ids loosely. The ids 5 and '5' now refer to two different ports, and
0 is a valid port id.
dia.Element – fix the PortLabelPositionType type
PortLabelPositionType now uses PortLabelPositionJSON for the position of a port label.
dia.Element – fix the types of portProp()
The types now allow portProp(portId) and portProp(portId, object, opt).
ElementView
dia.ElementView – fix getLinkEnd() to keep a non-integer numeric port id
Fix an issue where getLinkEnd() did not keep a non-integer numeric port id (e.g. 1.5).
Graph
dia.Graph – fix to resolve cell and layer type only to dia.Cell and dia.GraphLayer constructors Security
Fix a security issue where the type of a cell or a layer could resolve to any function reachable from the namespace
(e.g. constructor). Such a type now throws "Could not find cell constructor" or "Could not find layer constructor".
Link
dia.Link – internal refactoring of the link label resolution
The resolution of link labels against defaultLabel and the built-in default label was consolidated in one place.
link.label() and link.labels() still return the labels as they are stored.
Paper
dia.Paper – fix defineFilter() to ignore filter names inherited from Object.prototype Security
Fix a security issue where a filter name inherited from Object.prototype (e.g. toString) was called as a filter and
its result was inserted as the filter markup. Such a name now throws "Non-existing filter".
dia.Paper – fix multiLinks: false to tell a link to port 0 apart from links to other ports
Fix an issue where multiLinks: false did not tell a link to port 0 apart from links to other ports of the same
element.
dia.Paper – fix a re-added layer being left without a view
Fix an issue where a layer removed and added again before the paper updated was left without a view.
ToolsView
dia.ToolsView – fix a hidden tool reappearing in async mode
Fix an issue where a tool hidden with hide() right after addTools() reappeared when the update was deferred (e.g.
async: true).
mvc
mvc.$ – fix parseHTML() to remove all <script> elements Security
Fix a security issue where parseHTML() removed only every other <script> element.
mvc.Dom – fix $(window) to hold the window
Fix an issue where $(window) was an empty collection. It now holds the window, so the event methods and
width()/height() work on it.
util
util – fix sanitizeHTML() to remove unsafe elements and to detect obfuscated javascript: URLs Security
Fix a security issue where sanitizeHTML() kept unsafe content. It now removes script, iframe, frame,
frameset, object, embed, base, meta, link, noscript, animate and set elements, removes srcdoc and
event handlers in any letter case, and checks URL schemes regardless of letter case, whitespace and control characters.
util – fix setByPath() and unsetByPath() to ignore __proto__ as the last path segment Security
Fix a security issue where setByPath() and unsetByPath() could change the prototype of an object when the last
segment of the path was __proto__.
util – fix toggleFullScreen() in a cross-origin iframe
Fix an issue where toggleFullScreen() threw a SecurityError in a cross-origin iframe, because it read the document
of the top-level page. It now uses the page of the given element, and the current page's body when no element is
given.
util – accept undefined source objects in the defaults() typings
The typings of defaults(), defaultsDeep(), supplement() and deepSupplement() now accept undefined source
objects, which the implementations already skip.
filter
util.filter – fix the built-in filters to escape their arguments Security
Fix a security issue where the arguments of the built-in filters (e.g. color of util.filter.outline) were inserted
into the filter markup unescaped.
config
config – declare storeEmbeds in the TypeScript types
The config types now declare the storeEmbeds option.
types
View lookups infer the view type from the model
cell.findView() returns ElementView for a dia.Element and LinkView for a dia.Link. paper.getCellView()
infers the view type from the model it is given. This is a typings-only change.
linkTools
Anchor
linkTools.Anchor – add types for the pointer methods
The types now declare onPointerDown(), onPointerMove(), onPointerUp() and onPointerDblClick().
Vertices
linkTools.Vertices – fix the VertexHandle type
The VertexHandle type now declares onDoubleClick() instead of onPointerClick().
linkTools.Vertices – fix the vertexAdding type
The vertexAdding type now names interactiveLinkNode instead of interactiveLineNode.
routers
rightAngle
routers.rightAngle – fix routing at ports of rotated elements
Fix an issue where a link left (or reached) a port of a rotated element in the direction of the unrotated element, e.g. along the body of the element. The router now also routes around the rotated element. Unrotated elements are routed as before.
layout
ForceDirected
layout.ForceDirected – skip distant quadtree cells in the radial force
The radial force now skips the quadtree cells which are too far away to affect an element, instead of visiting the whole quadtree for every element. The layout results do not change.
format
Print
format.Print – fix to restore the paper on the window's afterprint
Fix an issue where the paper was restored and its afterprint event triggered only by a fallback timer. They now run on
the window's afterprint event.
Visio
format.Visio – fix the check of image data URLs on export
Fix an issue where checking the data URL of an image which can not be drawn to a canvas took exponential time on export.
format.Visio – fix the parsing of image file names on import
Fix an issue where parsing the file names of the images of a Visio archive took quadratic time, and where an image path without an extension threw an error.
shapes
bpmn2
shapes.bpmn2 – fix iconColor leaking as an attribute
Fix an issue where iconColor was rendered as an icon-color attribute on Event, Gateway and DataObject.
shapes.bpmn2 – fix the icon types
Fix the type of the collectionIcon selector of DataObject, and allow null entries in an icon set.
ui
Inspector
ui.Inspector – fix select fields to keep the type of non-string option values
Fix an issue where a select field saved the option values as strings. It now saves them with their original type
(e.g. numeric options save numbers, not strings).
ui.Inspector – fix options referenced from a model property
options referenced from a model property now support non-string primitive values.
Keyboard
ui.Keyboard – fix the parsing of shortcuts with long runs of white space
Fix an issue where parsing a shortcut definition with a long run of white space took quadratic time.
Lightbox
ui.Lightbox – fix to re-position and rescale the image when the window is resized
Fix an issue where an open image was not re-positioned and rescaled when the window was resized.
PaperScroller
ui.PaperScroller – fix autoResizePaper to stop forcing a layout on every paper update
Fix an issue where autoResizePaper forced a layout on every paper update.
ui.PaperScroller – fix the types of the zoom options
The options of zoomToFit() and zoomToRect() are typed as dia.Paper.TransformToFitContentOptions instead of the
deprecated alias.
SelectBox
ui.SelectBox – fix openPolicy: 'auto' with a document.body target
Fix an issue where a select box with openPolicy: 'auto' and document.body as its target ignored the viewport
height and always opened downwards.
Snaplines
ui.Snaplines – fix a delegated drag
Fix an issue where, during a delegated drag (e.g. an embedded element with interactive: { stopDelegation: false }),
the moved element jumped to the pointer on snap. additionalSnapPoints() now receives the view of the moved element.
Stencil
ui.Stencil – fix cellCursor to keep the default hit area of links
Fix an issue where cellCursor removed the default hit area of links, so straight links could not be dragged.
widgets
ui.widgets.fullscreen – fix a SecurityError in a cross-origin iframe
Fix an issue where a toolbar with the fullscreen widget did not render in a cross-origin iframe. The button is now
shown only where fullscreen is allowed.
react
Hooks
useOnElementsMeasured – fire once per settled change
useOnElementsMeasured() now fires exactly once per settled change (an addition, a removal or a re-measurement), when
no element is still waiting to be measured.