Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: keep object prototype when adding stubs #1075

Merged
merged 2 commits into from Dec 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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'))
})
})