Empty Textbox with Number type should return null after validation even if source of library minified by UglifyJS.
Actual behaviour
Empty Textbox with Number type returns NaN after validation.
Steps to reproduce
Minify project by UglifyJS
Call validate() on Textbox instance and inspect returned result. Actual value will be reported as NaN
Details
Just found weird issue with numberTransformer that occurred after library compression by UglifyJS. Empty Textbox value reported as NaN after validate call.
It caused by incorrect isNumeric detection logic in parseNumber function used in numberTransformer.
For empty string parseFloat will return NaN that can't be correctly compared with zero. Result always will be false regardless of operator < or >.
After minification (with unsafe_comps option)
function parseNumber(value) {
const n = parseFloat(value)
const isNumeric = (value - n + 1) >= 0
return isNumeric ? n : toNull(value)
}
will became
function c(e) {
var t = parseFloat(e);
return 0 > e - t + 1 ? l(e) : t
}
So compare operator has changed but result still the same – false and finally NaN is returned.
Hope my explanation is clear.
So it will be great if deeply minified tcomb-form will work correctly.
Version
Expected behaviour
Empty
Textbox
withNumber
type should returnnull
after validation even if source of library minified by UglifyJS.Actual behaviour
Empty
Textbox
withNumber
type returnsNaN
after validation.Steps to reproduce
validate()
onTextbox
instance and inspect returned result. Actual value will be reported asNaN
Details
Just found weird issue with
numberTransformer
that occurred after library compression by UglifyJS. EmptyTextbox
value reported asNaN
aftervalidate
call.It caused by incorrect
isNumeric
detection logic inparseNumber
function used innumberTransformer
. For empty stringparseFloat
will returnNaN
that can't be correctly compared with zero. Result always will befalse
regardless of operator<
or>
. After minification (withunsafe_comps
option)will became
So compare operator has changed but result still the same –
false
and finallyNaN
is returned. Hope my explanation is clear. So it will be great if deeply minifiedtcomb-form
will work correctly.