framework7io/framework7 · error · Error
`errorDim` color is undefined prior to 2025 spec.
Error message
`errorDim` color is undefined prior to 2025 spec.
What it means
DynamicScheme exposes an `errorDim` ARGB getter, but the underlying palette delegate only defines an errorDim color for the 2025 Material color spec. In the 2021 spec `this.colors.errorDim()` returns undefined, so the getter explicitly throws this error rather than silently returning NaN. It is a guard against accessing a 2025-only color token on a pre-2025 scheme.
Source
Thrown at src/core/shared/material-color-utils.js:2355
}
get tertiaryFixed() {
return this.getArgb(this.colors.tertiaryFixed());
}
get tertiaryFixedDim() {
return this.getArgb(this.colors.tertiaryFixedDim());
}
get onTertiaryFixed() {
return this.getArgb(this.colors.onTertiaryFixed());
}
get onTertiaryFixedVariant() {
return this.getArgb(this.colors.onTertiaryFixedVariant());
}
get error() {
return this.getArgb(this.colors.error());
}
get errorDim() {
const errorDim = this.colors.errorDim();
if (void 0 === errorDim) throw new Error("`errorDim` color is undefined prior to 2025 spec.");
return this.getArgb(errorDim);
}
get onError() {
return this.getArgb(this.colors.onError());
}
get errorContainer() {
return this.getArgb(this.colors.errorContainer());
}
get onErrorContainer() {
return this.getArgb(this.colors.onErrorContainer());
}
}
DynamicScheme.DEFAULT_SPEC_VERSION = "2021", DynamicScheme.DEFAULT_PLATFORM = "phone";
class DynamicSchemePalettesDelegateImpl2021 {
getPrimaryPalette(variant, sourceColorHct, isDark, platform, contrastLevel) {
switch (variant) {View on GitHub (pinned to 6557591266)
Solutions
- Switch the scheme to the 2025 spec (construct DynamicScheme/dynamic color with the 2025 spec version / 2025 variant) so errorDim is defined.
- If you must stay on the 2021 spec, stop reading scheme.errorDim; fall back to a computed darkened error color instead.
- Feature-check before access: only read errorDim when the scheme's spec/version supports it.
Example fix
// before const dim = scheme.errorDim; // throws on 2021 spec // after const dim = scheme.errorDim !== undefined ? scheme.errorDim : scheme.error; // or use a 2025-spec scheme
Defensive patterns
Strategy: validation
Validate before calling
function supportsErrorDim(scheme) {
return typeof scheme?.colors?.errorDim === 'function' && scheme.colors.errorDim() !== undefined;
}
// usage: const dim = supportsErrorDim(scheme) ? scheme.errorDim : scheme.error; Type guard
function hasErrorDim(scheme) {
return !!scheme && typeof scheme.colors === 'object' && scheme.colors.errorDim() !== undefined;
} Try / catch
let dim;
try {
dim = scheme.errorDim;
} catch (e) {
if (e.message.includes('errorDim')) dim = scheme.error; // 2021-spec fallback
else throw e;
} Prevention
- Only read errorDim when the scheme is built with the 2025 spec.
- Never iterate all scheme getters generically across spec versions.
- Centralize color-token access in a helper that feature-checks per spec version.
- Pin the spec version in one place and derive token availability from it.
When it happens
Trigger: Reading `scheme.errorDim` (or any code path that reads it, e.g. serializing all scheme colors) when the scheme was created with spec version 2021 or with a Variant/delegate that does not define errorDim — `this.colors.errorDim()` returns undefined.
Common situations: Apps upgraded Material theme libraries and iterate every token generically; code copied from 2025-spec examples run against 2021 schemes; schemes built with `specVersion: '2021'` (or default 2021) while UI code expects 2025 tokens.
Related errors
- Attempting to extend color ${originalColor.name} with color
- Attempting to extend color ${originalColor.name} as a ${orig
- `primaryDim` color is undefined prior to 2025 spec.
- `secondaryDim` color is undefined prior to 2025 spec.
- `tertiaryDim` color is undefined prior to 2025 spec.
AI-assisted analysis of framework7io/framework7@6557591266 (2026-09-02).
Data as JSON: /api/errors/b29a4b6a19bfb16b.
Report an issue: GitHub.