瀏覽代碼

prioritize the MutationObserver (microtask) approach

勾股 10 年之前
父節點
當前提交
38accc1755
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      src/util/env.js

+ 3 - 3
src/util/env.js

@@ -72,9 +72,7 @@ export const nextTick = (function () {
   }
 
   /* istanbul ignore if */
-  if (typeof setImmediate === 'function') {
-    timerFunc = setImmediate
-  } else if (typeof MutationObserver !== 'undefined') {
+  if (typeof MutationObserver !== 'undefined') {
     var counter = 1
     var observer = new MutationObserver(nextTickHandler)
     var textNode = document.createTextNode(counter)
@@ -85,6 +83,8 @@ export const nextTick = (function () {
       counter = (counter + 1) % 2
       textNode.data = counter
     }
+  } else if (typeof setImmediate === 'function') {
+    timerFunc = setImmediate
   } else {
     timerFunc = setTimeout
   }