fix(Viewer): trigger resized on attach

Ensure components get notified on `canvas.resized`, whenever
the Viewer instance gets attached.
This commit is contained in:
Nico Rehwaldt 2017-12-07 11:58:41 +01:00
parent 029c3d76aa
commit 50da47e1e1
2 changed files with 10 additions and 0 deletions

View File

@ -379,6 +379,8 @@ Viewer.prototype.attachTo = function(parentNode) {
parentNode.appendChild(this._container);
this._emit('attach', {});
this.get('canvas').resized();
};
Viewer.prototype.getDefinitions = function() {

View File

@ -962,12 +962,20 @@ describe('Viewer', function() {
// assume
expect(viewer._container.parentNode).not.to.exist;
/* global sinon */
var resizedSpy = sinon.spy();
viewer.on('canvas.resized', resizedSpy);
// when
viewer.attachTo(container);
// then
expect(viewer._container.parentNode).to.equal(container);
// should trigger resized
expect(resizedSpy).to.have.been.called;
done(err, warnings);
});
});