-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Improve elm.value update (fix #4392) #4402
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
Conversation
1. the elem is not active and the value is not equal to model.value 2. the elem need to be casted to number or trimed, and the casted value is not equal to model.value
} | ||
} | ||
|
||
export function isToNumber (modifiers: ?ASTModifiers, type: ?string): boolean { |
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.
I guess you can use a better name, as isToNumber
isn't the most meaningful of them IMHO.
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.
I think so, I'll try to find a better one
} | ||
|
||
export function isToNumber (modifiers: ?ASTModifiers, type: ?string): boolean { | ||
return modifiers && modifiers.number || (type === 'number') |
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.
The brackets are unnecessary, aren't they?
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.
Yes. &&
has higher priority, just to make it explicitly. I'll update it
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.
For logical operator && ||, updated the coding style to keep consistent with other codes
return directive.modifiers | ||
} | ||
} | ||
} |
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.
I think that this function is not problem, however, If modifier did not find, in end of function,
when you explicitly return, we can easily understand about this function.
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.
Added an explictly return undefined
statement
2. for logical operator && ||, keep it consistent with other codes
@yyx990803 CI dosen't run, will you please help to have a check on it ? |
const needNumber = (modifiers && modifiers.number) || vnode.elm.type === 'number' | ||
const needTrim = modifiers && modifiers.trim | ||
if (needNumber) { | ||
return toNumber(value, val) !== toNumber(val) |
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.
the first toNumber has an extra argument
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.
I'll correct it
return directive.modifiers | ||
} | ||
} | ||
return undefined |
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.
Isn't better to return an empty object so at the top you can do modifiers.number
instead of modifiers && modifiers.number
?
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.
Yes, thanks
I found an easier way: simply prevent updating when in focus, and force update on blur (see 8a7b02a) Thanks for the PR still, used your test cases :) |
Hmm, looks like the |
I ended up including your |
fix #4392
We should update the elm.value when in these cases: