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

Re: [css-variables] Empty variable values?

From: Garrett Smith <dhtmlkitchen@gmail.com>
Date: Sat, 9 Feb 2013 09:52:26 -0800
Message-ID: <CABZUbM0vXbUmNwO-kPWbsgkHiE5LSxkbYUxUJjOMRAAmkn61dw@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: François REMY <francois.remy.dev@outlook.com>, www-style list <www-style@w3.org>
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?
Twitter: @xkit
Received on Saturday, 9 February 2013 17:52:53 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:26 UTC