@@ -404,15 +404,14 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
404404 }
405405 }
406406
407- function scheduleSynchronousWork ( root : FiberRoot ) {
408- root . current . pendingWorkPriority = SynchronousPriority ;
409-
410- // Perform work now
411- nextUnitOfWork = findNextUnitOfWork ( ) ;
407+ function performSynchronousWork ( ) {
408+ if ( ! nextUnitOfWork ) {
409+ nextUnitOfWork = findNextUnitOfWork ( ) ;
410+ }
412411 while ( nextUnitOfWork &&
413412 nextPriorityLevel === SynchronousPriority ) {
414413 nextUnitOfWork = performUnitOfWork ( nextUnitOfWork ) ;
415- // If there's no nextUnitForWork , we don't need to search for more
414+ // If there's no nextUnitOfWork , we don't need to search for more
416415 // because it shouldn't be possible to schedule sync work without
417416 // immediately performing it
418417 }
@@ -425,6 +424,11 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
425424 }
426425 }
427426
427+ function scheduleSynchronousWork ( root : FiberRoot ) {
428+ root . current . pendingWorkPriority = SynchronousPriority ;
429+ performSynchronousWork ( ) ;
430+ }
431+
428432 function scheduleWork ( root : FiberRoot , priorityLevel : ?PriorityLevel ) : void {
429433 // Use priority context if no priority is provided
430434 if ( priorityLevel == null ) {
@@ -433,13 +437,12 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
433437 defaultPriorityContext ;
434438 }
435439
436- if ( priorityLevel === SynchronousPriority ) {
437- scheduleSynchronousWork ( root ) ;
438- }
439-
440440 if ( priorityLevel === NoWork ) {
441441 return ;
442442 }
443+ if ( priorityLevel === SynchronousPriority ) {
444+ scheduleSynchronousWork ( root ) ;
445+ }
443446 if ( priorityLevel > AnimationPriority ) {
444447 scheduleDeferredWork ( root , priorityLevel ) ;
445448 return ;
@@ -455,6 +458,13 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
455458 defaultPriorityContext ;
456459 }
457460
461+ if ( priorityLevel === SynchronousPriority ) {
462+ fiber . pendingWorkPriority = SynchronousPriority ;
463+ nextUnitOfWork = fiber ;
464+ performSynchronousWork ( ) ;
465+ return ;
466+ }
467+
458468 while ( true ) {
459469 if ( fiber . pendingWorkPriority === NoWork ||
460470 fiber . pendingWorkPriority >= priorityLevel ) {
0 commit comments