W3C home > Mailing lists > Public > www-style@w3.org > February 2013

Re: [css-variables] Empty variable values?

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Sat, 9 Feb 2013 10:31:07 -0700
Message-ID: <CAAWBYDDo1_wcADsOqb2Ap4TjoWsKv_1it8N6oBGjePim2Qobhg@mail.gmail.com>
To: Fran├žois REMY <francois.remy.dev@outlook.com>
Cc: www-style list <www-style@w3.org>
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 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:21:05 GMT