Fix setting text property to number. (#3449)

Fix setting JS property from native.
This commit is contained in:
Hristo Hristov
2017-01-09 18:13:31 +02:00
committed by GitHub
parent e3acdcbc78
commit 309ea148e1
23 changed files with 156 additions and 153 deletions

View File

@@ -94,7 +94,7 @@ export abstract class TextBaseCommon extends View implements TextBaseDefinition,
public onFormattedTextChanged(data: PropertyChangeData) {
let value = data.value;
this._setFormattedTextPropertyToNative(value);
this.nativePropertyChanged(textProperty, value.toString());
textProperty.nativeValueChange(this, value.toString());
}
public _addChildFromBuilder(name: string, value: any): void {

View File

@@ -22,11 +22,8 @@ export class TextBase extends TextBaseCommon {
return this._nativeView.getText();
}
set [textProperty.native](value: string) {
if (value === null || value === undefined) {
value = "";
}
this._nativeView.setText(value);
const text = (value === null || value === undefined) ? '' : value.toString();
this._nativeView.setText(text);
}
//FormattedText

View File

@@ -21,7 +21,7 @@ export class TextBase extends TextBaseCommon {
}
}
set [textProperty.native](value: string) {
let newValue = (typeof value === "undefined") || (value === null) ? "" : value + "";
let newValue = (value === undefined || value === null) ? '' : value.toString();
let nativeView = this.nativeView;
if (nativeView instanceof UIButton) {
nativeView.setTitleForState(newValue, UIControlState.Normal);