mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-26 00:09:15 +08:00
fix(Stepper): change event emitted twice (#7820)
This commit is contained in:
parent
97509a90b1
commit
b89832c03e
@ -193,6 +193,11 @@ export default createComponent({
|
|||||||
event.target.value = formatted;
|
event.target.value = formatted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// perfer number type
|
||||||
|
if (formatted === String(+formatted)) {
|
||||||
|
formatted = +formatted;
|
||||||
|
}
|
||||||
|
|
||||||
this.emitChange(formatted);
|
this.emitChange(formatted);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ test('filter value during user input', () => {
|
|||||||
input.element.value = '2';
|
input.element.value = '2';
|
||||||
input.trigger('input');
|
input.trigger('input');
|
||||||
expect(input.element.value).toEqual('2');
|
expect(input.element.value).toEqual('2');
|
||||||
expect(wrapper.emitted('input')[1][0]).toEqual('2');
|
expect(wrapper.emitted('input')[1][0]).toEqual(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('shoud watch value and format it', () => {
|
test('shoud watch value and format it', () => {
|
||||||
@ -149,12 +149,11 @@ test('only allow interger', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const input = wrapper.find('input');
|
const input = wrapper.find('input');
|
||||||
input.element.value = '1.2';
|
input.element.value = '2.2';
|
||||||
input.trigger('input');
|
input.trigger('input');
|
||||||
input.trigger('blur');
|
input.trigger('blur');
|
||||||
|
|
||||||
expect(wrapper.emitted('input')[0][0]).toEqual('1');
|
expect(wrapper.emitted('input')[0][0]).toEqual(2);
|
||||||
expect(wrapper.emitted('input')[1][0]).toEqual(1);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('input invalid value and blur', () => {
|
test('input invalid value and blur', () => {
|
||||||
@ -246,8 +245,8 @@ test('async-change prop', () => {
|
|||||||
input.element.value = '3';
|
input.element.value = '3';
|
||||||
input.trigger('input');
|
input.trigger('input');
|
||||||
|
|
||||||
expect(wrapper.emitted('input')[1][0]).toEqual('3');
|
expect(wrapper.emitted('input')[1][0]).toEqual(3);
|
||||||
expect(wrapper.emitted('change')[1][0]).toEqual('3');
|
expect(wrapper.emitted('change')[1][0]).toEqual(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('min value is 0', () => {
|
test('min value is 0', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user