Mark text property as special and set it with a string comming from builder.

This commit is contained in:
Nedyalko Nikolov
2016-07-19 14:37:10 +03:00
parent e4cf173e3f
commit a481fa9808
2 changed files with 15 additions and 0 deletions

View File

@ -900,3 +900,15 @@ export function test_hasSourceCodeLocations() {
var labelSource = Source.get(label);
TKUnit.assertEqual(labelSource.toString(), "file:///app/" + basePath + "examples/test-page.xml:3:5");
}
export function test_Setting_digits_for_text_Label_is_not_converted_to_number() {
var p = <Page>builder.parse('<Page><Label id="testLabel" text="01234"/></Page>');
var testLabel = <Label>p.getViewById("testLabel");
TKUnit.assertEqual(testLabel.text, "01234");
}
export function test_Setting_digits_for_text_Button_is_not_converted_to_number() {
var p = <Page>builder.parse('<Page><Button id="testButton" text="01234"/></Page>');
var testButton = <Button>p.getViewById("testButton");
TKUnit.assertEqual(testButton.text, "01234");
}

View File

@ -29,6 +29,9 @@ function ensureVisualState() {
registerSpecialProperty("class", (instance: definition.View, propertyValue: string) => {
instance.className = propertyValue;
});
registerSpecialProperty("text", (instance, propertyValue) => {
instance.set("text", propertyValue);
});
function getEventOrGestureName(name: string): string {
return name.indexOf("on") === 0 ? name.substr(2, name.length - 2) : name;