framework7io/framework7 · error · Error

`secondaryDim` color is undefined prior to 2025 spec.

Error message

`secondaryDim` color is undefined prior to 2025 spec.

What it means

Same pattern as primaryDim: the secondaryDim getter is only populated under the 2025 spec. On schemes built for earlier specs, colors.secondaryDim() returns undefined and the getter throws to prevent silently using a missing color.

Source

Thrown at src/core/shared/material-color-utils.js:2297

  }
  get primaryFixedDim() {
    return this.getArgb(this.colors.primaryFixedDim());
  }
  get onPrimaryFixed() {
    return this.getArgb(this.colors.onPrimaryFixed());
  }
  get onPrimaryFixedVariant() {
    return this.getArgb(this.colors.onPrimaryFixedVariant());
  }
  get inversePrimary() {
    return this.getArgb(this.colors.inversePrimary());
  }
  get secondary() {
    return this.getArgb(this.colors.secondary());
  }
  get secondaryDim() {
    const secondaryDim = this.colors.secondaryDim();
    if (void 0 === secondaryDim) throw new Error("`secondaryDim` color is undefined prior to 2025 spec.");
    return this.getArgb(secondaryDim);
  }
  get onSecondary() {
    return this.getArgb(this.colors.onSecondary());
  }
  get secondaryContainer() {
    return this.getArgb(this.colors.secondaryContainer());
  }
  get onSecondaryContainer() {
    return this.getArgb(this.colors.onSecondaryContainer());
  }
  get secondaryFixed() {
    return this.getArgb(this.colors.secondaryFixed());
  }
  get secondaryFixedDim() {
    return this.getArgb(this.colors.secondaryFixedDim());
  }
  get onSecondaryFixed() {

View on GitHub (pinned to 6557591266)

Solutions

  1. Construct the scheme with the 2025 spec version.
  2. Check scheme.specVersion before accessing and fall back to secondary (or compute a dim variant) for older specs.
  3. Remove the secondaryDim usage if targeting legacy specs.

Example fix

// before
const c = legacyScheme.secondaryDim; // throws
// after
const c = scheme.specVersion === SpecVersion.SPEC_2025 ? scheme.secondaryDim : scheme.secondary;
Defensive patterns

Strategy: type-guard

Validate before calling

function supportsDimRole(scheme, role) {
  return String(scheme.specVersion).includes('2025');
}
const c = supportsDimRole(scheme, 'secondaryDim') ? scheme.secondaryDim : scheme.secondary;

Type guard

function supports2025Roles(scheme) {
  return scheme && scheme.specVersion === '2025';
}

Try / catch

try {
  argb = scheme.secondaryDim;
} catch (err) {
  if (err.message.includes('`secondaryDim` color is undefined')) {
    argb = scheme.secondary;
  } else throw err;
}

Prevention

When it happens

Trigger: Reading scheme.secondaryDim when the DynamicScheme's specVersion is not 2025, making colors.secondaryDim() undefined.

Common situations: Legacy schemes (specVersion 2021) used with code expecting the expanded 2025 role set; copy-pasted color extraction code referencing newer roles than the scheme supports.

Related errors


AI-assisted analysis of framework7io/framework7@6557591266 (2026-09-02). Data as JSON: /api/errors/c375d65ebdccc69f. Report an issue: GitHub.