-
Notifications
You must be signed in to change notification settings - Fork 44
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
Generalisation of lowercase etc enforcements on inputs #69
Conversation
src/Rifm.js
Outdated
props.onChange( | ||
props.replace != null | ||
? props.replace(formattedValue) | ||
: formattedValue |
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.
Put replaceValue into upper scope and reuse it here please. It will be inlined by minifier.
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.
No, 10 bytes gzipped lost
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.
Readability of this fragment is bad. Only warning condition should be wrapped with NODE_ENV
const { replace } = props; | ||
const userValue = replace | ||
? replace(props.format(props.value)) | ||
: props.format(props.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.
props.format(props.value) can be reused to achieve better minified size
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.
At at least destructure format
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.
having gzip it s usually not true, in gzip this duplicate is just a back ref and size
solves #65
replace: str=>str
method added to Rifm, it allows to do postprocessing operation after format.And if
replace(value).length === value.length
then replace doesn't affect cursor position.So lowercase enforcement now look
And you can even replace with any text see new example.