(fn, bookkeeping)
| 2957 | |
| 2958 | var isBatching = false; |
| 2959 | function batchedUpdates(fn, bookkeeping) { |
| 2960 | if (isBatching) { |
| 2961 | // If we are currently inside another batch, we need to wait until it |
| 2962 | // fully completes before restoring state. |
| 2963 | return fn(bookkeeping); |
| 2964 | } |
| 2965 | isBatching = true; |
| 2966 | try { |
| 2967 | return _batchedUpdates(fn, bookkeeping); |
| 2968 | } finally { |
| 2969 | // Here we wait until all updates have propagated, which is important |
| 2970 | // when using controlled components within layers: |
| 2971 | // https://github.com/facebook/react/issues/1698 |
| 2972 | // Then we restore state of any controlled component. |
| 2973 | isBatching = false; |
| 2974 | var controlledComponentsHavePendingUpdates = needsStateRestore(); |
| 2975 | if (controlledComponentsHavePendingUpdates) { |
| 2976 | // If a controlled event was fired, we may need to restore the state of |
| 2977 | // the DOM node back to the controlled value. This is necessary when React |
| 2978 | // bails out of the update without touching the DOM. |
| 2979 | _flushInteractiveUpdates(); |
| 2980 | restoreStateIfNeeded(); |
| 2981 | } |
| 2982 | } |
| 2983 | } |
| 2984 | |
| 2985 | function interactiveUpdates(fn, a, b) { |
| 2986 | return _interactiveUpdates(fn, a, b); |
no test coverage detected