fix(v-model): fix case where .trim and .number modifiers are used together (#5842)
fix #5839
This commit is contained in:
@@ -355,6 +355,37 @@ describe('component: emit', () => {
|
||||
expect(fn2).toHaveBeenCalledWith('two')
|
||||
})
|
||||
|
||||
test('.trim and .number modifiers should work with v-model on component', () => {
|
||||
const Foo = defineComponent({
|
||||
render() {},
|
||||
created() {
|
||||
this.$emit('update:modelValue', ' +01.2 ')
|
||||
this.$emit('update:foo', ' 1 ')
|
||||
}
|
||||
})
|
||||
|
||||
const fn1 = jest.fn()
|
||||
const fn2 = jest.fn()
|
||||
|
||||
const Comp = () =>
|
||||
h(Foo, {
|
||||
modelValue: null,
|
||||
modelModifiers: { trim: true, number: true },
|
||||
'onUpdate:modelValue': fn1,
|
||||
|
||||
foo: null,
|
||||
fooModifiers: { trim: true, number: true },
|
||||
'onUpdate:foo': fn2
|
||||
})
|
||||
|
||||
render(h(Comp), nodeOps.createElement('div'))
|
||||
|
||||
expect(fn1).toHaveBeenCalledTimes(1)
|
||||
expect(fn1).toHaveBeenCalledWith(1.2)
|
||||
expect(fn2).toHaveBeenCalledTimes(1)
|
||||
expect(fn2).toHaveBeenCalledWith(1)
|
||||
})
|
||||
|
||||
test('isEmitListener', () => {
|
||||
const options = {
|
||||
click: null,
|
||||
|
||||
Reference in New Issue
Block a user