Skip to content

Commit

Permalink
fix: allow extended components as stubs (#825)
Browse files Browse the repository at this point in the history
  • Loading branch information
kellym authored and eddyerburgh committed Jul 14, 2018
1 parent 4f9af82 commit 65449b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 5 additions & 4 deletions packages/shared/stub-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@ import {
} from './util'
import {
componentNeedsCompiling,
templateContainsComponent
templateContainsComponent,
isVueComponent
} from './validators'
import { compileTemplate } from './compile-template'

function isVueComponent (comp): boolean {
return comp && (comp.render || comp.template || comp.options)
function isVueComponentStub (comp): boolean {
return comp && comp.template || isVueComponent(comp)
}

function isValidStub (stub: any): boolean {
return (
(!!stub && typeof stub === 'string') ||
stub === true ||
isVueComponent(stub)
isVueComponentStub(stub)
)
}

Expand Down
6 changes: 4 additions & 2 deletions test/specs/mounting-options/stubs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ describeWithMountingMethods('options.stub', mountingMethod => {
it('accepts valid component stubs', () => {
const ComponentWithRender = { render: h => h('div') }
const ComponentWithoutRender = { template: '<div></div>' }
const ExtendedComponent = Vue.extend({ template: '<div></div>' })
const ExtendedComponent = { extends: ComponentWithRender }
const SubclassedComponent = Vue.extend({ template: '<div></div>' })
mountingMethod(ComponentWithChild, {
stubs: {
ChildComponent: ComponentAsAClass,
ChildComponent2: ComponentWithRender,
ChildComponent3: ComponentWithoutRender,
ChildComponent4: ExtendedComponent
ChildComponent4: ExtendedComponent,
ChildComponent5: SubclassedComponent
}
})
})
Expand Down

0 comments on commit 65449b3

Please sign in to comment.