@@ -30,6 +30,13 @@ function flushCallbacks () {
30
30
// where microtasks have too high a priority and fire in between supposedly
31
31
// sequential events (e.g. #4521, #6690, which have workarounds)
32
32
// or even between bubbling of the same event (#6566).
33
+
34
+ // 这里我们有一个使用microtasks来实现的异步延迟包装器
35
+ // 在2.5版本我们使用macrotasks(结合microtasks)
36
+ // 然而,如果在重绘前改变了状态,那么这么做会有微妙的问题(例如 #6813 out-in过渡,改变的状态在下一个tick才会生效,导致css先生效,页面闪一下)
37
+ // 而且,在事件处理器中使用macrotasks,会导致一些奇怪的行为并且无法规避(例如 #7109, #7153, #7546, #7834, #8109)
38
+ // 所以我们再次在各处使用microtasks
39
+ // 这种权衡的一个主要缺点是,在某些情况下微任务具有过高的优先级,并且在本应该按顺序发生的事件之间执行,甚至是同一事件源冒泡监听回调之间执行(#6566)
33
40
let timerFunc
34
41
35
42
// The nextTick behavior leverages the microtask queue, which can be accessed
@@ -38,6 +45,11 @@ let timerFunc
38
45
// UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
39
46
// completely stops working after triggering a few times... so, if native
40
47
// Promise is available, we will use it:
48
+
49
+ // nextTick函数的行为,改变了microtask队列。microtask队列可以通过原生的Promise.then或者MutationObserver改变
50
+ // MutationObserver有着广泛的支持,然而在iOS >= 9.3.3的UIWebView上,当在触摸事件处理函数上触发MutationObserver时有着严重的bug
51
+ // 在触发了几次之后,MutationObserver完全停止了工作
52
+ // 所以,如果原生的Promise是可用的,我们将使用原生Promise
41
53
/* istanbul ignore next, $flow-disable-line */
42
54
if ( typeof Promise !== 'undefined' && isNative ( Promise ) ) {
43
55
const p = Promise . resolve ( )
0 commit comments