RE: [css-variables] Empty variable values?

± 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). 

So, my proposal would be to accept the empty string value as a way to reset the custom property to a unset state:

    #selector {
        my-property: 1;
    }

    #selector > * {
         my-property:; /* unset the property */
    }

    qS("#selector > *").computedStyle.myProperty // empty string
    qS("#selector > *").computedStyle.my.property // undefined

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?

Received on Friday, 8 February 2013 10:16:57 UTC