Skip to content

Commit 2656f18

Browse files
author
Nedyalko Nikolov
authored
Merge pull request NativeScript#2474 from NativeScript/nnikolov/TextPropertyMustBeString
Mark text property as special and set it with a string comming from b…
2 parents a9d835b + a481fa9 commit 2656f18

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
@@ -21,6 +21,9 @@ import {Source} from "utils/debug";
2121
registerSpecialProperty("class", (instance: definition.View, propertyValue: string) => {
2222
instance.className = propertyValue;
2323
});
24+
registerSpecialProperty("text", (instance, propertyValue) => {
25+
instance.set("text", propertyValue);
26+
});
2427

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

0 commit comments

Comments
 (0)