Skip to content

Commit 65449b3

Browse files
kellymeddyerburgh
authored andcommitted
fix: allow extended components as stubs (#825)
1 parent 4f9af82 commit 65449b3

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Diff for: packages/shared/stub-components.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,20 @@ import {
1010
} from './util'
1111
import {
1212
componentNeedsCompiling,
13-
templateContainsComponent
13+
templateContainsComponent,
14+
isVueComponent
1415
} from './validators'
1516
import { compileTemplate } from './compile-template'
1617

17-
function isVueComponent (comp): boolean {
18-
return comp && (comp.render || comp.template || comp.options)
18+
function isVueComponentStub (comp): boolean {
19+
return comp && comp.template || isVueComponent(comp)
1920
}
2021

2122
function isValidStub (stub: any): boolean {
2223
return (
2324
(!!stub && typeof stub === 'string') ||
2425
stub === true ||
25-
isVueComponent(stub)
26+
isVueComponentStub(stub)
2627
)
2728
}
2829

Diff for: test/specs/mounting-options/stubs.spec.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ describeWithMountingMethods('options.stub', mountingMethod => {
3333
it('accepts valid component stubs', () => {
3434
const ComponentWithRender = { render: h => h('div') }
3535
const ComponentWithoutRender = { template: '<div></div>' }
36-
const ExtendedComponent = Vue.extend({ template: '<div></div>' })
36+
const ExtendedComponent = { extends: ComponentWithRender }
37+
const SubclassedComponent = Vue.extend({ template: '<div></div>' })
3738
mountingMethod(ComponentWithChild, {
3839
stubs: {
3940
ChildComponent: ComponentAsAClass,
4041
ChildComponent2: ComponentWithRender,
4142
ChildComponent3: ComponentWithoutRender,
42-
ChildComponent4: ExtendedComponent
43+
ChildComponent4: ExtendedComponent,
44+
ChildComponent5: SubclassedComponent
4345
}
4446
})
4547
})

0 commit comments

Comments
 (0)