Skip to content

Commit

Permalink
fix: fallback to Promise in non-DOM environments
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Oct 5, 2017
1 parent 6e41679 commit 6d1f4cb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/core/util/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ export const nextTick = (function () {
timerFunc = () => {
port.postMessage(1)
}
} else if (typeof Promise !== 'undefined' && isNative(Promise)) {
// use microtask in non-DOM environments, e.g. Weex
const p = Promise.resolve()
timerFunc = () => {
p.then(nextTickHandler)
}
} else {
// fallback to setTimeout
/* istanbul ignore next */
Expand Down

0 comments on commit 6d1f4cb

Please sign in to comment.