Skip to content

Commit 123cfd3

Browse files
feat: support template props omitted
1 parent f0405f1 commit 123cfd3

20 files changed

+202
-174
lines changed

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

+29-18
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exports[`compile > bindings 1`] = `
44
"import { renderEffect as _renderEffect, setText as _setText, template as _template } from 'vue/vapor';
55
const t0 = _template("<div></div>")
66
7-
export function render(_ctx) {
7+
export function render(_ctx, _props) {
88
const n0 = t0()
99
_renderEffect(() => _setText(n0, "count is ", _ctx.count, "."))
1010
return n0
@@ -15,7 +15,7 @@ exports[`compile > custom directive > basic 1`] = `
1515
"import { resolveDirective as _resolveDirective, withDirectives as _withDirectives, template as _template } from 'vue/vapor';
1616
const t0 = _template("<div></div>")
1717
18-
export function render(_ctx) {
18+
export function render(_ctx, _props) {
1919
const _directive_test = _resolveDirective("test")
2020
const _directive_hello = _resolveDirective("hello")
2121
const n0 = t0()
@@ -28,7 +28,7 @@ exports[`compile > custom directive > component 1`] = `
2828
"import { resolveComponent as _resolveComponent, resolveDirective as _resolveDirective, createComponent as _createComponent, withDirectives as _withDirectives, insert as _insert, createIf as _createIf, template as _template } from 'vue/vapor';
2929
const t0 = _template("<div></div>")
3030
31-
export function render(_ctx) {
31+
export function render(_ctx, _props) {
3232
const _component_Bar = _resolveComponent("Bar")
3333
const _component_Comp = _resolveComponent("Comp")
3434
const _directive_hello = _resolveDirective("hello")
@@ -56,7 +56,7 @@ exports[`compile > directives > custom directive > basic 1`] = `
5656
"import { withDirectives as _withDirectives, template as _template } from 'vue/vapor';
5757
const t0 = _template("<div></div>")
5858
59-
export function render(_ctx) {
59+
export function render(_ctx, _props) {
6060
const n0 = t0()
6161
_withDirectives(n0, [[_ctx.vExample]])
6262
return n0
@@ -67,7 +67,7 @@ exports[`compile > directives > custom directive > binding value 1`] = `
6767
"import { withDirectives as _withDirectives, template as _template } from 'vue/vapor';
6868
const t0 = _template("<div></div>")
6969
70-
export function render(_ctx) {
70+
export function render(_ctx, _props) {
7171
const n0 = t0()
7272
_withDirectives(n0, [[_ctx.vExample, () => _ctx.msg]])
7373
return n0
@@ -78,7 +78,7 @@ exports[`compile > directives > custom directive > dynamic parameters 1`] = `
7878
"import { withDirectives as _withDirectives, template as _template } from 'vue/vapor';
7979
const t0 = _template("<div></div>")
8080
81-
export function render(_ctx) {
81+
export function render(_ctx, _props) {
8282
const n0 = t0()
8383
_withDirectives(n0, [[_ctx.vExample, () => _ctx.msg, _ctx.foo]])
8484
return n0
@@ -89,7 +89,7 @@ exports[`compile > directives > custom directive > modifiers 1`] = `
8989
"import { withDirectives as _withDirectives, template as _template } from 'vue/vapor';
9090
const t0 = _template("<div></div>")
9191
92-
export function render(_ctx) {
92+
export function render(_ctx, _props) {
9393
const n0 = t0()
9494
_withDirectives(n0, [[_ctx.vExample, () => _ctx.msg, void 0, { bar: true }]])
9595
return n0
@@ -100,7 +100,7 @@ exports[`compile > directives > custom directive > modifiers w/o binding 1`] = `
100100
"import { withDirectives as _withDirectives, template as _template } from 'vue/vapor';
101101
const t0 = _template("<div></div>")
102102
103-
export function render(_ctx) {
103+
export function render(_ctx, _props) {
104104
const n0 = t0()
105105
_withDirectives(n0, [[_ctx.vExample, void 0, void 0, { "foo-bar": true }]])
106106
return n0
@@ -111,7 +111,7 @@ exports[`compile > directives > custom directive > static parameters 1`] = `
111111
"import { withDirectives as _withDirectives, template as _template } from 'vue/vapor';
112112
const t0 = _template("<div></div>")
113113
114-
export function render(_ctx) {
114+
export function render(_ctx, _props) {
115115
const n0 = t0()
116116
_withDirectives(n0, [[_ctx.vExample, () => _ctx.msg, "foo"]])
117117
return n0
@@ -122,7 +122,7 @@ exports[`compile > directives > custom directive > static parameters and modifie
122122
"import { withDirectives as _withDirectives, template as _template } from 'vue/vapor';
123123
const t0 = _template("<div></div>")
124124
125-
export function render(_ctx) {
125+
export function render(_ctx, _props) {
126126
const n0 = t0()
127127
_withDirectives(n0, [[_ctx.vExample, () => _ctx.msg, "foo", { bar: true }]])
128128
return n0
@@ -133,7 +133,7 @@ exports[`compile > directives > v-cloak > basic 1`] = `
133133
"import { template as _template } from 'vue/vapor';
134134
const t0 = _template("<div>test</div>")
135135
136-
export function render(_ctx) {
136+
export function render(_ctx, _props) {
137137
const n0 = t0()
138138
return n0
139139
}"
@@ -143,7 +143,7 @@ exports[`compile > directives > v-pre > basic 1`] = `
143143
"import { template as _template } from 'vue/vapor';
144144
const t0 = _template("<div :id=\\"foo\\"><Comp></Comp>{{ bar }}</div>")
145145
146-
export function render(_ctx) {
146+
export function render(_ctx, _props) {
147147
const n0 = t0()
148148
return n0
149149
}"
@@ -154,7 +154,7 @@ exports[`compile > directives > v-pre > should not affect siblings after it 1`]
154154
const t0 = _template("<div :id=\\"foo\\"><Comp></Comp>{{ bar }}</div>")
155155
const t1 = _template("<div></div>")
156156
157-
export function render(_ctx) {
157+
export function render(_ctx, _props) {
158158
const _component_Comp = _resolveComponent("Comp")
159159
const n0 = t0()
160160
const n3 = t1()
@@ -169,7 +169,7 @@ export function render(_ctx) {
169169
exports[`compile > dynamic root 1`] = `
170170
"import { createTextNode as _createTextNode } from 'vue/vapor';
171171
172-
export function render(_ctx) {
172+
export function render(_ctx, _props) {
173173
const n0 = _createTextNode([1, 2])
174174
return n0
175175
}"
@@ -180,7 +180,7 @@ exports[`compile > dynamic root nodes and interpolation 1`] = `
180180
const t0 = _template("<button></button>")
181181
_delegateEvents("click")
182182
183-
export function render(_ctx) {
183+
export function render(_ctx, _props) {
184184
const n0 = t0()
185185
_delegate(n0, "click", () => _ctx.handleClick)
186186
_renderEffect(() => _setText(n0, _ctx.count, "foo", _ctx.count, "foo", _ctx.count))
@@ -210,18 +210,29 @@ const t0 = _template("<p></p>")
210210
const t1 = _template("<span></span>")
211211
const t2 = _template("<div></div>")
212212
213-
export function render(_ctx) {
213+
export function render(_ctx, _props) {
214214
const n0 = t0()
215215
const n1 = t1()
216216
const n2 = t2()
217217
return [n0, n1, n2]
218218
}"
219219
`;
220220
221+
exports[`compile > props bindings 1`] = `
222+
"import { renderEffect as _renderEffect, setDynamicProp as _setDynamicProp, template as _template } from 'vue/vapor';
223+
const t0 = _template("<div>count</div>")
224+
225+
export function render(_ctx, _props) {
226+
const n0 = t0()
227+
_renderEffect(() => _setDynamicProp(n0, "count", _props.count))
228+
return n0
229+
}"
230+
`;
231+
221232
exports[`compile > static + dynamic root 1`] = `
222233
"import { createTextNode as _createTextNode } from 'vue/vapor';
223234
224-
export function render(_ctx) {
235+
export function render(_ctx, _props) {
225236
const n0 = _createTextNode([1, 2, "3", 4, 5, "6", 7, 8, "9", 'A', 'B'])
226237
return n0
227238
}"
@@ -231,7 +242,7 @@ exports[`compile > static template 1`] = `
231242
"import { template as _template } from 'vue/vapor';
232243
const t0 = _template("<div><p>hello</p><input><span></span></div>")
233244
234-
export function render(_ctx) {
245+
export function render(_ctx, _props) {
235246
const n0 = t0()
236247
return n0
237248
}"

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

+9
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ describe('compile', () => {
5959
expect(code).matchSnapshot()
6060
})
6161

62+
test('props bindings', () => {
63+
const code = compile(`<div :count="count">count</div>`, {
64+
bindingMetadata: {
65+
count: BindingTypes.PROPS,
66+
},
67+
})
68+
expect(code).matchSnapshot()
69+
})
70+
6271
describe('directives', () => {
6372
describe('v-pre', () => {
6473
test('basic', () => {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exports[`compiler: children transform > children & sibling references 1`] = `
44
"import { next as _next, createTextNode as _createTextNode, insert as _insert, renderEffect as _renderEffect, setText as _setText, template as _template } from 'vue/vapor';
55
const t0 = _template("<div><p></p> <!><p></p></div>")
66
7-
export function render(_ctx) {
7+
export function render(_ctx, _props) {
88
const n4 = t0()
99
const n0 = n4.firstChild
1010
const n3 = _next(n0, 2)

0 commit comments

Comments
 (0)