Fix: CSS border-color does not recognize rgb and rgba values

Resolves #2781
This commit is contained in:
hamorphis
2016-09-21 16:31:30 +03:00
parent c91162b934
commit 08f9c941cc
3 changed files with 20 additions and 7 deletions

View File

@@ -9,7 +9,7 @@ Label {
} }
#s1 { #s1 {
border-width: 5; border-color: red; border-width: 5; border-color: rgba(255,0,0,1);
} }
#s2 { #s2 {
@@ -25,7 +25,7 @@ Label {
} }
#s5 { #s5 {
border-width: 5 10 15 20; border-color: red; border-width: 5 10 15 20; border-color: rgb(255, 0, 0);
} }
#s6 { #s6 {

View File

@@ -81,6 +81,14 @@ export function test_setting_borderColor_property_from_CSS_is_applied_to_Style()
test_property_from_CSS_is_applied_to_style("borderColor", "border-color", new color.Color("#FF0000"), "#FF0000"); test_property_from_CSS_is_applied_to_style("borderColor", "border-color", new color.Color("#FF0000"), "#FF0000");
} }
export function test_setting_borderColorRGB_property_from_CSS_is_applied_to_Style() {
test_property_from_CSS_is_applied_to_style("borderColor", "border-color", new color.Color("#FF0000"), "rgb(255, 0, 0)");
}
export function test_setting_borderColorRGBA_property_from_CSS_is_applied_to_Style() {
test_property_from_CSS_is_applied_to_style("borderColor", "border-color", new color.Color("#FF0000"), "rgba(255,0,0,1)");
}
export function test_setting_borderRadius_property_from_CSS_is_applied_to_Style() { export function test_setting_borderRadius_property_from_CSS_is_applied_to_Style() {
test_property_from_CSS_is_applied_to_style("borderRadius", "border-radius", 20); test_property_from_CSS_is_applied_to_style("borderRadius", "border-radius", 20);
} }

View File

@@ -1613,6 +1613,11 @@ function parseBorderColor(value: any): definition.BorderColor {
var result: definition.BorderColor = { top: undefined, right: undefined, bottom: undefined, left: undefined }; var result: definition.BorderColor = { top: undefined, right: undefined, bottom: undefined, left: undefined };
try { try {
if (types.isString(value)) { if (types.isString(value)) {
if (value.indexOf("rgb") === 0){
result.top = result.right = result.bottom = result.left = new Color(value);
return result;
}
let arr = value.split(/[ ,]+/); let arr = value.split(/[ ,]+/);
if (arr.length === 1){ if (arr.length === 1){
let arr0 = new Color(arr[0]); let arr0 = new Color(arr[0]);
@@ -1650,11 +1655,11 @@ function parseBorderColor(value: any): definition.BorderColor {
} }
} }
else if (value instanceof Color) { else if (value instanceof Color) {
result.top = result.right = result.bottom = result.left = value; result.top = result.right = result.bottom = result.left = value;
} }
else { else {
result = value; result = value;
} }
} }
catch(ex){ catch(ex){
if (trace.enabled) { if (trace.enabled) {