-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(v-model): keep the same behavior as v-model
with undefined
value with 2.x
#1530
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -47,7 +47,7 @@ export const vModelText: ModelDirective< | |||||
HTMLInputElement | HTMLTextAreaElement | ||||||
> = { | ||||||
beforeMount(el, { value, modifiers: { lazy, trim, number } }, vnode) { | ||||||
el.value = value | ||||||
if (value !== undefined && value !== null) el.value = value | ||||||
el._assign = getModelAssigner(vnode) | ||||||
const castToNumber = number || el.type === 'number' | ||||||
addEventListener(el, lazy ? 'change' : 'input', e => { | ||||||
|
@@ -85,6 +85,7 @@ export const vModelText: ModelDirective< | |||||
return | ||||||
} | ||||||
} | ||||||
if (value === undefined || value === null) value = '' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Literally assigning NULL to native input value should has same effect. Probably checks Check out example:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above:
Suggested change
|
||||||
el.value = value | ||||||
} | ||||||
} | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should also be able to do