Skip to content

Commit 03d1d0a

Browse files
committed
refactor: delegate set modelValue event
1 parent 11b99ba commit 03d1d0a

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed
Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,146 +1,146 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`compiler: vModel transform > modifiers > .lazy 1`] = `
4-
"import { vModelText as _vModelText, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
4+
"import { vModelText as _vModelText, withDirectives as _withDirectives, delegate as _delegate, template as _template } from 'vue/vapor';
55
const t0 = _template("<input>")
66
77
export function render(_ctx) {
88
const n0 = t0()
99
_withDirectives(n0, [[_vModelText, () => _ctx.model, void 0, { lazy: true }]])
10-
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
10+
_delegate(n0, "update:modelValue", () => $event => (_ctx.model = $event))
1111
return n0
1212
}"
1313
`;
1414
1515
exports[`compiler: vModel transform > modifiers > .number 1`] = `
16-
"import { vModelText as _vModelText, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
16+
"import { vModelText as _vModelText, withDirectives as _withDirectives, delegate as _delegate, template as _template } from 'vue/vapor';
1717
const t0 = _template("<input>")
1818
1919
export function render(_ctx) {
2020
const n0 = t0()
2121
_withDirectives(n0, [[_vModelText, () => _ctx.model, void 0, { number: true }]])
22-
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
22+
_delegate(n0, "update:modelValue", () => $event => (_ctx.model = $event))
2323
return n0
2424
}"
2525
`;
2626
2727
exports[`compiler: vModel transform > modifiers > .trim 1`] = `
28-
"import { vModelText as _vModelText, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
28+
"import { vModelText as _vModelText, withDirectives as _withDirectives, delegate as _delegate, template as _template } from 'vue/vapor';
2929
const t0 = _template("<input>")
3030
3131
export function render(_ctx) {
3232
const n0 = t0()
3333
_withDirectives(n0, [[_vModelText, () => _ctx.model, void 0, { trim: true }]])
34-
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
34+
_delegate(n0, "update:modelValue", () => $event => (_ctx.model = $event))
3535
return n0
3636
}"
3737
`;
3838
3939
exports[`compiler: vModel transform > should support input (checkbox) 1`] = `
40-
"import { vModelCheckbox as _vModelCheckbox, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
40+
"import { vModelCheckbox as _vModelCheckbox, withDirectives as _withDirectives, delegate as _delegate, template as _template } from 'vue/vapor';
4141
const t0 = _template("<input type=\\"checkbox\\">")
4242
4343
export function render(_ctx) {
4444
const n0 = t0()
4545
_withDirectives(n0, [[_vModelCheckbox, () => _ctx.model]])
46-
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
46+
_delegate(n0, "update:modelValue", () => $event => (_ctx.model = $event))
4747
return n0
4848
}"
4949
`;
5050
5151
exports[`compiler: vModel transform > should support input (dynamic type) 1`] = `
52-
"import { vModelDynamic as _vModelDynamic, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
52+
"import { vModelDynamic as _vModelDynamic, withDirectives as _withDirectives, delegate as _delegate, template as _template } from 'vue/vapor';
5353
const t0 = _template("<input>")
5454
5555
export function render(_ctx) {
5656
const n0 = t0()
5757
_withDirectives(n0, [[_vModelDynamic, () => _ctx.model]])
58-
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
58+
_delegate(n0, "update:modelValue", () => $event => (_ctx.model = $event))
5959
return n0
6060
}"
6161
`;
6262
6363
exports[`compiler: vModel transform > should support input (radio) 1`] = `
64-
"import { vModelRadio as _vModelRadio, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
64+
"import { vModelRadio as _vModelRadio, withDirectives as _withDirectives, delegate as _delegate, template as _template } from 'vue/vapor';
6565
const t0 = _template("<input type=\\"radio\\">")
6666
6767
export function render(_ctx) {
6868
const n0 = t0()
6969
_withDirectives(n0, [[_vModelRadio, () => _ctx.model]])
70-
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
70+
_delegate(n0, "update:modelValue", () => $event => (_ctx.model = $event))
7171
return n0
7272
}"
7373
`;
7474
7575
exports[`compiler: vModel transform > should support input (text) 1`] = `
76-
"import { vModelText as _vModelText, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
76+
"import { vModelText as _vModelText, withDirectives as _withDirectives, delegate as _delegate, template as _template } from 'vue/vapor';
7777
const t0 = _template("<input type=\\"text\\">")
7878
7979
export function render(_ctx) {
8080
const n0 = t0()
8181
_withDirectives(n0, [[_vModelText, () => _ctx.model]])
82-
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
82+
_delegate(n0, "update:modelValue", () => $event => (_ctx.model = $event))
8383
return n0
8484
}"
8585
`;
8686
8787
exports[`compiler: vModel transform > should support select 1`] = `
88-
"import { vModelSelect as _vModelSelect, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
88+
"import { vModelSelect as _vModelSelect, withDirectives as _withDirectives, delegate as _delegate, template as _template } from 'vue/vapor';
8989
const t0 = _template("<select></select>")
9090
9191
export function render(_ctx) {
9292
const n0 = t0()
9393
_withDirectives(n0, [[_vModelSelect, () => _ctx.model]])
94-
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
94+
_delegate(n0, "update:modelValue", () => $event => (_ctx.model = $event))
9595
return n0
9696
}"
9797
`;
9898
9999
exports[`compiler: vModel transform > should support simple expression 1`] = `
100-
"import { vModelText as _vModelText, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
100+
"import { vModelText as _vModelText, withDirectives as _withDirectives, delegate as _delegate, template as _template } from 'vue/vapor';
101101
const t0 = _template("<input>")
102102
103103
export function render(_ctx) {
104104
const n0 = t0()
105105
_withDirectives(n0, [[_vModelText, () => _ctx.model]])
106-
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
106+
_delegate(n0, "update:modelValue", () => $event => (_ctx.model = $event))
107107
return n0
108108
}"
109109
`;
110110
111111
exports[`compiler: vModel transform > should support textarea 1`] = `
112-
"import { vModelText as _vModelText, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
112+
"import { vModelText as _vModelText, withDirectives as _withDirectives, delegate as _delegate, template as _template } from 'vue/vapor';
113113
const t0 = _template("<textarea></textarea>")
114114
115115
export function render(_ctx) {
116116
const n0 = t0()
117117
_withDirectives(n0, [[_vModelText, () => _ctx.model]])
118-
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
118+
_delegate(n0, "update:modelValue", () => $event => (_ctx.model = $event))
119119
return n0
120120
}"
121121
`;
122122
123123
exports[`compiler: vModel transform > should support w/ dynamic v-bind 1`] = `
124-
"import { vModelDynamic as _vModelDynamic, withDirectives as _withDirectives, on as _on, renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, template as _template } from 'vue/vapor';
124+
"import { vModelDynamic as _vModelDynamic, withDirectives as _withDirectives, delegate as _delegate, renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, template as _template } from 'vue/vapor';
125125
const t0 = _template("<input>")
126126
127127
export function render(_ctx) {
128128
const n0 = t0()
129129
_withDirectives(n0, [[_vModelDynamic, () => _ctx.model]])
130-
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
130+
_delegate(n0, "update:modelValue", () => $event => (_ctx.model = $event))
131131
_renderEffect(() => _setDynamicProps(n0, _ctx.obj))
132132
return n0
133133
}"
134134
`;
135135
136136
exports[`compiler: vModel transform > should support w/ dynamic v-bind 2`] = `
137-
"import { vModelDynamic as _vModelDynamic, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
137+
"import { vModelDynamic as _vModelDynamic, withDirectives as _withDirectives, delegate as _delegate, template as _template } from 'vue/vapor';
138138
const t0 = _template("<input>")
139139
140140
export function render(_ctx) {
141141
const n0 = t0()
142142
_withDirectives(n0, [[_vModelDynamic, () => _ctx.model]])
143-
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
143+
_delegate(n0, "update:modelValue", () => $event => (_ctx.model = $event))
144144
return n0
145145
}"
146146
`;

packages/compiler-vapor/src/generators/modelValue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ export function genSetModelValue(
2525

2626
return [
2727
NEWLINE,
28-
...genCall(vaporHelper('on'), `n${oper.element}`, name, handler),
28+
...genCall(vaporHelper('delegate'), `n${oper.element}`, name, handler),
2929
]
3030
}

packages/runtime-vapor/src/directives/vModel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import { MetadataKind, getMetadata } from '../metadata'
2020
type AssignerFn = (value: any) => void
2121
function getModelAssigner(el: Element): AssignerFn {
2222
const metadata = getMetadata(el)
23-
const fn: any = metadata[MetadataKind.event]['update:modelValue']
24-
return isArray(fn) ? value => invokeArrayFns(fn, value) : fn
23+
const fn = metadata[MetadataKind.event]['update:modelValue'] || []
24+
return value => invokeArrayFns(fn, value)
2525
}
2626

2727
function onCompositionStart(e: Event) {

0 commit comments

Comments
 (0)