Преглед изворни кода

Removed throttle when firing layoutChanged event.

Oskar Wróbel пре 7 година
родитељ
комит
b88af1c2b5

+ 1 - 11
packages/ckeditor5-engine/src/view/view.js

@@ -22,7 +22,6 @@ import CompositionObserver from './observer/compositionobserver';
 import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
 import log from '@ckeditor/ckeditor5-utils/src/log';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
-import throttle from '@ckeditor/ckeditor5-utils/src/lib/lodash/throttle';
 import { scrollViewportToShowTarget } from '@ckeditor/ckeditor5-utils/src/dom/scroll';
 import { injectUiElementHandling } from './uielement';
 import { injectQuirksHandling } from './filler';
@@ -135,14 +134,6 @@ export default class View {
 		 */
 		this._writer = new Writer( this.document );
 
-		/**
-		 * Fires throttled {@link module:engine/view/document~Document#event:layoutChanged} event.
-		 *
-		 * @protected
-		 * @type {Function}
-		 */
-		this._throttledLayoutChange = throttle( () => this.document.fire( 'layoutChanged' ), 200 );
-
 		// Add default observers.
 		this.addObserver( MutationObserver );
 		this.addObserver( SelectionObserver );
@@ -160,7 +151,7 @@ export default class View {
 			this._render();
 
 			// Informs that layout has changed after render.
-			this._throttledLayoutChange();
+			this.document.fire( 'layoutChanged' );
 		} );
 	}
 
@@ -390,7 +381,6 @@ export default class View {
 		}
 
 		this.stopListening();
-		this._throttledLayoutChange.cancel();
 	}
 
 	/**

+ 1 - 27
packages/ckeditor5-engine/tests/view/view/view.js

@@ -381,7 +381,7 @@ describe( 'view', () => {
 			sinon.assert.callOrder( observerMock.disable, renderStub, observerMock.enable );
 		} );
 
-		it( 'should fire throttled view.document.layoutChanged event after each render', () => {
+		it( 'should fire view.document.layoutChanged event on render', () => {
 			const spy = sinon.spy();
 
 			view.document.on( 'layoutChanged', spy );
@@ -392,12 +392,6 @@ describe( 'view', () => {
 
 			view.render();
 
-			// Still once because of throttle.
-			sinon.assert.calledOnce( spy );
-
-			view._throttledLayoutChange.flush();
-
-			// Twice after flushing throttled event.
 			sinon.assert.calledTwice( spy );
 		} );
 	} );
@@ -617,26 +611,6 @@ describe( 'view', () => {
 
 			sinon.assert.calledOnce( observerMock.destroy );
 		} );
-
-		it( 'should cancel throttled layoutChanged event', () => {
-			const view = new View();
-			const spy = sinon.spy();
-
-			view.document.on( 'layoutChanged', spy );
-
-			view.render();
-
-			sinon.assert.calledOnce( spy );
-
-			view.render();
-
-			view.destroy();
-
-			view._throttledLayoutChange.flush();
-
-			// Still once because second call was canceled.
-			sinon.assert.calledOnce( spy );
-		} );
 	} );
 
 	function createRoot( name, rootName, viewDoc ) {