@@ -8,7 +8,7 @@ import { throwError, warn, vueVersion } from 'shared/util'
8
8
import { compileTemplate } from 'shared/compile-template'
9
9
import extractInstanceOptions from './extract-instance-options'
10
10
import createFunctionalComponent from './create-functional-component'
11
- import { componentNeedsCompiling } from 'shared/validators'
11
+ import { componentNeedsCompiling , isPlainObject } from 'shared/validators'
12
12
import { validateSlots } from './validate-slots'
13
13
import createScopedSlots from './create-scoped-slots'
14
14
@@ -138,25 +138,32 @@ export default function createInstance (
138
138
139
139
const scopedSlots = createScopedSlots ( options . scopedSlots )
140
140
141
- const Parent = _Vue . extend ( {
142
- provide: options . provide ,
143
- render ( h ) {
144
- const slots = options . slots
145
- ? createSlotVNodes ( this , options . slots )
146
- : undefined
147
- return h (
148
- Constructor ,
149
- {
150
- ref : 'vm' ,
151
- props : options . propsData ,
152
- on : options . listeners ,
153
- attrs : options . attrs ,
154
- scopedSlots
155
- } ,
156
- slots
157
- )
158
- }
159
- } )
141
+ if ( options . parentComponent && ! isPlainObject ( options . parentComponent ) ) {
142
+ throwError (
143
+ `options.parentComponent should be a valid Vue component ` +
144
+ `options object`
145
+ )
146
+ }
147
+
148
+ const parentComponentOptions = options . parentComponent || { }
149
+ parentComponentOptions . provide = options . provide
150
+ parentComponentOptions . render = function ( h ) {
151
+ const slots = options . slots
152
+ ? createSlotVNodes ( this , options . slots )
153
+ : undefined
154
+ return h (
155
+ Constructor ,
156
+ {
157
+ ref : 'vm' ,
158
+ props : options . propsData ,
159
+ on : options . listeners ,
160
+ attrs : options . attrs ,
161
+ scopedSlots
162
+ } ,
163
+ slots
164
+ )
165
+ }
166
+ const Parent = _Vue . extend ( parentComponentOptions )
160
167
161
168
return new Parent ( )
162
169
}
0 commit comments