Explorar o código

prioritize the MutationObserver (microtask) approach

勾股 %!s(int64=10) %!d(string=hai) anos
pai
achega
38accc1755
Modificáronse 1 ficheiros con 3 adicións e 3 borrados
  1. 3 3
      src/util/env.js

+ 3 - 3
src/util/env.js

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