mirror of https://github.com/vuejs/core.git
fix(compiler-vapor): nested component
This commit is contained in:
parent
8ea6e4fb22
commit
51d9bbe7f0
|
@ -27,7 +27,7 @@
|
|||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
|
||||
"dev-esm": "node scripts/dev.js -if esm-bundler-runtime",
|
||||
"dev-prepare-cjs": "node scripts/prepare-cjs.js || npm run build-all-cjs",
|
||||
"dev-compiler": "run-p \"dev template-explorer\" serve",
|
||||
"dev-compiler": "run-p \"dev template-explorer\" serve open",
|
||||
"dev-sfc": "run-s dev-prepare-cjs dev-sfc-run",
|
||||
"dev-sfc-serve": "vite packages-private/sfc-playground --host",
|
||||
"dev-sfc-run": "run-p \"dev compiler-sfc -f esm-browser\" \"dev vue -if esm-bundler-runtime\" \"dev vue -ipf esm-browser-runtime\" \"dev server-renderer -if esm-bundler\" dev-sfc-serve",
|
||||
|
|
|
@ -137,6 +137,24 @@ export function render(_ctx) {
|
|||
}"
|
||||
`;
|
||||
|
||||
exports[`compiler: transform slot > nested component slot 1`] = `
|
||||
"import { resolveComponent as _resolveComponent, createComponent as _createComponent } from 'vue/vapor';
|
||||
|
||||
export function render(_ctx) {
|
||||
const _component_B = _resolveComponent("B")
|
||||
const _component_A = _resolveComponent("A")
|
||||
const n1 = _createComponent(_component_A, null, [
|
||||
{
|
||||
"default": () => {
|
||||
const n0 = _createComponent(_component_B)
|
||||
return n0
|
||||
}
|
||||
}
|
||||
], true)
|
||||
return n1
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`compiler: transform slot > nested slots scoping 1`] = `
|
||||
"import { resolveComponent as _resolveComponent, createTextNode as _createTextNode, withDestructure as _withDestructure, createComponent as _createComponent, template as _template } from 'vue/vapor';
|
||||
const t0 = _template(" ")
|
||||
|
|
|
@ -406,6 +406,34 @@ describe('compiler: transform slot', () => {
|
|||
expect(code).contains(`"nav-bar-title-before"`)
|
||||
})
|
||||
|
||||
test('nested component slot', () => {
|
||||
const { ir, code } = compileWithSlots(`<A><B/></A>`)
|
||||
expect(code).toMatchSnapshot()
|
||||
expect(ir.block.operation).toMatchObject([
|
||||
{
|
||||
type: IRNodeTypes.CREATE_COMPONENT_NODE,
|
||||
tag: 'A',
|
||||
slots: [
|
||||
{
|
||||
slotType: IRSlotType.STATIC,
|
||||
slots: {
|
||||
default: {
|
||||
type: IRNodeTypes.BLOCK,
|
||||
operation: [
|
||||
{
|
||||
type: IRNodeTypes.CREATE_COMPONENT_NODE,
|
||||
tag: 'B',
|
||||
slots: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
describe('errors', () => {
|
||||
test('error on extraneous children w/ named default slot', () => {
|
||||
const onError = vi.fn()
|
||||
|
|
|
@ -104,7 +104,7 @@ function transformComponentElement(
|
|||
props: propsResult[0] ? propsResult[1] : [propsResult[1]],
|
||||
asset,
|
||||
root,
|
||||
slots: context.slots,
|
||||
slots: [...context.slots],
|
||||
once: context.inVOnce,
|
||||
})
|
||||
context.slots = []
|
||||
|
|
Loading…
Reference in New Issue