Skip to content

Commit

Permalink
fix(runtime-core): should not register name for anonymous component
Browse files Browse the repository at this point in the history
  • Loading branch information
underfin committed Jun 22, 2020
1 parent 06569a1 commit 3e800c6
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions packages/runtime-core/src/helpers/resolveAssets.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { currentRenderingInstance } from '../componentRenderUtils'
import {
currentInstance,
Component,
FunctionalComponent,
ComponentOptions
} from '../component'
import { currentInstance, Component, FunctionalComponent } from '../component'
import { Directive } from '../directives'
import { camelize, capitalize, isString, isObject } from '@vue/shared'
import { camelize, capitalize, isString } from '@vue/shared'
import { warn } from '../warning'

const COMPONENTS = 'components'
Expand Down Expand Up @@ -82,19 +77,13 @@ function resolveAsset(
res = self
}
}
if (__DEV__) {
if (res) {
// in dev, infer anonymous component's name based on registered name
if (
type === COMPONENTS &&
isObject(res) &&
!(res as ComponentOptions).name
) {
;(res as ComponentOptions).name = name
}
} else if (warnMissing) {
warn(`Failed to resolve ${type.slice(0, -1)}: ${name}`)
}
if (__DEV__ && warnMissing && !res) {
warn(
`Failed to resolve ${type.slice(0, -1)}: ${name}` +
(type === COMPONENTS
? `\nFor recursive components, make sure to provide the "name" option.`
: '')
)
}
return res
} else if (__DEV__) {
Expand Down

0 comments on commit 3e800c6

Please sign in to comment.