fix: background parsing color #9559 (#9560)

This commit is contained in:
farfromrefuge
2021-09-22 06:41:34 +02:00
committed by GitHub
parent 889f6d73cf
commit 3e21748af4
2 changed files with 5 additions and 2 deletions

View File

@@ -23,7 +23,7 @@ export interface LinearGradient {
colors: ColorStop[];
}
export interface Background {
readonly color?: number;
readonly color?: number | Color;
readonly image?: URL | LinearGradient;
readonly repeat?: BackgroundRepeat;
readonly position?: BackgroundPosition;

View File

@@ -838,7 +838,10 @@ backgroundPositionProperty.register(Style);
function convertToBackgrounds(this: void, value: string): [CssProperty<any, any>, any][] {
if (typeof value === 'string') {
const backgrounds = parser.parseBackground(value).value;
const backgroundColor = backgrounds.color ? new Color(backgrounds.color) : unsetValue;
let backgroundColor = unsetValue;
if (backgrounds.color) {
backgroundColor = backgrounds.color instanceof Color ? backgrounds.color : new Color(backgrounds.color);
}
let backgroundImage: string | LinearGradient;
if (typeof backgrounds.image === 'object' && backgrounds.image) {