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

More informative warning message for comp name (closes #4428) #4429

Merged
merged 1 commit into from
Dec 9, 2016
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
3 changes: 2 additions & 1 deletion src/core/global-api/extend.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
)
}
}
Expand Down
11 changes: 10 additions & 1 deletion test/unit/features/options/name.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
})
Expand Down