Commit f20c3788 authored by baiyaaaaa's avatar baiyaaaaa Committed by 杨奕

fix input-number invalid value reset bug

parent 42eb169e
......@@ -117,6 +117,8 @@
if (newVal <= this.max && newVal >= this.min) {
this.$emit('change', newVal, oldVal);
this.$emit('input', newVal);
} else {
this.currentValue = oldVal;
}
}
},
......
......@@ -234,6 +234,35 @@ describe('InputNumber', () => {
expect(vm.$el.querySelector('.el-input-number__decrease')).to.not.exist;
expect(vm.$el.querySelector('.el-input-number__increase')).to.not.exist;
});
it('invalid value reset', done => {
vm = createVue({
template: `
<el-input-number v-model="value" :min="5" :max="10">
</el-input-number>
`,
data() {
return {
value: 5
};
}
}, true);
vm.value = 100;
vm.$nextTick(_ => {
expect(vm.value).to.be.equal(5);
vm.value = 4;
vm.$nextTick(_ => {
expect(vm.value).to.be.equal(5);
vm.value = 'dsajkhd';
vm.$nextTick(_ => {
expect(vm.value).to.be.equal(5);
done();
});
});
});
});
it('event:change', done => {
vm = createVue({
template: `
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment