@@ -32,7 +32,7 @@ const Self = class ColorElement extends NudeElement {
3232 static all = { } ;
3333 static dependencies = new Set ( ) ;
3434
35- /** @type {Map<string, Color > } */
35+ /** @type {Map<string, string > } */
3636 static #resolvedColors = new Map ( ) ;
3737
3838 static globalStyles = [ { css : baseGlobalStyles } ] ;
@@ -154,7 +154,8 @@ const Self = class ColorElement extends NudeElement {
154154 catch {
155155 // Color.js can't parse the color value; possibly one of the values we can handle gracefully
156156 if ( Self . #resolvedColors. has ( value ) ) {
157- return Self . #resolvedColors. get ( value ) ;
157+ let color = Self . #resolvedColors. get ( value ) ;
158+ return Self . Color . get ( color ) ;
158159 }
159160
160161 if ( ! CSS . supports ( "color" , value ) ) {
@@ -165,11 +166,14 @@ const Self = class ColorElement extends NudeElement {
165166 // One of the supported color values; resolve and cache it
166167 element . style . backgroundColor = value ;
167168 let color = getComputedStyle ( element ) . backgroundColor ;
168- color = Self . Color . get ( color ) ;
169- Self . #resolvedColors. set ( value , color ) ;
170169 element . style . backgroundColor = "" ;
171170
172- return color ;
171+ let resolvedColor = Self . resolveColor ( color , element ) ;
172+ if ( resolvedColor ) {
173+ Self . #resolvedColors. set ( value , color ) ;
174+ }
175+
176+ return resolvedColor ;
173177 }
174178 }
175179} ;
0 commit comments