1

In complex or underway stylesheets, there may occur scenarios when no conditionals and no global :root declarations apply, so there is no value-assigning definition for a custom property, which however is being used in some applying selector.

Naturally, this could be mitigated by using default or fallback values. But how to find stray/orphaned unset/undefined variables?

By scrolling-by, the rule inspectors may display a missing declaration:

Firefox above, Chrome below

However, neither Chrome nor Firefox issue a warning if a CSS variable is being used, but not set/defined.

There is no point in checking the documentElement’s (custom) properties, because then they’d be already defined.

Do I need to iterate through each and every element style and check its (custom) properties for a defined value? (Maybe that won’t work either, because computed values will fall back to browser defaults.)

dakab
  • 5,379
  • 9
  • 43
  • 67

0 Answers0