mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Fix setting text property to number. (#3449)
Fix setting JS property from native.
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user