@@ -4,7 +4,7 @@ import config from '../config'
4
4
import VNode , { emptyVNode } from '../vdom/vnode'
5
5
import { normalizeChildren } from '../vdom/helpers'
6
6
import {
7
- warn , bind , isObject , toObject ,
7
+ warn , formatComponentName , bind , isObject , toObject ,
8
8
nextTick , resolveAsset , _toString , toNumber
9
9
} from '../util/index'
10
10
@@ -48,19 +48,38 @@ export function renderMixin (Vue: Class<Component>) {
48
48
_parentVnode
49
49
} = vm . $options
50
50
51
- if ( staticRenderFns && ! this . _staticTrees ) {
52
- this . _staticTrees = [ ]
51
+ if ( staticRenderFns && ! vm . _staticTrees ) {
52
+ vm . _staticTrees = [ ]
53
53
}
54
54
// set parent vnode. this allows render functions to have access
55
55
// to the data on the placeholder node.
56
- this . $vnode = _parentVnode
56
+ vm . $vnode = _parentVnode
57
57
// resolve slots. becaues slots are rendered in parent scope,
58
58
// we set the activeInstance to parent.
59
59
if ( _renderChildren ) {
60
60
resolveSlots ( vm , _renderChildren )
61
61
}
62
62
// render self
63
- let vnode = render . call ( vm . _renderProxy , vm . $createElement )
63
+ let vnode
64
+ try {
65
+ vnode = render . call ( vm . _renderProxy , vm . $createElement )
66
+ } catch ( e ) {
67
+ if ( process . env . NODE_ENV !== 'production' ) {
68
+ warn ( `Error when rendering ${ formatComponentName ( vm ) } :` )
69
+ }
70
+ /* istanbul ignore else */
71
+ if ( config . errorHandler ) {
72
+ config . errorHandler . call ( null , e , vm )
73
+ } else {
74
+ if ( config . _isServer ) {
75
+ throw e
76
+ } else {
77
+ setTimeout ( ( ) => { throw e } , 0 )
78
+ }
79
+ }
80
+ // return previous vnode to prevent render error causing blank component
81
+ vnode = vm . _vnode
82
+ }
64
83
// return empty vnode in case the render function errored out
65
84
if ( ! ( vnode instanceof VNode ) ) {
66
85
if ( process . env . NODE_ENV !== 'production' && Array . isArray ( vnode ) ) {
0 commit comments