You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
VariableContextProvider treats "unset", "inherit" and "initial" differently from CSS #573
I checked for possible duplicate issues, with possible answers.
Bug summary
A CSS-wide keyword passed as a runtime variable value does not take its CSS meaning. Custom properties inherit, so unset and inherit take the parent's value, and initial is the guaranteed-invalid value, which makes a var() use its fallback (css-variables-1 §2, css-cascade-5 §7.3).
With an outer VariableContextProvider setting --my-var: red and an inner one setting the keyword, .test { color: var(--my-var, green) } renders:
Inner value
main
Browsers
"unset"
no color
red
"inherit"
color: "inherit"
red
"initial"
color: "initial"
green
"unset" clears because resolveValue turns the string "unset" into null for every value, which is how background-color: unset resets a style (#90). A variable holding "unset" goes through the same path, so the property that reads it is cleared. #431 kept that as the way to clear a variable from the runtime, and its test asserts it.
A possible fix, for VariableContextProvider and vars():
"initial" stores the guaranteed-invalid value, so a var() reading it uses its fallback, and with no fallback the property is cleared.
background-color: unset and the #431 behaviour for undefined stay as they are, and clearing stays available through "initial", which gives the result #431's "clears a variable with unset" test expects. The one change is that a runtime "unset" inherits, as in browsers, so that test would use "initial".
Does this match the intended semantics? If so, I'm happy to open a pull request. #503 covers the same keywords in compiled CSS (.child { --my-var: unset }), so the runtime side could reuse its representation of the guaranteed-invalid value.
Activity