Skip to content

Commit 76c9c74

Browse files
authored
chore(runtime-core): optimize validateComponentName (#10378)
1 parent c131eba commit 76c9c74

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

packages/runtime-core/src/apiCreateApp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export type OptionMergeFunction = (to: unknown, from: unknown) => any
8484

8585
export interface AppConfig {
8686
// @private
87-
readonly isNativeTag?: (tag: string) => boolean
87+
readonly isNativeTag: (tag: string) => boolean
8888

8989
performance: boolean
9090
optionMergeStrategies: Record<string, OptionMergeFunction>

packages/runtime-core/src/component.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ import {
6161
import {
6262
EMPTY_OBJ,
6363
type IfAny,
64-
NO,
6564
NOOP,
6665
ShapeFlags,
6766
extend,
@@ -707,9 +706,11 @@ export const unsetCurrentInstance = () => {
707706

708707
const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component')
709708

710-
export function validateComponentName(name: string, config: AppConfig) {
711-
const appIsNativeTag = config.isNativeTag || NO
712-
if (isBuiltInTag(name) || appIsNativeTag(name)) {
709+
export function validateComponentName(
710+
name: string,
711+
{ isNativeTag }: AppConfig,
712+
) {
713+
if (isBuiltInTag(name) || isNativeTag(name)) {
713714
warn(
714715
'Do not use built-in or reserved HTML elements as component id: ' + name,
715716
)

0 commit comments

Comments
 (0)