mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
Merge pull request #3392 from NativeScript/issue-3210
Fix: SegmentedBar crash using a number as title
This commit is contained in:
@ -270,3 +270,14 @@ export var testSelectedIndexChangedIsRaisedCorrectlyIfItemsNotBound = function (
|
|||||||
TKUnit.assertEqual(newSelectedIndex, 1);
|
TKUnit.assertEqual(newSelectedIndex, 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function test_SettingNumberAsTitleFromXML_DoesNotThrow() {
|
||||||
|
let segmentedBar = new segmentedBarModule.SegmentedBar();
|
||||||
|
let item = new segmentedBarModule.SegmentedBarItem();
|
||||||
|
(<any>item).title = 1;
|
||||||
|
segmentedBar.items = [item];
|
||||||
|
|
||||||
|
buildUIAndRunTest(segmentedBar, function (views: Array<View>) {
|
||||||
|
TKUnit.assertEqual(item.title, "1");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -17,8 +17,9 @@ export abstract class SegmentedBarItemBase extends ViewBase implements Segmented
|
|||||||
return this._title;
|
return this._title;
|
||||||
}
|
}
|
||||||
set title(value: string) {
|
set title(value: string) {
|
||||||
if (this._title !== value) {
|
let strValue = (value !== null && value !== undefined) ? value.toString() : "";
|
||||||
this._title = value;
|
if (this._title !== strValue) {
|
||||||
|
this._title = strValue;
|
||||||
this._update();
|
this._update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ export class SegmentedBar extends SegmentedBarBase {
|
|||||||
|
|
||||||
private insertTab(tabItem: SegmentedBarItem, index: number): void {
|
private insertTab(tabItem: SegmentedBarItem, index: number): void {
|
||||||
const tab = this.android.newTabSpec(index + "");
|
const tab = this.android.newTabSpec(index + "");
|
||||||
tab.setIndicator(tabItem.title);
|
tab.setIndicator(tabItem.title + "");
|
||||||
tab.setContent(this.tabContentFactory);
|
tab.setContent(this.tabContentFactory);
|
||||||
|
|
||||||
let tabHost = this.android;
|
let tabHost = this.android;
|
||||||
|
Reference in New Issue
Block a user