Skip to content

Commit

Permalink
chore(runtime-core): optimize validateComponentName (#10378)
Browse files Browse the repository at this point in the history
  • Loading branch information
OnlyWick committed Feb 25, 2024
1 parent c131eba commit 76c9c74
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/runtime-core/src/apiCreateApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
9 changes: 5 additions & 4 deletions packages/runtime-core/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ import {
import {
EMPTY_OBJ,
type IfAny,
NO,
NOOP,
ShapeFlags,
extend,
Expand Down Expand Up @@ -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,
)
Expand Down

0 comments on commit 76c9c74

Please sign in to comment.