Skip to content

Commit 6bdb577

Browse files
committed
fix name warning when instantiating extended components (fix #3472)
1 parent e62165c commit 6bdb577

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/core/util/options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ if (process.env.NODE_ENV !== 'production') {
3636
}
3737

3838
strats.name = function (parent, child, vm) {
39-
if (vm) {
39+
if (vm && child) {
4040
warn(
4141
'options "name" can only be used as a component definition option, ' +
4242
'not during instance creation.'

test/unit/features/options/name.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import Vue from 'vue'
22

33
describe('Options name', () => {
44
it('should warn when giving instance a name', () => {
5+
const Comp = Vue.component('custom', { name: 'custom' })
6+
new Comp()
7+
expect(`options "name" can only be used as a component definition option`).not.toHaveBeenWarned()
8+
59
new Vue({
610
name: 'SuperVue'
711
}).$mount()
8-
9-
/* eslint-disable */
10-
expect(`options "name" can only be used as a component definition option, not during instance creation.`)
11-
.toHaveBeenWarned()
12-
/* eslint-enable */
12+
expect(`options "name" can only be used as a component definition option`).toHaveBeenWarned()
1313
})
1414

1515
it('should contain itself in self components', () => {

0 commit comments

Comments
 (0)