Explorar el Código

Fix: Call `ResizeObserver.destroy()` when destroying block toolbar.

Maciej Gołaszewski hace 5 años
padre
commit
a0bf22cd10

+ 4 - 0
packages/ckeditor5-ui/src/toolbar/block/blocktoolbar.js

@@ -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();
+		}
 	}
 
 	/**

+ 14 - 0
packages/ckeditor5-ui/tests/toolbar/block/blocktoolbar.js

@@ -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 );
+		} );
+	} );
 } );