public final class CSSVariableSubstitution extends Object
var() references in a value string with resolved custom
property values, following the
CSS Variables
substitution algorithm textually. It is paren- and quote-aware (so nested
var() and parens/commas inside strings work, which a regex cannot do);
a CSSVariableSubstitution.VarResolver supplies replacements and fallbacks are substituted
recursively.
The CSSVariableSubstitution.Result reports whether substitution fully succeeded. If a
reference is undefined with no fallback, the value is "invalid at
computed-value time" and the caller should treat the property as unset.
| Modifier and Type | Class and Description |
|---|---|
static class |
CSSVariableSubstitution.Result |
static interface |
CSSVariableSubstitution.VarResolver
Resolves a custom property name (including the leading
--) to its
already fully-substituted value, or null if undefined or invalid
(e.g. |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
containsVar(String valueText)
Returns true if the value text contains a
var( token. |
static CSSVariableSubstitution.Result |
substitute(String valueText,
CSSVariableSubstitution.VarResolver resolver) |
public static boolean containsVar(String valueText)
var( token. Cheap
pre-check to avoid running the full substitution on var-free values.public static CSSVariableSubstitution.Result substitute(String valueText, CSSVariableSubstitution.VarResolver resolver)
Copyright © 2004–2026. All rights reserved.