Skip to content

Commit 12cd46d

Browse files
kazuponyyx990803
authored andcommitted
fix 'name' option issue (vuejs#3040)
ref: vuejs#3039
1 parent ccd8700 commit 12cd46d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/global-api.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ export default function (Vue) {
210210
type === 'component' &&
211211
isPlainObject(definition)
212212
) {
213-
definition.name = id
213+
if (!definition.name) {
214+
definition.name = id
215+
}
214216
definition = Vue.extend(definition)
215217
}
216218
this.options[type + 's'][id] = definition

test/unit/specs/global_api_spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,14 @@ describe('Global API', function () {
112112
// extended registration should not pollute global
113113
expect(Vue.options.components.test).toBeUndefined()
114114
})
115+
116+
// GitHub issue #3039
117+
it('component with `name` option', function () {
118+
var def = { name: 'Component1' }
119+
Test.component('ns-tree', def)
120+
var component = Test.options.components['ns-tree']
121+
expect(typeof component).toBe('function')
122+
expect(component.name).toBe('Component1')
123+
})
115124
})
116125
})

0 commit comments

Comments
 (0)