File tree Expand file tree Collapse file tree 4 files changed +20
-7
lines changed Expand file tree Collapse file tree 4 files changed +20
-7
lines changed Original file line number Diff line number Diff line change 66 classify ,
77 toArray ,
88 commonTagRE ,
9+ reservedTagRE ,
910 warn ,
1011 isPlainObject
1112} from '../../util/index'
@@ -167,9 +168,12 @@ export default function (Vue) {
167168 } else {
168169 /* istanbul ignore if */
169170 if ( process . env . NODE_ENV !== 'production' ) {
170- if ( type === 'component' && commonTagRE . test ( id ) ) {
171+ if (
172+ type === 'component' &&
173+ ( commonTagRE . test ( id ) || reservedTagRE . test ( id ) )
174+ ) {
171175 warn (
172- 'Do not use built-in HTML elements as component ' +
176+ 'Do not use built-in or reserved HTML elements as component ' +
173177 'id: ' + id
174178 )
175179 }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { getAttr, getBindAttr } from './dom'
44import { isArray , isPlainObject } from './lang'
55
66export const commonTagRE = / ^ ( d i v | p | s p a n | i m g | a | b | i | b r | u l | o l | l i | h 1 | h 2 | h 3 | h 4 | h 5 | h 6 | c o d e | p r e | t a b l e | t h | t d | t r | f o r m | l a b e l | i n p u t | s e l e c t | o p t i o n | n a v | a r t i c l e | s e c t i o n | h e a d e r | f o o t e r ) $ /
7+ export const reservedTagRE = / ^ ( s l o t | p a r t i a l | c o m p o n e n t ) $ /
78
89/**
910 * Check if an element is a component, if yes return its
@@ -17,7 +18,7 @@ export const commonTagRE = /^(div|p|span|img|a|b|i|br|ul|ol|li|h1|h2|h3|h4|h5|h6
1718export function checkComponentAttr ( el , options ) {
1819 var tag = el . tagName . toLowerCase ( )
1920 var hasAttrs = el . hasAttributes ( )
20- if ( ! commonTagRE . test ( tag ) && tag !== 'component' ) {
21+ if ( ! commonTagRE . test ( tag ) && ! reservedTagRE . test ( tag ) ) {
2122 if ( resolveAsset ( options , 'components' , tag ) ) {
2223 return { id : tag }
2324 } else {
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import {
1010 camelize
1111} from './lang'
1212import { warn } from './debug'
13- import { commonTagRE } from './component'
13+ import { commonTagRE , reservedTagRE } from './component'
1414
1515/**
1616 * Option overwriting strategies are functions that handle
@@ -233,9 +233,9 @@ function guardComponents (options) {
233233 var ids = Object . keys ( components )
234234 for ( var i = 0 , l = ids . length ; i < l ; i ++ ) {
235235 var key = ids [ i ]
236- if ( commonTagRE . test ( key ) ) {
236+ if ( commonTagRE . test ( key ) || reservedTagRE . test ( key ) ) {
237237 process . env . NODE_ENV !== 'production' && warn (
238- 'Do not use built-in HTML elements as component ' +
238+ 'Do not use built-in or reserved HTML elements as component ' +
239239 'id: ' + key
240240 )
241241 continue
Original file line number Diff line number Diff line change @@ -161,7 +161,15 @@ describe('Util - Option merging', function () {
161161 a : { template : 'hi' }
162162 }
163163 } )
164- expect ( hasWarned ( 'Do not use built-in HTML elements' ) ) . toBe ( true )
164+ expect ( hasWarned ( 'Do not use built-in or reserved HTML elements as component id: a' ) ) . toBe ( true )
165+ merge ( {
166+ components : null
167+ } , {
168+ components : {
169+ slot : { template : 'hi' }
170+ }
171+ } )
172+ expect ( hasWarned ( 'Do not use built-in or reserved HTML elements as component id: slot' ) ) . toBe ( true )
165173 } )
166174
167175 it ( 'should ignore non-function el & data in class merge' , function ( ) {
You can’t perform that action at this time.
0 commit comments