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

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.

This also adds a burden to the implementors as well. For example, I
have a C++ representation of the Counter Style data with the default
values set to the initial values. In order to provide null or empty
string on unset properties, I would need to track which properties
have been set, adding an extra code path. For the initial value, I can
just serialize the C++ value to a string using the same codepath as
the one for when the value is explicitly set.

Thanks,
- Reece H. Dunn (Cainteoir Technologies)

Received on Wednesday, 12 February 2014 10:02:00 UTC