|
|
@@ -1269,4 +1269,41 @@ describe('vModel', () => {
|
|
|
expect(foo.selected).toEqual(true)
|
|
|
expect(bar.selected).toEqual(true)
|
|
|
})
|
|
|
+
|
|
|
+ // #10503
|
|
|
+ test('equal value with a leading 0 should trigger update.', async () => {
|
|
|
+ const setNum = function (this: any, value: any) {
|
|
|
+ this.num = value
|
|
|
+ }
|
|
|
+ const component = defineComponent({
|
|
|
+ data() {
|
|
|
+ return { num: 0 }
|
|
|
+ },
|
|
|
+ render() {
|
|
|
+ return [
|
|
|
+ withVModel(
|
|
|
+ h('input', {
|
|
|
+ id: 'input_num1',
|
|
|
+ type: 'number',
|
|
|
+ 'onUpdate:modelValue': setNum.bind(this),
|
|
|
+ }),
|
|
|
+ this.num,
|
|
|
+ ),
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ })
|
|
|
+
|
|
|
+ render(h(component), root)
|
|
|
+ const data = root._vnode.component.data
|
|
|
+
|
|
|
+ const inputNum1 = root.querySelector('#input_num1')!
|
|
|
+ expect(inputNum1.value).toBe('0')
|
|
|
+
|
|
|
+ inputNum1.value = '01'
|
|
|
+ triggerEvent('input', inputNum1)
|
|
|
+ await nextTick()
|
|
|
+ expect(data.num).toBe(1)
|
|
|
+
|
|
|
+ expect(inputNum1.value).toBe('1')
|
|
|
+ })
|
|
|
})
|