Re: [css-variables] Empty variable values?

On 2/9/13, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> On Fri, Feb 8, 2013 at 3:16 AM, François REMY
> <francois.remy.dev@outlook.com> wrote:
>> ± I believe Glenn brought up a related issue, which is that it would be
>> difficult
>> ± to tell in the OM between a property set to nothing and one not set at
>> all.
>> ± This can be avoided by using the new "var" property on
>> CSSStyleDeclaration,
>> ± as only valid variables show up there.  (You can use " 'foo' in
>> style.var " to test
>> ± it.)  This is the intended method to interact with variables anyway, as
>> it's
>> ± more convenient, so we can probably ignore this issue.
>>
>> I'm in favor of a semantic where setting a property to an empty value
>> undeclares the property, mimicking the element.style behavior which
>> exposes an empty string for undeclared properties (and where setting a
>> property to an empty string remove the property declaration).
>
> That does not address the use-case I presented for the proposal, which
> is to allow variables to substitute nothing for themselves, which is
> required for some semantics where the lack of a value is different
> from any value you can provide.  (It's also convenient for some other
> cases, like lists of values.)
>
>> If we do not go that way, it becomes very difficult to undeclare a custom
>> property. Do we really want people to rely on [[Delete]] semantics to
>> undeclare a property?
>
> 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").

That should be removed. There is no benefit to that and it will
undoubtedly cause compat issues with browsers people are using, either
in the form of errors are false positives.

Process-wise, I think it would have been better to have asked about
that on list first.

The most common way to unset existing property values on a CSSRule, in
JS is to set them to have the empty string. What kind of situation do
you want to unset a variable in CSS? And in that situation, why can't
you set it to the empty string?
-- 
Garrett
Twitter: @xkit
personx.tumblr.com

Received on Saturday, 9 February 2013 17:52:53 UTC