Skip to content
This repository has been archived by the owner on Nov 30, 2020. It is now read-only.

fix(radio): v-model doesn't work correctly #412

Merged
merged 3 commits into from
Aug 29, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions components/radio/Radio.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<template>
<div class="mdc-radio" :class="classes">
<div
class="mdc-radio"
:class="classes"
>
<input
ref="input"
class="mdc-radio__native-control"
type="radio"
v-bind="$attrs"
v-on="$listeners"
@change="onChange"
ref="input"
v-bind="attrs"
v-on="listeners"
@change="$emit('change', $event.target.value)"
>
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle" />
Expand Down Expand Up @@ -42,6 +45,16 @@ export default {
return {
'mdc-radio--disabled': this.$attrs.disabled != null
}
},
attrs () {
const _attrs = this.$attrs
delete _attrs.picked
return _attrs
},
listeners () {
const _listeners = this.$listeners
delete _listeners.change
return _listeners
}
},
watch: {
Expand All @@ -56,9 +69,6 @@ export default {
if (this.js) this.mdcRadio.destroy()
},
methods: {
onChange () {
this.$emit('change', this.$refs.input.value)
},
reInstantiate () {
if (this.js) {
if (this.mdcRadio) {
Expand Down