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

Fix: CSS border-color does not recognize rgb and rgba values · NativeScript/NativeScript@08f9c94 · GitHub

Commit 08f9c94

Browse files
committed
Fix: CSS border-color does not recognize rgb and rgba values
Resolves #2781
1 parent c91162b commit 08f9c94

3 files changed

Lines changed: 20 additions & 7 deletions

File tree

‎apps/app/ui-tests-app/css/label-border.css‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Label {
99
}
1010

1111
#s1 {
12-
border-width: 5; border-color: red;
12+
border-width: 5; border-color: rgba(255,0,0,1);
1313
}
1414

1515
#s2 {
@@ -25,7 +25,7 @@ Label {
2525
}
2626

2727
#s5 {
28-
border-width: 5 10 15 20; border-color: red;
28+
border-width: 5 10 15 20; border-color: rgb(255, 0, 0);
2929
}
3030

3131
#s6 {

‎tests/app/ui/styling/style-properties-tests.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ export function test_setting_borderColor_property_from_CSS_is_applied_to_Style()
8181
test_property_from_CSS_is_applied_to_style("borderColor", "border-color", new color.Color("#FF0000"), "#FF0000");
8282
}
8383

84+
export function test_setting_borderColorRGB_property_from_CSS_is_applied_to_Style() {
85+
test_property_from_CSS_is_applied_to_style("borderColor", "border-color", new color.Color("#FF0000"), "rgb(255, 0, 0)");
86+
}
87+
88+
export function test_setting_borderColorRGBA_property_from_CSS_is_applied_to_Style() {
89+
test_property_from_CSS_is_applied_to_style("borderColor", "border-color", new color.Color("#FF0000"), "rgba(255,0,0,1)");
90+
}
91+
8492
export function test_setting_borderRadius_property_from_CSS_is_applied_to_Style() {
8593
test_property_from_CSS_is_applied_to_style("borderRadius", "border-radius", 20);
8694
}

‎tns-core-modules/ui/styling/style.ts‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,11 @@ function parseBorderColor(value: any): definition.BorderColor {
16131613
var result: definition.BorderColor = { top: undefined, right: undefined, bottom: undefined, left: undefined };
16141614
try {
16151615
if (types.isString(value)) {
1616+
if (value.indexOf("rgb") === 0){
1617+
result.top = result.right = result.bottom = result.left = new Color(value);
1618+
return result;
1619+
}
1620+
16161621
let arr = value.split(/[ ,]+/);
16171622
if (arr.length === 1){
16181623
let arr0 = new Color(arr[0]);
@@ -1650,11 +1655,11 @@ function parseBorderColor(value: any): definition.BorderColor {
16501655
}
16511656
}
16521657
else if (value instanceof Color) {
1653-
result.top = result.right = result.bottom = result.left = value;
1654-
}
1655-
else {
1656-
result = value;
1657-
}
1658+
result.top = result.right = result.bottom = result.left = value;
1659+
}
1660+
else {
1661+
result = value;
1662+
}
16581663
}
16591664
catch(ex){
16601665
if (trace.enabled) {

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL