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
5 changes: 3 additions & 2 deletions packages/runtime-dom/src/directives/vModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ export const vModelText: ModelDirective<
el[assignKey] = getModelAssigner(vnode)
// avoid clearing unresolved text. #2302
if ((el as any).composing) return

const elValue =
number || el.type === 'number' ? looseToNumber(el.value) : el.value
number || (el.type === 'number' && el.value[0] !== '0')
Comment thread
sxzz marked this conversation as resolved.
Outdated
? looseToNumber(el.value)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made two small tweaks here:

  1. This leading 0 check should apply to both type="number" and .number modifier cases
  2. The leading 0 check should not apply to decimals like 0.123.

: el.value
const newValue = value == null ? '' : value

if (elValue === newValue) {
Expand Down