Skip to content

Commit 4275c8c

Browse files
nandi95lmiller1990
authored andcommitted
fix: Added prop update on emit for v-model
1 parent a9139b0 commit 4275c8c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/emit.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function recordEvent(
4848
events: Events,
4949
vm: ComponentInternalInstance,
5050
event: string,
51-
args: Events[number]
51+
args: unknown[]
5252
): void {
5353
// Functional component wrapper creates a parent component
5454
let wrapperVm = vm
@@ -64,4 +64,12 @@ function recordEvent(
6464

6565
// Record the event message sent by the emit
6666
events[cid][event].push(args)
67+
68+
if (event.startsWith('update:')) {
69+
if (args.length !== 1) {
70+
throw new Error('Two-way bound properties have to emit a single value.' + args.length + ' values given.')
71+
}
72+
73+
vm.props[event.slice('update:'.length)] = args[0]
74+
}
6775
}

0 commit comments

Comments
 (0)