File tree 3 files changed +24
-5
lines changed
3 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ Vue.prototype.$mount = function (
44
44
45
45
// devtools global hook
46
46
/* istanbul ignore next */
47
- setTimeout ( ( ) => {
47
+ Vue . nextTick ( ( ) => {
48
48
if ( config . devtools ) {
49
49
if ( devtools ) {
50
50
devtools . emit ( 'init' , Vue )
Original file line number Diff line number Diff line change @@ -58,9 +58,11 @@ if (hasTransition) {
58
58
}
59
59
60
60
// binding to window is necessary to make hot reload work in IE in strict mode
61
- const raf = inBrowser && window . requestAnimationFrame
62
- ? window . requestAnimationFrame . bind ( window )
63
- : setTimeout
61
+ const raf = inBrowser
62
+ ? window . requestAnimationFrame
63
+ ? window . requestAnimationFrame . bind ( window )
64
+ : setTimeout
65
+ : /* istanbul ignore next */ fn => fn ( )
64
66
65
67
export function nextFrame ( fn : Function ) {
66
68
raf ( ( ) => {
Original file line number Diff line number Diff line change 1
1
/* @flow */
2
2
3
3
const MAX_STACK_DEPTH = 1000
4
+ const noop = _ => _
5
+
6
+ const defer = typeof process !== 'undefined' && process . nextTick
7
+ ? process . nextTick
8
+ : typeof Promise !== 'undefined'
9
+ ? fn => Promise . resolve ( ) . then ( fn )
10
+ : typeof setTimeout !== 'undefined'
11
+ ? setTimeout
12
+ : noop
13
+
14
+ if ( defer === noop ) {
15
+ throw new Error (
16
+ 'Your JavaScript runtime does not support any asynchronous primitives ' +
17
+ 'that are required by vue-server-renderer. Please use a polyfill for ' +
18
+ 'either Promise or setTimeout.'
19
+ )
20
+ }
4
21
5
22
export function createWriteFunction (
6
23
write : ( text : string , next : Function ) = > boolean ,
@@ -14,7 +31,7 @@ export function createWriteFunction (
14
31
const waitForNext = write ( text , next )
15
32
if ( waitForNext !== true ) {
16
33
if ( stackDepth >= MAX_STACK_DEPTH ) {
17
- process . nextTick ( ( ) => {
34
+ defer ( ( ) => {
18
35
try { next ( ) } catch ( e ) {
19
36
onError ( e )
20
37
}
You can’t perform that action at this time.
0 commit comments