Re: [css-variables] Empty variable values?

On Wed, Feb 6, 2013 at 12:45 PM, Simon Sapin <simon.sapin@kozea.fr> wrote:

> Le 06/02/2013 12:24, Tab Atkins Jr. a écrit :
>
>>
>> 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.
>>
>
> Can’t we handle that with null (not set) vs. empty string?


The relevant semantics are at [1]

getPropertyCSSValue


> Returns the value of the property if it has been explicitly set for this
> declaration block. Returns null if the property has not been set.
>

and [2]

getPropertyValue


> Returns the value of the property if it has been explicitly set for this
> declaration block. Returns the empty string if the property has not been
> set.
>

Notice the former returns null and the latter returns the empty string "if
the property has not been explicitly set". Here, "explicitly set" is
referring to the CSSStyleDeclaration returned from
ElementCSSInlineStyle.style, and means "explicitly set in a source style
rule or explicitly set by mutating ElementCSSInlineStyle.style.cssText, etc.

So, with the suggested syntax, one can no longer distinguish between
explicitly set or set to /*empty*/.

[1]
http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration-getPropertyCSSValue
[2]
http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration-getPropertyValue

Received on Wednesday, 6 February 2013 20:08:55 UTC