Browse Source

improve util.nextTick by setImmediate

勾股 10 years ago
parent
commit
cc705567eb
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/util/env.js

+ 4 - 1
src/util/env.js

@@ -70,8 +70,11 @@ export const nextTick = (function () {
       copies[i]()
     }
   }
+
   /* istanbul ignore if */
-  if (typeof MutationObserver !== 'undefined') {
+  if (typeof setImmediate === 'function') {
+    timerFunc = setImmediate
+  } else if (typeof MutationObserver !== 'undefined') {
     var counter = 1
     var observer = new MutationObserver(nextTickHandler)
     var textNode = document.createTextNode(counter)