Re: [cssom][css3-values] Serialization of initial from shorthand

On Mon, Jun 24, 2013 at 2:58 PM, L. David Baron <> wrote:

> On Monday 2013-06-24 21:31 +0200, Rune Lillesveen wrote:
> > On 06/24/2013 04:14 PM, Glenn Adams wrote:
> > >In the first case, I would expect "center" returned, and in the
> > >second, I would expect "initial" returned: because these are
> > >specified values.
> >
> > In the first case, the background shorthand will reset
> > background-position to its initial value, I just added the "center"
> > declaration to illustrate that. So I think that needs to be either
> > "initial" or "0% 0%". For the second case, I agree that it should be
> > "initial". What I'm less sure about is the text from
> > css-backgrounds:
> >
> > "Given a valid declaration, for each layer the shorthand first sets
> > the corresponding layer of each of 'background-image',..., and
> > 'background-attachment'to that property's initial value, ..."
> >
> > Does it say "to that property's initial value" instead of "to
> > 'initial'" because it's not aware of the 'initial' value from
> > css-values?
> I think it should actually *not* be the 'initial' value, given that
> in general the 'initial' value can't be serialized as part of a
> shorthand.  I'd rather stick to the model that:
>  * if there's any 'inherit'/'initial' involved, serialization of a
>    shorthand will fail unless all the subproperties are that same
>    'inherit' or 'initial'
>  * otherwise, the shorthand will attempt to serialize using
>    appropriate rules, and omitting values that can be omitted.

It might be useful to review what DOM-2 Style [1] says in this area
(emphases added):


When dealing with CSS "shorthand" properties, the shorthand properties
should be decomposed into their component longhand properties as
appropriate, and when querying for their value, the form returned should be
the shortest form exactly equivalent to the declarations made in the
ruleset. However, if there is no shorthand declaration that could be added
to the ruleset without changing in any way the rules already declared in
the ruleset (i.e., by adding longhand rules that were previously not
declared in the ruleset), then the empty string should be returned for the
shorthand property.

For example, querying for the font property should not return "normal
normal normal 14pt/normal Arial, sans-serif", when "14pt Arial, sans-serif"
suffices. (The normals are initial values, and are implied by use of the
longhand property.)

If the values for all the longhand properties that compose a particular
string are the initial values, then a string consisting of all the initial
values should be returned (e.g. a border-widthvalue of "medium" should be
returned as such, not as "").

For some shorthand properties that take missing values from other sides,
such as the margin, padding, and border-[width|style|color] properties, the
minimum number of sides possible should be used; i.e., "0px 10px" will be
returned instead of "0px 10px 0px 10px".

If the value of a shorthand property can not be decomposed into its
component longhand properties, as is the case for the font property with a
value of "menu", querying for the values of the component longhand
properties should return the empty string.

> (This is even worse for background layers, since it doesn't make
> sense to make 'initial' be the value for a single layer when there
> are multiple layers, since that layer then *still* couldn't be
> serialized into valid CSS syntax if a different layer had a
> different value.)
> -David
> --
> 𝄞   L. David Baron                  𝄂
> 𝄢   Mozilla                    𝄂

Received on Tuesday, 25 June 2013 03:03:56 UTC