From 76c9c742e9b045d1342f5952866972498e59f00b Mon Sep 17 00:00:00 2001 From: Wick Date: Sun, 25 Feb 2024 20:41:08 +0800 Subject: [PATCH] chore(runtime-core): optimize validateComponentName (#10378) --- packages/runtime-core/src/apiCreateApp.ts | 2 +- packages/runtime-core/src/component.ts | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/runtime-core/src/apiCreateApp.ts b/packages/runtime-core/src/apiCreateApp.ts index a1bf09fd2..65c10166d 100644 --- a/packages/runtime-core/src/apiCreateApp.ts +++ b/packages/runtime-core/src/apiCreateApp.ts @@ -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 diff --git a/packages/runtime-core/src/component.ts b/packages/runtime-core/src/component.ts index ed1f8efee..2ad0a66f1 100644 --- a/packages/runtime-core/src/component.ts +++ b/packages/runtime-core/src/component.ts @@ -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, )