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

Commit

Permalink
Fix: Call ResizeObserver.destroy() when destroying block toolbar.
Browse files Browse the repository at this point in the history
  • Loading branch information
jodator committed Apr 14, 2020
1 parent fcd9c4e commit 59449d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/toolbar/block/blocktoolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ export default class BlockToolbar extends Plugin {
this.panelView.destroy();
this.buttonView.destroy();
this.toolbarView.destroy();

if ( this._resizeObserver ) {
this._resizeObserver.destroy();
}
}

/**
Expand Down
14 changes: 14 additions & 0 deletions tests/toolbar/block/blocktoolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -676,4 +676,18 @@ describe( 'BlockToolbar', () => {
sinon.assert.notCalled( spy );
} );
} );

describe( 'destroy()', () => {
it( 'should destroy #resizeObserver if is available', () => {
const editable = editor.ui.getEditableElement();
const resizeObserver = new ResizeObserver( editable, () => {} );
const destroySpy = sinon.spy( resizeObserver, 'destroy' );

blockToolbar._resizeObserver = resizeObserver;

blockToolbar.destroy();

sinon.assert.calledOnce( destroySpy );
} );
} );
} );

0 comments on commit 59449d2

Please sign in to comment.