fix(viewer): do not clear diagram if no diagram to clear

Closes #1181
This commit is contained in:
Philipp Fromme 2019-09-20 12:55:20 +02:00 committed by fake-join[bot]
parent 83e9f05efa
commit f177a462ea
2 changed files with 24 additions and 0 deletions

View File

@ -479,6 +479,11 @@ Viewer.prototype.getModules = function() {
* @method Viewer#clear
*/
Viewer.prototype.clear = function() {
if (!this.getDefinitions()) {
// no diagram to clear
return;
}
// remove businessObject#di binding
//

View File

@ -1614,6 +1614,25 @@ describe('Viewer', function() {
describe('#clear', function() {
it('should NOT clear if no diagram', function() {
// given
var viewer = new Viewer({ container: container });
var eventBus = viewer.get('eventBus');
var spy = sinon.spy();
eventBus.on('diagram.clear', spy);
// when
viewer.clear();
// then
expect(spy).not.to.have.been.called;
});
it('should not throw if diagram is already empty', function() {
// given