Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/core/util/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import config from '../config'
import { warn } from './debug'
import { nativeWatch } from './env'
import { set } from '../observer/index'
import { hyphenate } from '../../shared/util'

import {
ASSET_TYPES,
Expand Down Expand Up @@ -260,7 +261,8 @@ export function validateComponentName (name: string) {
'and must start with a letter.'
)
}
if (isBuiltInTag(name) || config.isReservedTag(name)) {
const hyphenatedName = hyphenate(name)
if (isBuiltInTag(hyphenatedName) || config.isReservedTag(hyphenatedName)) {
warn(
'Do not use built-in or reserved HTML elements as component ' +
'id: ' + name
Expand Down
9 changes: 9 additions & 0 deletions test/unit/features/options/components.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ describe('Options components', () => {
expect('Do not use built-in or reserved HTML elements as component').toHaveBeenWarned()
})

it('should warn component names translated into native HTML elements', () => {
new Vue({
components: {
Div: { template: '<div></div>' }
}
})
expect('Do not use built-in or reserved HTML elements as component').toHaveBeenWarned()
})

it('should warn built-in elements', () => {
new Vue({
components: {
Expand Down