wsick / Fayde

Inspired by Silverlight; XAML engine using Javascript and rendering to the HTML5 Canvas.
MIT License
189 stars 27 forks source link

DateTime value set in XMAL doesn't get converted to DateTime after the XAML is Loaded #144

Closed Sally-Xu closed 9 years ago

Sally-Xu commented 9 years ago

Sample XAML:

The SelectedDate is still a string type after the control is loaded. It should be in DateTime type.

BSick7 commented 9 years ago

Please submit a PR with a reproducible test.

Sally-Xu commented 9 years ago

I found the reason for this: there is no converter for DateTime type in the nullstone.convertAnyToType function, only a converter for Date type.

export function convertAnyToType (val: any, type: Function): any { var converter: (val: any) => any = (converters)[type]; if (converter) return converter(val); if (type instanceof Enum) { var enumo = (type).Object; if (enumo.Converter) return enumo.Converter(val); val = val || 0; if (typeof val === "string") return enumo[val]; return val; } return val; }

Not sure how to fix this because DateTime is defined in Fayde, nullstone certainly doesn't know this type.

BSick7 commented 9 years ago

Converters can be registered through nullstone.registerTypeConverter(<type>, <converter>). Implemented in v0.16.42.