Permalink
Browse files

fix(form-input): Fix reactivity (issue #817)

  • Loading branch information...
tmorehouse committed Aug 12, 2017
1 parent 4a62e1b commit 88e2dbbd78e2c0651d688fe1eb9abff93e2f806d
Showing with 14 additions and 8 deletions.
  1. +14 −8 lib/components/form-input.vue
@@ -32,7 +32,6 @@
<script>
import { formMixin } from '../mixins';
import bFormInputStatic from './form-input-static.vue';
export default {
mixins: [formMixin],
components: {bFormInputStatic},
@@ -60,27 +59,35 @@
return this.invalid;
}
},
watch:{
value(newVal, oldVal) {
if (newVal !== oldVal){
this.$refs.input.value = newVal;
}
}
},
methods: {
format(value, el) {
if (this.formatter) {
const formattedValue = this.formatter(value, el);
if (formattedValue !== value) {
value = formattedValue;
this.$refs.input.value = formattedValue;
return formattedValue;
}
}
return value;
},
onInput(value, el) {
let formattedValue=value;
if (!this.lazyFormatter) {
value = this.format(value, el);
formattedValue = this.format(value, el);
}
this.$emit('input', value);
this.$emit('input', formattedValue);
},
onChange(value, el) {
value = this.format(value, el);
this.$emit('input', value);
this.$emit('change', value);
const formattedValue = this.format(value, el);
this.$emit('input', formattedValue);
this.$emit('change', formattedValue);
},
onKeyUp(e) {
this.$emit('keyup', e);
@@ -142,5 +149,4 @@
}
}
};
</script>

0 comments on commit 88e2dbb

Please sign in to comment.