Skip to content

Commit 15fb060

Browse files
authored
Merge branch 'main' into feat/static-v-slot
2 parents 0852d62 + 133d494 commit 15fb060

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

packages/compiler-vapor/__tests__/transforms/__snapshots__/transformSlotOutlet.spec.ts.snap

+30
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,21 @@ export function render(_ctx) {
2222
}"
2323
`;
2424
25+
exports[`compiler: transform <slot> outlets > default slot outlet with props & fallback 1`] = `
26+
"import { createSlot as _createSlot, template as _template } from 'vue/vapor';
27+
const t0 = _template("<div></div>")
28+
29+
export function render(_ctx) {
30+
const n0 = _createSlot("default", [
31+
{ foo: () => (_ctx.bar) }
32+
], () => {
33+
const n2 = t0()
34+
return n2
35+
})
36+
return n0
37+
}"
38+
`;
39+
2540
exports[`compiler: transform <slot> outlets > default slot outlet with props 1`] = `
2641
"import { createSlot as _createSlot } from 'vue/vapor';
2742
@@ -86,6 +101,21 @@ export function render(_ctx) {
86101
}"
87102
`;
88103
104+
exports[`compiler: transform <slot> outlets > named slot outlet with props & fallback 1`] = `
105+
"import { createSlot as _createSlot, template as _template } from 'vue/vapor';
106+
const t0 = _template("<div></div>")
107+
108+
export function render(_ctx) {
109+
const n0 = _createSlot("foo", [
110+
{ foo: () => (_ctx.bar) }
111+
], () => {
112+
const n2 = t0()
113+
return n2
114+
})
115+
return n0
116+
}"
117+
`;
118+
89119
exports[`compiler: transform <slot> outlets > statically named slot outlet 1`] = `
90120
"import { createSlot as _createSlot } from 'vue/vapor';
91121

packages/compiler-vapor/__tests__/transforms/transformSlotOutlet.spec.ts

+46
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,52 @@ describe('compiler: transform <slot> outlets', () => {
210210
])
211211
})
212212

213+
test('default slot outlet with props & fallback', () => {
214+
const { ir, code } = compileWithSlotsOutlet(
215+
`<slot :foo="bar"><div/></slot>`,
216+
)
217+
expect(code).toMatchSnapshot()
218+
expect(ir.template[0]).toMatchObject('<div></div>')
219+
expect(ir.block.operation).toMatchObject([
220+
{
221+
type: IRNodeTypes.SLOT_OUTLET_NODE,
222+
id: 0,
223+
name: { content: 'default' },
224+
props: [[{ key: { content: 'foo' }, values: [{ content: 'bar' }] }]],
225+
fallback: {
226+
type: IRNodeTypes.BLOCK,
227+
dynamic: {
228+
children: [{ template: 0, id: 2 }],
229+
},
230+
returns: [2],
231+
},
232+
},
233+
])
234+
})
235+
236+
test('named slot outlet with props & fallback', () => {
237+
const { ir, code } = compileWithSlotsOutlet(
238+
`<slot name="foo" :foo="bar"><div/></slot>`,
239+
)
240+
expect(code).toMatchSnapshot()
241+
expect(ir.template[0]).toMatchObject('<div></div>')
242+
expect(ir.block.operation).toMatchObject([
243+
{
244+
type: IRNodeTypes.SLOT_OUTLET_NODE,
245+
id: 0,
246+
name: { content: 'foo' },
247+
props: [[{ key: { content: 'foo' }, values: [{ content: 'bar' }] }]],
248+
fallback: {
249+
type: IRNodeTypes.BLOCK,
250+
dynamic: {
251+
children: [{ template: 0, id: 2 }],
252+
},
253+
returns: [2],
254+
},
255+
},
256+
])
257+
})
258+
213259
test('error on unexpected custom directive on <slot>', () => {
214260
const onError = vi.fn()
215261
const source = `<slot v-foo />`

0 commit comments

Comments
 (0)