Re: [css-counter-styles] question about API

On Wed, Feb 12, 2014 at 9:01 PM, Reece Dunn <msclrhd@googlemail.com> wrote:
> On 11 February 2014 19:26, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
>> On Fri, Feb 7, 2014 at 3:45 PM, Xidorn Quan <quanxunzhen@gmail.com> wrote:
>>> I have a question that, if one descriptor is not specificed in rule
>>> declaration, should the corresponding attribute return the initial
>>> value defined for the descriptor or an empty string?
>>
>> Hmm, I'm actually not sure what the best behavior is.  The closest
>> similar rule, @font-face, doesn't define it at all either:
>> <http://dev.w3.org/csswg/css-fonts/#om-fontface>
>>
>> I can go with either null, empty string, or initial value.  I'll let
>> the group decide which makes the most sense.
>
> I would expect it to be the initial value. That is:
>
>     @counter-style default1 {};
>     @counter-style default2 { system: symbolic; };
>
> specify the same counter style settings. That is, both have
> system=symbolic -- default1 picks it up via the initial value and
> default2 has it explicitly specified.
>
> If CSSCounterStyleRule returned null or empty string if the value is
> unset (same applies for any CSS property), then someone writing
> JavaScript code will need to:
>
> 1.  check for the null and/or empty string;
> 2.  know the initial value for the property.
>
> Thus, instead of:
>
>     if (counter.system == "symbolic") { ... }
>
> They would need to write:
>
>     if (counter.system == "" || counter.system == "symbolic") { ... }
>
> This would then lead to more complex code by the JavaScript developers
> and will probably end up with a JQuery-like API to access this (so it
> handles the logic). Especially for the range property which is
> dependent on the system property.
>
> If developers are not careful, they will end up with buggy client code.

It is a very reasonable point. I agree with you that it is easier for
developers to use this API if it returns initial value for unspecified
descriptors. I thought there should be a way to distinguish whether a
descriptor is explicitly declared, which seems to have no sense.

(Oh, I changed my stand the second time...)

Regards,
Xidorn Quan

Received on Friday, 14 February 2014 11:04:00 UTC