Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: keep components when adding stubs (#1075)
  • Loading branch information
eddyerburgh committed Dec 22, 2018
1 parent d4c118b commit 5e92c10
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
5 changes: 2 additions & 3 deletions packages/create-instance/patch-render.js
Expand Up @@ -108,10 +108,9 @@ export function patchRender (_Vue, stubs, stubAllComponents) {
const stub = createStubIfNeeded(stubAllComponents, original, _Vue, el)

if (stub) {
vm.$options.components = {
...vm.$options.components,
Object.assign(vm.$options.components, {
[el]: stub
}
})
modifiedComponents.add(el)
}
}
Expand Down
30 changes: 28 additions & 2 deletions test/specs/shallow-mount.spec.js
Expand Up @@ -13,8 +13,8 @@ import { describeRunIf, itDoNotRunIf } from 'conditional-specs'

describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => {
beforeEach(() => {
sinon.stub(console, 'info')
sinon.stub(console, 'error')
sinon.stub(console, 'info').callThrough()
sinon.stub(console, 'error').callThrough()
})

afterEach(() => {
Expand Down Expand Up @@ -490,4 +490,30 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => {
'</div>'
)
})

itDoNotRunIf(
vueVersion < 2.1,
'does not error when rendering a previously stubbed component', () => {
const ChildComponent = {
render: h => h('div')
}
const TestComponent = {
template: `
<div>
<extended-component />
<keep-alive>
<child-component />
</keep-alive>
</div>
`,
components: {
ExtendedComponent: Vue.extend({ render: h => h('div') }),
ChildComponent
}
}
shallowMount(TestComponent)
mount(TestComponent)
expect(console.error)
.not.calledWith(sinon.match('Unknown custom element'))
})
})

0 comments on commit 5e92c10

Please sign in to comment.