Skip to content

Commit a481fa9

Browse files
author
Nedyalko Nikolov
committed
Mark text property as special and set it with a string comming from builder.
1 parent e4cf173 commit a481fa9

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

tests/app/xml-declaration/xml-declaration-tests.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,3 +900,15 @@ export function test_hasSourceCodeLocations() {
900900
var labelSource = Source.get(label);
901901
TKUnit.assertEqual(labelSource.toString(), "file:///app/" + basePath + "examples/test-page.xml:3:5");
902902
}
903+
904+
export function test_Setting_digits_for_text_Label_is_not_converted_to_number() {
905+
var p = <Page>builder.parse('<Page><Label id="testLabel" text="01234"/></Page>');
906+
var testLabel = <Label>p.getViewById("testLabel");
907+
TKUnit.assertEqual(testLabel.text, "01234");
908+
}
909+
910+
export function test_Setting_digits_for_text_Button_is_not_converted_to_number() {
911+
var p = <Page>builder.parse('<Page><Button id="testButton" text="01234"/></Page>');
912+
var testButton = <Button>p.getViewById("testButton");
913+
TKUnit.assertEqual(testButton.text, "01234");
914+
}

tns-core-modules/ui/core/view-common.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ function ensureVisualState() {
2929
registerSpecialProperty("class", (instance: definition.View, propertyValue: string) => {
3030
instance.className = propertyValue;
3131
});
32+
registerSpecialProperty("text", (instance, propertyValue) => {
33+
instance.set("text", propertyValue);
34+
});
3235

3336
function getEventOrGestureName(name: string): string {
3437
return name.indexOf("on") === 0 ? name.substr(2, name.length - 2) : name;

0 commit comments

Comments
 (0)