chore(runtime-core): optimize validateComponentName (#10378)

This commit is contained in:
Wick 2024-02-25 20:41:08 +08:00 committed by GitHub
parent c131ebae45
commit 76c9c742e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View File

@ -84,7 +84,7 @@ export type OptionMergeFunction = (to: unknown, from: unknown) => any
export interface AppConfig {
// @private
readonly isNativeTag?: (tag: string) => boolean
readonly isNativeTag: (tag: string) => boolean
performance: boolean
optionMergeStrategies: Record<string, OptionMergeFunction>

View File

@ -61,7 +61,6 @@ import {
import {
EMPTY_OBJ,
type IfAny,
NO,
NOOP,
ShapeFlags,
extend,
@ -707,9 +706,11 @@ export const unsetCurrentInstance = () => {
const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component')
export function validateComponentName(name: string, config: AppConfig) {
const appIsNativeTag = config.isNativeTag || NO
if (isBuiltInTag(name) || appIsNativeTag(name)) {
export function validateComponentName(
name: string,
{ isNativeTag }: AppConfig,
) {
if (isBuiltInTag(name) || isNativeTag(name)) {
warn(
'Do not use built-in or reserved HTML elements as component id: ' + name,
)