diff --git a/apps/app/ui-tests-app/issues/issue-3175.xml b/apps/app/ui-tests-app/issues/issue-3175.xml
new file mode 100644
index 000000000..7e76d79fa
--- /dev/null
+++ b/apps/app/ui-tests-app/issues/issue-3175.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/apps/app/ui-tests-app/issues/main-page.ts b/apps/app/ui-tests-app/issues/main-page.ts
index de6c32a97..0fcaf6598 100644
--- a/apps/app/ui-tests-app/issues/main-page.ts
+++ b/apps/app/ui-tests-app/issues/main-page.ts
@@ -18,6 +18,7 @@ export function pageLoaded(args: EventData) {
examples.set("2661", "issues/issue-2661");
examples.set("3113", "issues/issue-3113");
examples.set("3164", "issues/issue-3164");
+ examples.set("3175", "issues/issue-3175");
let viewModel = new SubMainPageViewModel(wrapLayout, examples);
page.bindingContext = viewModel;
diff --git a/tests/app/ui/styling/style-properties-tests.ts b/tests/app/ui/styling/style-properties-tests.ts
index 1d8003bbb..681822214 100644
--- a/tests/app/ui/styling/style-properties-tests.ts
+++ b/tests/app/ui/styling/style-properties-tests.ts
@@ -529,9 +529,7 @@ function test_font_shorthand_property(short: string, family: string, size: numbe
TKUnit.assertEqual(testView.style.fontWeight, weight, "style.fontWeight");
TKUnit.assertEqual(testView.style.fontSize, size, "style.fontSize");
}
-
export function test_setting_font_properties_sets_native_font() {
-
if (fontModule.ios) {
var basePath = "fonts";
fontModule.ios.registerFont(basePath + "/Roboto-Regular.ttf");
@@ -571,6 +569,22 @@ function test_native_font(style: string, weight: string) {
//TODO: If needed add tests for other platforms
}
+export function test_FontWeightsParsedAsNumbersByTheXmlParserAreConvertedToStrings() {
+ var testView = new buttonModule.Button();
+ // The XML parser will interpret "100" as a number and feed it to Style, so simulate this here.
+ (testView.style).fontWeight = 100; TKUnit.assertEqual(testView.style.fontWeight, "100");
+ (testView.style).fontWeight = 200; TKUnit.assertEqual(testView.style.fontWeight, "200");
+ (testView.style).fontWeight = 300; TKUnit.assertEqual(testView.style.fontWeight, "300");
+ (testView.style).fontWeight = 400; TKUnit.assertEqual(testView.style.fontWeight, "400");
+ (testView.style).fontWeight = "normal"; TKUnit.assertEqual(testView.style.fontWeight, "normal");
+ (testView.style).fontWeight = 500; TKUnit.assertEqual(testView.style.fontWeight, "500");
+ (testView.style).fontWeight = 600; TKUnit.assertEqual(testView.style.fontWeight, "600");
+ (testView.style).fontWeight = 700; TKUnit.assertEqual(testView.style.fontWeight, "700");
+ (testView.style).fontWeight = "bold"; TKUnit.assertEqual(testView.style.fontWeight, "bold");
+ (testView.style).fontWeight = 800; TKUnit.assertEqual(testView.style.fontWeight, "800");
+ (testView.style).fontWeight = 900; TKUnit.assertEqual(testView.style.fontWeight, "900");
+}
+
export var test_setting_button_whiteSpace_normal_sets_native = function () {
var testView = new buttonModule.Button();
testView.style.whiteSpace = "nowrap";
diff --git a/tns-core-modules/ui/styling/style.ts b/tns-core-modules/ui/styling/style.ts
index f271eac0d..9120f47d5 100644
--- a/tns-core-modules/ui/styling/style.ts
+++ b/tns-core-modules/ui/styling/style.ts
@@ -650,7 +650,8 @@ export class Style extends DependencyObservable implements styling.Style {
return this._getValue(fontWeightProperty);
}
set fontWeight(value: string) {
- this._setValue(fontWeightProperty, value);
+ let stringValue = value ? value.toString() : undefined;
+ this._setValue(fontWeightProperty, stringValue);
}
get font(): string {