W3C home > Mailing lists > Public > www-style@w3.org > February 2013

Re: [css-variables] and shortcut properties, fundamental limitation?

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Sat, 23 Feb 2013 16:13:44 -0800
Message-ID: <CAAWBYDAX7wnT3KmwwAKTKSMu-m_yfmru1xCm6_C2HYU3Qi2xFg@mail.gmail.com>
To: Andrew Fedoniouk <news@terrainformatica.com>
Cc: "www-style@w3.org" <www-style@w3.org>
On Sat, Feb 23, 2013 at 11:32 AM, Andrew Fedoniouk
<news@terrainformatica.com> wrote:
> Let's imagine that we have this rule:
> div {
>   border: var(var1) var(var2) var(var3);
> }
> Here we use variables that are not yet defined.
> As at this point CSS parser has no knowledge about types of each variable then
> it cannot decide which "terminal" property will receive which variable.
> So it appears as variables cannot be used in shortcut properties at all?

You are correct that the parser has no knowledge about what the
variables are, and thus cannot expand the shorthand yet.  This means
that a shorthand using variables must be treated somewhat differently
than a normal shorthand.

Ordinarily, shorthands are expanded into their longhands at
cascaded-value time.  That way, you can forget that there was a
shorthand at all almost immediately.

When you add variables, you have to treat this slightly differently.
Expand the shorthand into its longhands, but just fill in every
longhand value with a special "placeholder" value.  Then you run the
cascade normally.  When it finishes, if any placeholders are still
around, go ahead and process the shorthand (which is possible to do
now, because all the variables are available).  Based on this
expansion, replace the placeholder with the appropriate value.

I see that this doesn't seem to have made it into the draft, or got
dropped at some point.  I'll edit it in.

Received on Sunday, 24 February 2013 00:14:35 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:09 UTC