Skip to content

Commit e572b60

Browse files
fix(vue): fix model value assignment
1 parent 3178af8 commit e572b60

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

packages/vue/src/runtime.ts

+9-19
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,13 @@ export const defineContainer = <Props, VModelType = string | number | boolean>(
8585
}
8686

8787
const emits: string[] = emitProps;
88-
const props = componentProps.reduce(
88+
const props = [ROUTER_LINK_VALUE, ...componentProps].reduce(
8989
(acc, prop) => {
90-
acc[prop] = { type: null as unknown as PropType<any>, default: EMPTY_PROP };
90+
acc[prop] = DEFAULT_EMPTY_PROP;
9191
return acc;
9292
},
9393
{} as Record<string, { type?: PropType<any>; default: Symbol }>
9494
) as ComponentObjectPropsOptions<Props & InputProps<VModelType>>;
95-
props[ROUTER_LINK_VALUE] = { type: null, default: DEFAULT_EMPTY_PROP };
9695
if (modelProp) {
9796
emits.push(UPDATE_VALUE_EVENT);
9897
props[MODEL_VALUE] = DEFAULT_EMPTY_PROP as unknown as PropType<any>;
@@ -109,8 +108,8 @@ export const defineContainer = <Props, VModelType = string | number | boolean>(
109108
* we register the event emmiter for @Event definitions
110109
* so we can use @event
111110
*/
112-
emitProps.forEach((eventName: string) => {
113-
containerRef.value!.addEventListener(eventName, (e: Event) => {
111+
emitProps.forEach((eventName) => {
112+
containerRef.value?.addEventListener(eventName, (e) => {
114113
emit(eventName, e);
115114
});
116115
});
@@ -199,7 +198,7 @@ export const defineContainer = <Props, VModelType = string | number | boolean>(
199198
}
200199
};
201200

202-
let propsToAdd: any = {
201+
const propsToAdd: Record<string, unknown> = {
203202
ref: containerRef,
204203
class: getElementClasses(containerRef, classes),
205204
onClick: handleClick,
@@ -214,7 +213,7 @@ export const defineContainer = <Props, VModelType = string | number | boolean>(
214213
for (const key in props) {
215214
const value = props[key as keyof InputProps<VModelType>];
216215
if ((props.hasOwnProperty(key) && value !== EMPTY_PROP) || key.startsWith(ARIA_PROP_PREFIX)) {
217-
propsToAdd[key] = value;
216+
propsToAdd[key as 'ariaLabel'] = value as string;
218217
}
219218

220219
/**
@@ -235,15 +234,9 @@ export const defineContainer = <Props, VModelType = string | number | boolean>(
235234
* was set as a static value (i.e. no v-model).
236235
*/
237236
if (props[MODEL_VALUE] !== EMPTY_PROP) {
238-
propsToAdd = {
239-
...propsToAdd,
240-
[modelProp]: props[MODEL_VALUE],
241-
};
237+
propsToAdd[modelProp] = props[MODEL_VALUE]
242238
} else if (modelPropValue !== EMPTY_PROP) {
243-
propsToAdd = {
244-
...propsToAdd,
245-
[modelProp]: modelPropValue,
246-
};
239+
propsToAdd[modelProp] = modelPropValue
247240
}
248241
}
249242

@@ -252,10 +245,7 @@ export const defineContainer = <Props, VModelType = string | number | boolean>(
252245
// of components that should become activatable and
253246
// focusable with router link.
254247
if (ROUTER_LINK_VALUE in props && props[ROUTER_LINK_VALUE] !== EMPTY_PROP) {
255-
propsToAdd = {
256-
...propsToAdd,
257-
href: props[ROUTER_LINK_VALUE],
258-
};
248+
propsToAdd.href = props[ROUTER_LINK_VALUE]
259249
}
260250

261251
/**

0 commit comments

Comments
 (0)