mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-03 20:47:36 +08:00
More informative warning message for comp name (#4429)
This commit adds a more informative warning message for invalid component names. Also fixes a typo. Closes #4428.
This commit is contained in:
parent
29d6e33b33
commit
962b778e10
@ -28,7 +28,8 @@ export function initExtend (Vue: GlobalAPI) {
|
||||
if (!/^[a-zA-Z][\w-]*$/.test(name)) {
|
||||
warn(
|
||||
'Invalid component name: "' + name + '". Component names ' +
|
||||
'can only contain alphanumeric characaters and the hyphen.'
|
||||
'can only contain alphanumeric characters and the hyphen, ' +
|
||||
'and must start with a letter.'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,16 @@ describe('Options name', () => {
|
||||
})
|
||||
|
||||
/* eslint-disable */
|
||||
expect(`Invalid component name: "Hyper*Vue". Component names can only contain alphanumeric characaters and the hyphen.`)
|
||||
expect(`Invalid component name: "Hyper*Vue". Component names can only contain alphanumeric characters and the hyphen, and must start with a letter.`)
|
||||
.toHaveBeenWarned()
|
||||
/* eslint-enable */
|
||||
|
||||
Vue.extend({
|
||||
name: '2Cool2BValid'
|
||||
})
|
||||
|
||||
/* eslint-disable */
|
||||
expect(`Invalid component name: "2Cool2BValid". Component names can only contain alphanumeric characters and the hyphen, and must start with a letter.`)
|
||||
.toHaveBeenWarned()
|
||||
/* eslint-enable */
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user