Skip to content

Commit

Permalink
fix: nextTick support IE
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche committed Dec 1, 2017
1 parent ef9569a commit 738eee6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/nerv-utils/src/next-tick.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { isFunction } from './is'
const canUsePromise = 'Promise' in window

const resolved = Promise.resolve()
let resolved
if (canUsePromise) {
resolved = Promise.resolve()
}

const nextTick: (fn) => void = isFunction(Promise)
const nextTick: (fn) => void = canUsePromise
? (fn) => resolved.then(fn)
: isFunction(requestAnimationFrame)
? requestAnimationFrame
: setTimeout
: 'requestAnimationFrame' in window ? requestAnimationFrame : setTimeout

export default nextTick

0 comments on commit 738eee6

Please sign in to comment.