Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

diagram-js

Package Overview
Dependencies
Maintainers
4
Versions
288
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diagram-js - npm Package Compare versions

Comparing version 0.19.3 to 0.19.4

11

lib/core/ElementRegistry.js

@@ -13,6 +13,10 @@ 'use strict';

*/
function ElementRegistry() {
function ElementRegistry(eventBus) {
this._elements = {};
this._eventBus = eventBus;
}
ElementRegistry.$inject = [ 'eventBus' ];
module.exports = ElementRegistry;

@@ -80,2 +84,7 @@

this._eventBus.fire('element.updateId', {
element: element,
newId: newId
});
var gfx = this.getGraphics(element),

@@ -82,0 +91,0 @@ secondaryGfx = this.getGraphics(element, true);

@@ -259,2 +259,16 @@ 'use strict';

// update bendpoint container data attribute on element ID change
eventBus.on('element.updateId', function(context) {
var element = context.element,
newId = context.newId;
if (element.waypoints) {
var bendpointContainer = getBendpointsContainer(element);
if (bendpointContainer) {
svgAttr(bendpointContainer, { 'data-element-id': newId });
}
}
});
// API

@@ -261,0 +275,0 @@

15

lib/features/modeling/cmd/DeleteShapeHandler.js

@@ -55,6 +55,9 @@ 'use strict';

// remove children
saveClear(shape.children, function(e) {
modeling.removeShape(e, { nested: true });
// remove child shapes and connections
saveClear(shape.children, function(child) {
if (isConnection(child)) {
modeling.removeConnection(child, { nested: true });
} else {
modeling.removeShape(child, { nested: true });
}
});

@@ -106,1 +109,5 @@ };

};
function isConnection(element) {
return element.waypoints;
}
{
"name": "diagram-js",
"version": "0.19.3",
"version": "0.19.4",
"description": "A modeling framework for the web",

@@ -5,0 +5,0 @@ "scripts": {

@@ -235,2 +235,22 @@ 'use strict';

describe('updating', function() {
it('should update on element updated ID', inject(function(selection, canvas, elementRegistry) {
// given
var layer = canvas.getLayer('overlays');
selection.select(connection);
// when
elementRegistry.updateId(connection, 'foo');
var bendpointContainer = domQuery('.djs-bendpoints', layer);
// then
// bendpoint container references element with updated ID
expect(bendpointContainer.dataset.elementId).to.equal('foo');
}));
});
});

@@ -8,3 +8,3 @@ 'use strict';

var changeSupportModule = require('../../../../lib/features/modeling'),
var modelingModule = require('../../../../lib/features/modeling'),
coreModule = require('../../../../lib/core');

@@ -18,3 +18,3 @@

coreModule,
changeSupportModule
modelingModule
]

@@ -51,3 +51,3 @@ }));

it('should emit element.changed event', inject(function(eventBus) {
it('should emit <element.changed> event', inject(function(eventBus) {

@@ -68,3 +68,3 @@ // given

it('should omit element.changed event for deleted shape',
it('should omit <element.changed> event for deleted shape',
inject(function(eventBus, modeling) {

@@ -85,3 +85,3 @@

it('should emit shape.changed event', inject(function(eventBus) {
it('should emit <shape.changed> event', inject(function(eventBus) {

@@ -101,3 +101,3 @@ // given

it('should emit connection.changed event', inject(function(eventBus) {
it('should emit <connection.changed> event', inject(function(eventBus) {

@@ -117,3 +117,3 @@ // given

it('should emit root.changed event', inject(function(eventBus) {
it('should emit <root.changed> event', inject(function(eventBus) {

@@ -132,2 +132,40 @@ // given

describe('command stack integration', function() {
it('should emit <element.changed> on execute', inject(function(eventBus, modeling) {
// given
var affectedElements = recordEvents(eventBus, 'element.changed');
// when
modeling.moveShape(shapeA, { x: 10, y: 5 });
// then
expect(affectedElements).to.eql([
shapeA
]);
}));
it('should emit <element.changed> on undo', inject(
function(eventBus, modeling, commandStack) {
// given
modeling.moveShape(shapeA, { x: 10, y: 5 });
var affectedElements = recordEvents(eventBus, 'element.changed');
// when
commandStack.undo();
// then
expect(affectedElements).to.eql([
shapeA
]);
})
);
});
});

@@ -134,0 +172,0 @@

@@ -18,3 +18,6 @@ 'use strict';

childShape2,
connection;
childShape3,
childShape4,
connection,
connection2;

@@ -37,6 +40,3 @@ beforeEach(bootstrapDiagram({ modules: [ modelingModule ] }));

canvas.addShape(parentShape, rootShape);
}));
beforeEach(inject(function(elementFactory, canvas) {
childShape = elementFactory.createShape({

@@ -64,2 +64,25 @@ id: 'child',

canvas.addConnection(connection, parentShape);
childShape3 = elementFactory.createShape({
id: 'child3',
x: 600, y: 100, width: 100, height: 100
});
canvas.addShape(childShape3, rootShape);
childShape4 = elementFactory.createShape({
id: 'child4',
x: 100, y: 500, width: 100, height: 100
});
canvas.addShape(childShape4, rootShape);
connection2 = elementFactory.createConnection({
id: 'connection2',
waypoints: [ { x: 650, y: 150 }, { x: 150, y: 550 } ],
source: childShape3,
target: childShape4
});
canvas.addConnection(connection2, parentShape);
}));

@@ -111,2 +134,4 @@

expect(connection.parent).to.be.null;
expect(childShape3.outgoing.length).to.equal(0);
expect(childShape4.incoming.length).to.equal(0);
}));

@@ -126,2 +151,4 @@

expect(connection.parent).to.equal(parentShape);
expect(childShape3.outgoing.length).to.equal(1);
expect(childShape4.incoming.length).to.equal(1);
}));

@@ -128,0 +155,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc