-
Notifications
You must be signed in to change notification settings - Fork 667
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: no unnecessary extend #1084
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -292,29 +292,21 @@ When `sync` is `false`, the Vue component is rendered asynchronously. | |
|
||
## Other options | ||
|
||
When the options for `mount` and `shallowMount` contain the options other than the mounting options, the component options are overwritten with those using [extends](https://vuejs.org/v2/api/#extends). | ||
When the options for `mount` and `shallowMount` contain the options other than the mounting options, the options are added used when the Vue instance is initialized. | ||
|
||
```js | ||
const Component = { | ||
template: '<div>{{ foo() }}{{ bar() }}{{ baz() }}</div>', | ||
methods: { | ||
foo () { | ||
return 'a' | ||
}, | ||
bar () { | ||
return 'b' | ||
} | ||
} | ||
template: ` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This example could be improved to make context more clear. |
||
<div> | ||
id: {$route.params.id} | ||
username: {$store.state.username} | ||
</div> | ||
` | ||
} | ||
|
||
const options = { | ||
methods: { | ||
bar () { | ||
return 'B' | ||
}, | ||
baz () { | ||
return 'C' | ||
} | ||
} | ||
store, | ||
route | ||
} | ||
const wrapper = mount(Component, options) | ||
expect(wrapper.text()).toBe('aBC') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,8 +90,8 @@ export default function createInstance ( | |
// extend component from _Vue to add properties and mixins | ||
// extend does not work correctly for sub class components in Vue < 2.2 | ||
const Constructor = typeof component === 'function' | ||
? _Vue.extend(component.options).extend(instanceOptions) | ||
: _Vue.extend(component).extend(instanceOptions) | ||
? _Vue.extend(component.options) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
: _Vue.extend(component) | ||
|
||
// used to identify extended component using constructor | ||
Constructor.options.$_vueTestUtils_original = component | ||
|
@@ -151,5 +151,5 @@ export default function createInstance ( | |
} | ||
const Parent = _Vue.extend(parentComponentOptions) | ||
|
||
return new Parent() | ||
return new Parent(instanceOptions) | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the options for
mount
andshallowMount
contain the options other than the mounting options, the options are addedusedwhen the Vue instance is initialized.