Skip to content

Commit c62524b

Browse files
Address feedback: Improve API + add some docs
1 parent f6f88bc commit c62524b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/common/color-element.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ const Self = class ColorElement extends NudeElement {
3131
static Color;
3232
static all = {};
3333
static dependencies = new Set();
34+
35+
/** @type {Map<string, Color>} */
3436
static resolvedColors = new Map();
3537

3638
static globalStyles = [{ css: baseGlobalStyles }];
@@ -143,6 +145,7 @@ const Self = class ColorElement extends NudeElement {
143145
* Resolve a color value and cache it.
144146
* @param {string} value Color value to resolve.
145147
* @param {Element} element Element to get computed style from to resolve the color value.
148+
* @returns {Color | null} Resolved color value or null if the value cannot be resolved.
146149
*/
147150
static resolveColor (value, element) {
148151
try {
@@ -165,7 +168,7 @@ const Self = class ColorElement extends NudeElement {
165168
Self.resolvedColors.set(value, color);
166169
element.style.backgroundColor = "";
167170

168-
return color;
171+
return Self.Color.get(color);
169172
}
170173
}
171174
};

0 commit comments

Comments
 (0)