Re: [css-variables] Empty variable values?

On Sat, Feb 9, 2013 at 10:25 AM, François REMY
<francois.remy.dev@outlook.com> wrote:
>> Why is it difficult? The standard way to delete a property in JS
>> still works ("style.removeProperty('var-foo')"), and I've added a
>> second way using the convenience API ("delete style.var.foo").
>
> What if you want to undeclare a custom property from CSS to make sure the children make use of their fallback instead of inheriting the parent value? This is also a very valuable use case in my mind, maybe more important than the previous one.

I assume you mean that you have a second variable referencing the
first, and the second has a fallback value that you'd like to invoke
when you undeclare the first?

That happens automatically.  Variables without a corresponding valid
custom property are invalid when used.

If you want to have a variable be explicitly invalid but still in the
OM for some reason, you can explicitly invalidate it with a
self-reference ("style.var.foo = 'var(foo)';").  This is a horrible
use-case, though - the only difference between it and unsetting the
property is that if the property is also set on an ancestor, but you
don't want that value and want to instead use fallbacks.  I can't see
any reason to ever do that on purpose.

~TJ

Received on Saturday, 9 February 2013 17:31:54 UTC