Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Commit

Permalink
Don't detach already detached jsPlumb connections (solves #1243)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinvdm committed Apr 14, 2015
1 parent 9df021b commit 1896573
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
8 changes: 3 additions & 5 deletions go/base/static/js/src/components/plumbing/connections.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,11 @@
},

destroy: function() {
var plumbConnection = this.plumbConnection;

if (plumbConnection) {
this.plumbConnection = null;
jsPlumb.detach(plumbConnection);
if (this.plumbConnection && this.plumbConnection.endpoints) {
jsPlumb.detach(this.plumbConnection);
}

this.plumbConnection = null;
return this;
},

Expand Down
20 changes: 16 additions & 4 deletions go/base/static/js/test/components/plumbing/connections.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,31 @@ describe("go.components.plumbing.connections", function() {
});

describe(".destroy", function() {
it("should remove the actual jsPlumb connection", function(done) {
it("should detach the connection", function(done) {
var plumbConnection = x3_y2.plumbConnection;

assert(plumbConnection);

jsPlumb.bind('connectionDetached', function(e) {
assert.equal(plumbConnection, e.connection);
assert.isNull(x3_y2.plumbConnection);
done();
});

x3_y2.destroy();
});

it("should unset the jsPlumb connection", function() {
assert.isNotNull(x3_y2.plumbConnection);
x3_y2.destroy();
assert.isNull(x3_y2.plumbConnection);
});

it("should not detach an already detached connection", function() {
var plumbConnection = x3_y2.plumbConnection;
var detached = false;
jsPlumb.detach(plumbConnection);
jsPlumb.bind('connectionDetached', function(e) { detached = true; });
x3_y2.destroy();
assert(!detached);
});
});

describe(".render", function() {
Expand Down

0 comments on commit 1896573

Please sign in to comment.