Explorar o código

Removed throttle when firing update event.

Oskar Wróbel %!s(int64=7) %!d(string=hai) anos
pai
achega
0628e85a02

+ 2 - 15
packages/ckeditor5-core/src/editor/editorui.js

@@ -12,7 +12,6 @@ import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker';
 
 import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
-import throttle from '@ckeditor/ckeditor5-utils/src/lib/lodash/throttle';
 
 /**
  * A class providing the minimal interface that is required to successfully bootstrap any editor UI.
@@ -61,23 +60,15 @@ export default class EditorUI {
 		 */
 		this.focusTracker = new FocusTracker();
 
-		/**
-		 * Fires throttled {@link module:core/editor/editorui~EditorUI#event:update} event.
-		 *
-		 * @protected
-		 * @type {Function}
-		 */
-		this._throttledUpdate = throttle( () => this.fire( 'update' ), 5 );
-
 		// Informs UI components that should be refreshed after layout change.
 		this.listenTo( editor.editing.view.document, 'layoutChanged', () => this.update() );
 	}
 
 	/**
-	 * Fires the (throttled) {@link module:core/editor/editorui~EditorUI#event:update} event.
+	 * Fires the {@link module:core/editor/editorui~EditorUI#event:update} event.
 	 */
 	update() {
-		this._throttledUpdate();
+		this.fire( 'update' );
 	}
 
 	/**
@@ -85,7 +76,6 @@ export default class EditorUI {
 	 */
 	destroy() {
 		this.stopListening();
-		this._throttledUpdate.cancel();
 		this.view.destroy();
 	}
 
@@ -95,9 +85,6 @@ export default class EditorUI {
 	 * **Note:**: The event is fired after each {@link module:engine/view/document~Document#event:layoutChanged}.
 	 * It can also be fired manually via the {@link module:core/editor/editorui~EditorUI#update} method.
 	 *
-	 * **Note:**: Successive `update` events will throttled (5ms) to improve the performance of the UI
-	 * and the overall responsiveness of the editor.
-	 *
 	 * @event update
 	 */
 }

+ 2 - 27
packages/ckeditor5-core/tests/editor/editorui.js

@@ -47,7 +47,7 @@ describe( 'EditorUI', () => {
 			expect( ui.focusTracker ).to.be.instanceOf( FocusTracker );
 		} );
 
-		it( 'should fire throttled update event after viewDocument#layoutChanged', () => {
+		it( 'should fire update event after viewDocument#layoutChanged', () => {
 			const spy = sinon.spy();
 
 			ui.on( 'update', spy );
@@ -58,16 +58,12 @@ describe( 'EditorUI', () => {
 
 			editor.editing.view.document.fire( 'layoutChanged' );
 
-			sinon.assert.calledOnce( spy );
-
-			ui._throttledUpdate.flush();
-
 			sinon.assert.calledTwice( spy );
 		} );
 	} );
 
 	describe( 'update()', () => {
-		it( 'should fire throttled update event', () => {
+		it( 'should fire update event', () => {
 			const spy = sinon.spy();
 
 			ui.on( 'update', spy );
@@ -78,10 +74,6 @@ describe( 'EditorUI', () => {
 
 			ui.update();
 
-			sinon.assert.calledOnce( spy );
-
-			ui._throttledUpdate.flush();
-
 			sinon.assert.calledTwice( spy );
 		} );
 	} );
@@ -102,22 +94,5 @@ describe( 'EditorUI', () => {
 
 			sinon.assert.called( spy );
 		} );
-
-		it( 'should cancel throttled update event', () => {
-			const spy = sinon.spy();
-
-			ui.on( 'update', spy );
-
-			ui.update();
-
-			sinon.assert.calledOnce( spy );
-
-			ui.destroy();
-
-			ui.update();
-			ui._throttledUpdate.flush();
-
-			sinon.assert.calledOnce( spy );
-		} );
 	} );
 } );