ensure Switch has type="button" (#192)

Closes: #178

Co-authored-by: =?UTF-8?q?Oskar=20L=C3=B6fgren?= <islander.abroad@gmail.com>

Co-authored-by: =?UTF-8?q?Oskar=20L=C3=B6fgren?= <islander.abroad@gmail.com>
This commit is contained in:
Robin Malfait
2021-01-08 23:00:39 +01:00
committed by GitHub
parent e941c7031b
commit 17a853501d
2 changed files with 8 additions and 0 deletions
@@ -117,6 +117,10 @@ export function Switch<TTag extends React.ElementType = typeof DEFAULT_SWITCH_TA
onKeyPress: handleKeyPress,
}
if (passThroughProps.as === 'button') {
Object.assign(propsWeControl, { type: 'button' })
}
return render({ ...passThroughProps, ...propsWeControl }, propsBag, DEFAULT_SWITCH_TAG)
}
@@ -74,6 +74,10 @@ export const Switch = defineComponent({
onKeyPress: this.handleKeyPress,
}
if (this.$props.as === 'button') {
Object.assign(propsWeControl, { type: 'button' })
}
return render({
props: { ...this.$props, ...propsWeControl },
slot,