Skip to content

Commit

Permalink
feat: added isLateTag
Browse files Browse the repository at this point in the history
  • Loading branch information
baiwusanyu-c committed Oct 23, 2023
1 parent 0a8be45 commit be735d7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
23 changes: 14 additions & 9 deletions packages/runtime-core/src/helpers/resolveAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '../component'
import { currentRenderingInstance } from '../componentRenderContext'
import { Directive } from '../directives'
import { camelize, capitalize, isString } from '@vue/shared'
import {camelize, capitalize, isLateTag, isString} from '@vue/shared'
import { warn } from '../warning'
import { VNodeTypes } from '../vnode'

Expand Down Expand Up @@ -106,19 +106,24 @@ function resolveAsset(
resolve(instance[type] || (Component as ComponentOptions)[type], name) ||
// global registration
resolve(instance.appContext[type], name)

debugger
if (!res && maybeSelfReference) {
// fallback to implicit self-reference
return Component
}

if (__DEV__ && warnMissing && !res) {
const extra =
type === COMPONENTS
? `\nIf this is a native custom element, make sure to exclude it from ` +
`component resolution via compilerOptions.isCustomElement.`
: ``
warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`)
if (__DEV__ && warnMissing) {
const isResEmpty = !res;
const isNameLateTag = isLateTag(name);

if ((isResEmpty && !isNameLateTag) || (!isResEmpty && isNameLateTag)) {
const extra =
type === COMPONENTS
? `\nIf this is a native custom element, make sure to exclude it from ` +
`component resolution via compilerOptions.isCustomElement.`
: ``
warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`)
}
}

return res
Expand Down
4 changes: 4 additions & 0 deletions packages/shared/src/domTagConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const HTML_TAGS =
'option,output,progress,select,textarea,details,dialog,menu,' +
'summary,template,blockquote,iframe,tfoot'

const LATE_ADDED_TAGS = 'search'

// https://developer.mozilla.org/en-US/docs/Web/SVG/Element
const SVG_TAGS =
'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' +
Expand Down Expand Up @@ -45,3 +47,5 @@ export const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS)
* Do NOT use in runtime code paths unless behind `__DEV__` flag.
*/
export const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS)

export const isLateTag = /*#__PURE__*/ makeMap(LATE_ADDED_TAGS)

0 comments on commit be735d7

Please sign in to comment.