-
Notifications
You must be signed in to change notification settings - Fork 86
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
refactor!: return a marker string to help Flow detect bad input #8413
Conversation
* @private | ||
*/ | ||
get __hasUnparsableValue() { | ||
return this.inputElement.validity.badInput; | ||
get __unparsableValue() { |
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 found the previous approach with the boolean getter a bit clearer, and it looks like we don't necessarily have to change this. Having an unparsable value string if the value is parsable is potentially confusing. A boolean expresses this clearer because either the value parsable or not, and that is all we are interested in.
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.
Thanks, I reverted the previous approach and also added an undefined check to the _inputElementValue
getter that's necessary for the Flow ITs to pass.
* @param {InputEvent} event | ||
* @protected | ||
*/ | ||
_setHasInputValue(event) { |
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.
Let's also remove this method from input-mixin.d.ts
.
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.
Done.
|
Description
This PR changes number fields to make the
_inputElementValue
getter return aNaN
marker string when input can't be parsed. This change will allow us to replace_hasInputValue
with_inputElementValue
in Flow NumberField and then deprecate it in the web components. Previously, detecting bad input via_inputElementValue
wasn't possible sinceinput[type=number]
elements give an empty string for unparsable values.Since
_inputElementValue
is a protected method, I marked this as a possible breaking changeType of change