Divec has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/178263

Change subject: Track state properly at the end of an event loop.
......................................................................

Track state properly at the end of an event loop.

Previously, doneOnLoop was only reset if the user set an after*Listener.

Change-Id: I5a043ee277504fe47c82d4c5409e54a8c39f2b10
---
M src/ve.EventSequencer.js
1 file changed, 18 insertions(+), 23 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/63/178263/1

diff --git a/src/ve.EventSequencer.js b/src/ve.EventSequencer.js
index 855b98a..e1d8523 100644
--- a/src/ve.EventSequencer.js
+++ b/src/ve.EventSequencer.js
@@ -256,29 +256,24 @@
                onListener = onListeners[i];
                this.callListener( 'on', eventName, i, onListener, ev );
        }
-       // Queue a call to afterEvent only if there are some
-       // afterListeners/afterOneListeners/afterLoopListeners
-       if ( ( this.afterListenersForEvent[eventName] || [] ).length > 0 ||
-               ( this.afterOneListenersForEvent[eventName] || [] ).length > 0 
||
-               this.afterLoopListeners.length > 0 ) {
-               // Create a cancellable pending call
-               // - Create the pendingCall object first
-               // - then create the setTimeout invocation to modify 
pendingCall.id
-               // - then set pendingCall.id to the setTimeout id, so the call 
can cancel itself
-               pendingCall = { id: null, ev: ev, eventName: eventName };
-               eventSequencer = this;
-               id = this.postpone( function () {
-                       if ( pendingCall.id === null ) {
-                               // clearTimeout seems not always to work 
immediately
-                               return;
-                       }
-                       eventSequencer.resetAfterLoopTimeout();
-                       pendingCall.id = null;
-                       eventSequencer.afterEvent( eventName, ev );
-               } );
-               pendingCall.id = id;
-               this.pendingCalls.push( pendingCall );
-       }
+       // Create a cancellable pending call. We need one even if there are no 
after*Listeners, to
+       // call resetAfterLoopTimeout which resets doneOneLoop to false.
+       // - Create the pendingCall object first
+       // - then create the setTimeout invocation to modify pendingCall.id
+       // - then set pendingCall.id to the setTimeout id, so the call can 
cancel itself
+       pendingCall = { id: null, ev: ev, eventName: eventName };
+       eventSequencer = this;
+       id = this.postpone( function () {
+               if ( pendingCall.id === null ) {
+                       // clearTimeout seems not always to work immediately
+                       return;
+               }
+               eventSequencer.resetAfterLoopTimeout();
+               pendingCall.id = null;
+               eventSequencer.afterEvent( eventName, ev );
+       } );
+       pendingCall.id = id;
+       this.pendingCalls.push( pendingCall );
 };
 
 /**

-- 
To view, visit https://gerrit.wikimedia.org/r/178263
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5a043ee277504fe47c82d4c5409e54a8c39f2b10
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Divec <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to