feat(sfc): allow sfcs to recursively self-reference in template via name inferred from filename
e.g. A file named `FooBar.vue` can refer to itself as `<FooBar/>`. This gets rid of the need for the `name` option.
This commit is contained in:
@@ -263,7 +263,16 @@ export function resolveComponentType(
|
||||
}
|
||||
}
|
||||
|
||||
// 4. user component (resolve)
|
||||
// 4. Self referencing component (inferred from filename)
|
||||
if (!__BROWSER__ && context.selfName) {
|
||||
if (capitalize(camelize(tag)) === context.selfName) {
|
||||
context.helper(RESOLVE_COMPONENT)
|
||||
context.components.add(`_self`)
|
||||
return toValidAssetId(`_self`, `component`)
|
||||
}
|
||||
}
|
||||
|
||||
// 5. user component (resolve)
|
||||
context.helper(RESOLVE_COMPONENT)
|
||||
context.components.add(tag)
|
||||
return toValidAssetId(tag, `component`)
|
||||
|
||||
Reference in New Issue
Block a user