diff --git a/packages/compiler-vapor/__tests__/transforms/__snapshots__/transformSlotOutlet.spec.ts.snap b/packages/compiler-vapor/__tests__/transforms/__snapshots__/transformSlotOutlet.spec.ts.snap index 72b9b95f1..8d0b2ade5 100644 --- a/packages/compiler-vapor/__tests__/transforms/__snapshots__/transformSlotOutlet.spec.ts.snap +++ b/packages/compiler-vapor/__tests__/transforms/__snapshots__/transformSlotOutlet.spec.ts.snap @@ -22,6 +22,21 @@ export function render(_ctx) { }" `; +exports[`compiler: transform outlets > default slot outlet with props & fallback 1`] = ` +"import { createSlot as _createSlot, template as _template } from 'vue/vapor'; +const t0 = _template("
") + +export function render(_ctx) { + const n0 = _createSlot("default", [ + { foo: () => (_ctx.bar) } + ], () => { + const n2 = t0() + return n2 + }) + return n0 +}" +`; + exports[`compiler: transform outlets > default slot outlet with props 1`] = ` "import { createSlot as _createSlot } from 'vue/vapor'; @@ -86,6 +101,21 @@ export function render(_ctx) { }" `; +exports[`compiler: transform outlets > named slot outlet with props & fallback 1`] = ` +"import { createSlot as _createSlot, template as _template } from 'vue/vapor'; +const t0 = _template("
") + +export function render(_ctx) { + const n0 = _createSlot("foo", [ + { foo: () => (_ctx.bar) } + ], () => { + const n2 = t0() + return n2 + }) + return n0 +}" +`; + exports[`compiler: transform outlets > statically named slot outlet 1`] = ` "import { createSlot as _createSlot } from 'vue/vapor'; diff --git a/packages/compiler-vapor/__tests__/transforms/transformSlotOutlet.spec.ts b/packages/compiler-vapor/__tests__/transforms/transformSlotOutlet.spec.ts index aee60e5b3..32b9a865d 100644 --- a/packages/compiler-vapor/__tests__/transforms/transformSlotOutlet.spec.ts +++ b/packages/compiler-vapor/__tests__/transforms/transformSlotOutlet.spec.ts @@ -210,6 +210,52 @@ describe('compiler: transform outlets', () => { ]) }) + test('default slot outlet with props & fallback', () => { + const { ir, code } = compileWithSlotsOutlet( + `
`, + ) + expect(code).toMatchSnapshot() + expect(ir.template[0]).toMatchObject('
') + expect(ir.block.operation).toMatchObject([ + { + type: IRNodeTypes.SLOT_OUTLET_NODE, + id: 0, + name: { content: 'default' }, + props: [[{ key: { content: 'foo' }, values: [{ content: 'bar' }] }]], + fallback: { + type: IRNodeTypes.BLOCK, + dynamic: { + children: [{ template: 0, id: 2 }], + }, + returns: [2], + }, + }, + ]) + }) + + test('named slot outlet with props & fallback', () => { + const { ir, code } = compileWithSlotsOutlet( + `
`, + ) + expect(code).toMatchSnapshot() + expect(ir.template[0]).toMatchObject('
') + expect(ir.block.operation).toMatchObject([ + { + type: IRNodeTypes.SLOT_OUTLET_NODE, + id: 0, + name: { content: 'foo' }, + props: [[{ key: { content: 'foo' }, values: [{ content: 'bar' }] }]], + fallback: { + type: IRNodeTypes.BLOCK, + dynamic: { + children: [{ template: 0, id: 2 }], + }, + returns: [2], + }, + }, + ]) + }) + test('error on unexpected custom directive on ', () => { const onError = vi.fn() const source = ``