Skip to content

Commit e65bca5

Browse files
fix: Support non-browser environments
1 parent a380f11 commit e65bca5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/helpers/setAnimationFrameTimeout.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ export function clearAnimationFrameTimeout(canceller: Canceller) {
2727
cancelAnimationFrame(canceller.id)
2828
}
2929

30+
const isBrowser = typeof document !== 'undefined'
31+
3032
export function nextTick(callback: () => unknown) {
33+
if (!isBrowser)
34+
return setAnimationFrameTimeout(callback, 0)
35+
3136
return setTimeout(() => {
3237
// Reading document.body.offsetTop can force browser to repaint before transition to the next state
3338
Number.isNaN(document.body.offsetTop) || callback()

0 commit comments

Comments
 (0)