@@ -36,29 +36,34 @@ function batchedUpdates(callback) {
36
36
) ;
37
37
isBatchingUpdates = true ;
38
38
39
- callback ( ) ;
40
- // TODO: Sort components by depth such that parent components update first
41
- for ( var i = 0 ; i < dirtyComponents . length ; i ++ ) {
42
- // If a component is unmounted before pending changes apply, ignore them
43
- // TODO: Queue unmounts in the same list to avoid this happening at all
44
- var component = dirtyComponents [ i ] ;
45
- if ( component . isMounted ( ) ) {
46
- // If performUpdateIfNecessary happens to enqueue any new updates, we
47
- // shouldn't execute the callbacks until the next render happens, so
48
- // stash the callbacks first
49
- var callbacks = component . _pendingCallbacks ;
50
- component . _pendingCallbacks = null ;
51
- component . performUpdateIfNecessary ( ) ;
52
- if ( callbacks ) {
53
- for ( var j = 0 ; j < callbacks . length ; j ++ ) {
54
- callbacks [ j ] ( ) ;
39
+ try {
40
+ callback ( ) ;
41
+ // TODO: Sort components by depth such that parent components update first
42
+ for ( var i = 0 ; i < dirtyComponents . length ; i ++ ) {
43
+ // If a component is unmounted before pending changes apply, ignore them
44
+ // TODO: Queue unmounts in the same list to avoid this happening at all
45
+ var component = dirtyComponents [ i ] ;
46
+ if ( component . isMounted ( ) ) {
47
+ // If performUpdateIfNecessary happens to enqueue any new updates, we
48
+ // shouldn't execute the callbacks until the next render happens, so
49
+ // stash the callbacks first
50
+ var callbacks = component . _pendingCallbacks ;
51
+ component . _pendingCallbacks = null ;
52
+ component . performUpdateIfNecessary ( ) ;
53
+ if ( callbacks ) {
54
+ for ( var j = 0 ; j < callbacks . length ; j ++ ) {
55
+ callbacks [ j ] ( ) ;
56
+ }
55
57
}
56
58
}
57
59
}
60
+ } catch ( error ) {
61
+ // IE8 requires `catch` in order to use `finally`.
62
+ throw error ;
63
+ } finally {
64
+ dirtyComponents . length = 0 ;
65
+ isBatchingUpdates = false ;
58
66
}
59
- dirtyComponents . length = 0 ;
60
-
61
- isBatchingUpdates = false ;
62
67
}
63
68
64
69
/**
0 commit comments