@@ -8,7 +8,7 @@ import { throwError, warn, vueVersion } from 'shared/util'
88import { compileTemplate } from 'shared/compile-template'
99import extractInstanceOptions from './extract-instance-options'
1010import createFunctionalComponent from './create-functional-component'
11- import { componentNeedsCompiling } from 'shared/validators'
11+ import { componentNeedsCompiling , isPlainObject } from 'shared/validators'
1212import { validateSlots } from './validate-slots'
1313import createScopedSlots from './create-scoped-slots'
1414
@@ -138,25 +138,32 @@ export default function createInstance (
138138
139139 const scopedSlots = createScopedSlots ( options . scopedSlots )
140140
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 )
160167
161168 return new Parent ( )
162169}
0 commit comments