From 3e21748af4dcf76fec3822b4d5e9c844794eda1d Mon Sep 17 00:00:00 2001 From: farfromrefuge Date: Wed, 22 Sep 2021 06:41:34 +0200 Subject: [PATCH] fix: background parsing color #9559 (#9560) --- packages/core/css/parser.ts | 2 +- packages/core/ui/styling/style-properties.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/core/css/parser.ts b/packages/core/css/parser.ts index 83c1ee1aa..e13411158 100644 --- a/packages/core/css/parser.ts +++ b/packages/core/css/parser.ts @@ -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; diff --git a/packages/core/ui/styling/style-properties.ts b/packages/core/ui/styling/style-properties.ts index c0fb01e4e..e57310201 100644 --- a/packages/core/ui/styling/style-properties.ts +++ b/packages/core/ui/styling/style-properties.ts @@ -838,7 +838,10 @@ backgroundPositionProperty.register(Style); function convertToBackgrounds(this: void, value: string): [CssProperty, 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) {