(name)
| 6 | static _cache = new Map(); |
| 7 | |
| 8 | static get(name) { |
| 9 | let color = this._cache.get(name); |
| 10 | if (color !== undefined) return color; |
| 11 | const style = getComputedStyle(document.body); |
| 12 | color = style.getPropertyValue(`--${name}`); |
| 13 | if (color === undefined) { |
| 14 | throw new Error(`CSS color does not exist: ${name}`); |
| 15 | } |
| 16 | color = color.trim(); |
| 17 | this._cache.set(name, color); |
| 18 | return color; |
| 19 | } |
| 20 | |
| 21 | static reset() { |
| 22 | this._cache.clear(); |
no test coverage detected