SpoonX / typer

Simple library helping you cast to types.
BSD 2-Clause "Simplified" License
3 stars 4 forks source link

Null float entity field converts to NaN on client #2

Open RWOverdijk opened 7 years ago

RWOverdijk commented 7 years ago

Avekonst commented 3 minutes ago I've created entity class with @type('float') fields. When I firstly get instance of this entity I don't fill some of this fields, save it and then try to reload. While entity populates on client "typer" try to cast float by 'parseFloat' function so in case of null it returns NaN, but for other types null. Aurelia binding goes into an infinite loop while it tries to compare old and new NaN values (newValue !== oldValue - return true if both NaN).

https://github.com/SpoonX/aurelia-orm/issues/289

RWOverdijk commented 7 years ago

https://github.com/SpoonX/typer/blob/master/index.js#L70

Change to value = value ? parseFloat(value) : value;