FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix: Invalid value 500 for property fontWeight in XML by hamorphis · Pull Request #3191 · NativeScript/NativeScript · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ts  (3) .xml  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
15 changes: 15 additions & 0 deletions apps/app/ui-tests-app/issues/issue-3175.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd">
<StackLayout>
<Label text="100" style.fontWeight="100" />
<Label text="200" style.fontWeight="200" />
<Label text="300" style.fontWeight="300" />
<Label text="400" style.fontWeight="400" />
<Label text="normal" style.fontWeight="normal" />
<Label text="500" style.fontWeight="500" />
<Label text="600" style.fontWeight="600" />
<Label text="700" style.fontWeight="700" />
<Label text="bold" style.fontWeight="bold" />
<Label text="800" style.fontWeight="800" />
<Label text="900" style.fontWeight="900" />
</StackLayout>
</Page>
1 change: 1 addition & 0 deletions apps/app/ui-tests-app/issues/main-page.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 16 additions & 2 deletions tests/app/ui/styling/style-properties-tests.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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.
(<any>testView.style).fontWeight = 100; TKUnit.assertEqual(testView.style.fontWeight, "100");
(<any>testView.style).fontWeight = 200; TKUnit.assertEqual(testView.style.fontWeight, "200");
(<any>testView.style).fontWeight = 300; TKUnit.assertEqual(testView.style.fontWeight, "300");
(<any>testView.style).fontWeight = 400; TKUnit.assertEqual(testView.style.fontWeight, "400");
(<any>testView.style).fontWeight = "normal"; TKUnit.assertEqual(testView.style.fontWeight, "normal");
(<any>testView.style).fontWeight = 500; TKUnit.assertEqual(testView.style.fontWeight, "500");
(<any>testView.style).fontWeight = 600; TKUnit.assertEqual(testView.style.fontWeight, "600");
(<any>testView.style).fontWeight = 700; TKUnit.assertEqual(testView.style.fontWeight, "700");
(<any>testView.style).fontWeight = "bold"; TKUnit.assertEqual(testView.style.fontWeight, "bold");
(<any>testView.style).fontWeight = 800; TKUnit.assertEqual(testView.style.fontWeight, "800");
(<any>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";
Expand Down
3 changes: 2 additions & 1 deletion tns-core-modules/ui/styling/style.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

Back | FazBrowse Home | New Git URL