Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
test(runtime-dom): add test
  • Loading branch information
OnlyWick committed Mar 13, 2024
commit 41589339456aa46c920a18adc84c41122de90e66
37 changes: 37 additions & 0 deletions packages/runtime-dom/__tests__/directives/vModel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1237,4 +1237,41 @@ describe('vModel', () => {
await nextTick()
expect(data.value).toEqual('使用拼音输入')
})

// #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')
})
})