Skip to content

Commit 97f0b3b

Browse files
sxzzDoctor-wuLittleSound
authored
refactor: component slots (#238)
Co-authored-by: Doctor Wu <[email protected]> Co-authored-by: Rizumu Ayaka <[email protected]>
1 parent bbde386 commit 97f0b3b

23 files changed

+657
-572
lines changed

packages/compiler-vapor/__tests__/__snapshots__/compile.spec.ts.snap

+14-10
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,20 @@ export function render(_ctx) {
3333
const _component_Comp = _resolveComponent("Comp")
3434
const _directive_hello = _resolveDirective("hello")
3535
const _directive_test = _resolveDirective("test")
36-
const n4 = _createComponent(_component_Comp, null, { default: () => {
37-
const n0 = _createIf(() => (true), () => {
38-
const n3 = t0()
39-
const n2 = _createComponent(_component_Bar)
40-
_withDirectives(n2, [[_directive_hello, void 0, void 0, { world: true }]])
41-
_insert(n2, n3)
42-
return n3
43-
})
44-
return n0
45-
} }, null, true)
36+
const n4 = _createComponent(_component_Comp, null, [
37+
{
38+
default: () => {
39+
const n0 = _createIf(() => (true), () => {
40+
const n3 = t0()
41+
const n2 = _createComponent(_component_Bar)
42+
_withDirectives(n2, [[_directive_hello, void 0, void 0, { world: true }]])
43+
_insert(n2, n3)
44+
return n3
45+
})
46+
return n0
47+
}
48+
}
49+
], true)
4650
_withDirectives(n4, [[_directive_test]])
4751
return n4
4852
}"

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

+19-19
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exports[`compiler: element transform > component > do not resolve component from
55
66
export function render(_ctx) {
77
const _component_Example = _resolveComponent("Example")
8-
const n0 = _createComponent(_component_Example, null, null, null, true)
8+
const n0 = _createComponent(_component_Example, null, null, true)
99
return n0
1010
}"
1111
`;
@@ -25,7 +25,7 @@ exports[`compiler: element transform > component > generate single root componen
2525
"import { createComponent as _createComponent } from 'vue/vapor';
2626
2727
export function render(_ctx) {
28-
const n0 = _createComponent(_ctx.Comp, null, null, null, true)
28+
const n0 = _createComponent(_ctx.Comp, null, null, true)
2929
return n0
3030
}"
3131
`;
@@ -35,21 +35,21 @@ exports[`compiler: element transform > component > import + resolve component 1`
3535
3636
export function render(_ctx) {
3737
const _component_Foo = _resolveComponent("Foo")
38-
const n0 = _createComponent(_component_Foo, null, null, null, true)
38+
const n0 = _createComponent(_component_Foo, null, null, true)
3939
return n0
4040
}"
4141
`;
4242

4343
exports[`compiler: element transform > component > resolve component from setup bindings (inline const) 1`] = `
4444
"(() => {
45-
const n0 = _createComponent(Example, null, null, null, true)
45+
const n0 = _createComponent(Example, null, null, true)
4646
return n0
4747
})()"
4848
`;
4949

5050
exports[`compiler: element transform > component > resolve component from setup bindings (inline) 1`] = `
5151
"(() => {
52-
const n0 = _createComponent(_unref(Example), null, null, null, true)
52+
const n0 = _createComponent(_unref(Example), null, null, true)
5353
return n0
5454
})()"
5555
`;
@@ -58,14 +58,14 @@ exports[`compiler: element transform > component > resolve component from setup
5858
"import { createComponent as _createComponent } from 'vue/vapor';
5959
6060
export function render(_ctx) {
61-
const n0 = _createComponent(_ctx.Example, null, null, null, true)
61+
const n0 = _createComponent(_ctx.Example, null, null, true)
6262
return n0
6363
}"
6464
`;
6565

6666
exports[`compiler: element transform > component > resolve namespaced component from props bindings (inline) 1`] = `
6767
"(() => {
68-
const n0 = _createComponent(Foo.Example, null, null, null, true)
68+
const n0 = _createComponent(Foo.Example, null, null, true)
6969
return n0
7070
})()"
7171
`;
@@ -74,14 +74,14 @@ exports[`compiler: element transform > component > resolve namespaced component
7474
"import { createComponent as _createComponent } from 'vue/vapor';
7575
7676
export function render(_ctx) {
77-
const n0 = _createComponent(_ctx.Foo.Example, null, null, null, true)
77+
const n0 = _createComponent(_ctx.Foo.Example, null, null, true)
7878
return n0
7979
}"
8080
`;
8181

8282
exports[`compiler: element transform > component > resolve namespaced component from setup bindings (inline const) 1`] = `
8383
"(() => {
84-
const n0 = _createComponent(Foo.Example, null, null, null, true)
84+
const n0 = _createComponent(Foo.Example, null, null, true)
8585
return n0
8686
})()"
8787
`;
@@ -90,7 +90,7 @@ exports[`compiler: element transform > component > resolve namespaced component
9090
"import { createComponent as _createComponent } from 'vue/vapor';
9191
9292
export function render(_ctx) {
93-
const n0 = _createComponent(_ctx.Foo.Example, null, null, null, true)
93+
const n0 = _createComponent(_ctx.Foo.Example, null, null, true)
9494
return n0
9595
}"
9696
`;
@@ -102,7 +102,7 @@ export function render(_ctx) {
102102
const _component_Foo = _resolveComponent("Foo")
103103
const n0 = _createComponent(_component_Foo, [
104104
{ onBar: () => $event => (_ctx.handleBar($event)) }
105-
], null, null, true)
105+
], null, true)
106106
return n0
107107
}"
108108
`;
@@ -117,7 +117,7 @@ export function render(_ctx) {
117117
id: () => ("foo"),
118118
class: () => ("bar")
119119
}
120-
], null, null, true)
120+
], null, true)
121121
return n0
122122
}"
123123
`;
@@ -129,7 +129,7 @@ export function render(_ctx) {
129129
const _component_Foo = _resolveComponent("Foo")
130130
const n0 = _createComponent(_component_Foo, [
131131
() => (_ctx.obj)
132-
], null, null, true)
132+
], null, true)
133133
return n0
134134
}"
135135
`;
@@ -142,7 +142,7 @@ export function render(_ctx) {
142142
const n0 = _createComponent(_component_Foo, [
143143
{ id: () => ("foo") },
144144
() => (_ctx.obj)
145-
], null, null, true)
145+
], null, true)
146146
return n0
147147
}"
148148
`;
@@ -155,7 +155,7 @@ export function render(_ctx) {
155155
const n0 = _createComponent(_component_Foo, [
156156
() => (_ctx.obj),
157157
{ id: () => ("foo") }
158-
], null, null, true)
158+
], null, true)
159159
return n0
160160
}"
161161
`;
@@ -169,7 +169,7 @@ export function render(_ctx) {
169169
{ id: () => ("foo") },
170170
() => (_ctx.obj),
171171
{ class: () => ("bar") }
172-
], null, null, true)
172+
], null, true)
173173
return n0
174174
}"
175175
`;
@@ -181,7 +181,7 @@ export function render(_ctx) {
181181
const _component_Foo = _resolveComponent("Foo")
182182
const n0 = _createComponent(_component_Foo, [
183183
() => (_toHandlers(_ctx.obj))
184-
], null, null, true)
184+
], null, true)
185185
return n0
186186
}"
187187
`;
@@ -195,7 +195,7 @@ export function render(_ctx) {
195195
const n0 = _createComponent(_component_Foo, [
196196
() => ({ [_toHandlerKey(_ctx.foo-_ctx.bar)]: () => _ctx.bar }),
197197
() => ({ [_toHandlerKey(_ctx.baz)]: () => _ctx.qux })
198-
], null, null, true)
198+
], null, true)
199199
return n0
200200
}"
201201
`;
@@ -208,7 +208,7 @@ export function render(_ctx) {
208208
const n0 = _createComponent(_component_Foo, [
209209
() => ({ [_ctx.foo-_ctx.bar]: _ctx.bar }),
210210
() => ({ [_ctx.baz]: _ctx.qux })
211-
], null, null, true)
211+
], null, true)
212212
return n0
213213
}"
214214
`;

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function render(_ctx) {
99
{ modelValue: () => (_ctx.foo),
1010
"onUpdate:modelValue": () => $event => (_ctx.foo = $event),
1111
modelModifiers: () => ({ trim: true, "bar-baz": true }) }
12-
], null, null, true)
12+
], null, true)
1313
return n0
1414
}"
1515
`;
@@ -22,7 +22,7 @@ export function render(_ctx) {
2222
const n0 = _createComponent(_component_Comp, [
2323
{ modelValue: () => (_ctx.foo),
2424
"onUpdate:modelValue": () => $event => (_ctx.foo = $event) }
25-
], null, null, true)
25+
], null, true)
2626
return n0
2727
}"
2828
`;
@@ -41,7 +41,7 @@ export function render(_ctx) {
4141
"onUpdate:bar": () => $event => (_ctx.bar = $event),
4242
barModifiers: () => ({ number: true })
4343
}
44-
], null, null, true)
44+
], null, true)
4545
return n0
4646
}"
4747
`;
@@ -54,7 +54,7 @@ export function render(_ctx) {
5454
const n0 = _createComponent(_component_Comp, [
5555
{ bar: () => (_ctx.foo),
5656
"onUpdate:bar": () => $event => (_ctx.foo = $event) }
57-
], null, null, true)
57+
], null, true)
5858
return n0
5959
}"
6060
`;
@@ -71,7 +71,7 @@ export function render(_ctx) {
7171
() => ({ [_ctx.bar]: _ctx.bar,
7272
["onUpdate:" + _ctx.bar]: () => $event => (_ctx.bar = $event),
7373
[_ctx.bar + "Modifiers"]: () => ({ number: true }) })
74-
], null, null, true)
74+
], null, true)
7575
return n0
7676
}"
7777
`;
@@ -84,7 +84,7 @@ export function render(_ctx) {
8484
const n0 = _createComponent(_component_Comp, [
8585
() => ({ [_ctx.arg]: _ctx.foo,
8686
["onUpdate:" + _ctx.arg]: () => $event => (_ctx.foo = $event) })
87-
], null, null, true)
87+
], null, true)
8888
return n0
8989
}"
9090
`;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function render(_ctx) {
4444
const n1 = t0()
4545
const n0 = _createComponent(_component_Comp, [
4646
{ id: () => (_ctx.foo) }
47-
], null, null, null, true)
47+
], null, null, true)
4848
_insert(n0, n1)
4949
return n1
5050
}"

0 commit comments

Comments
 (0)