]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore(runtime-core): optimize validateComponentName (#10378)
authorWick <wick.linxunjie@gmail.com>
Sun, 25 Feb 2024 12:41:08 +0000 (20:41 +0800)
committerGitHub <noreply@github.com>
Sun, 25 Feb 2024 12:41:08 +0000 (20:41 +0800)
packages/runtime-core/src/apiCreateApp.ts
packages/runtime-core/src/component.ts

index a1bf09fd2127623316288127bd79e776befa6666..65c10166de7cbc8f600fca727c29aa86fbc36a0f 100644 (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>
index ed1f8efee52d4acb46f4122f987991aed9f7faea..2ad0a66f188d2ded68f6fd695064c11311df012e 100644 (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,
     )