- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Sat, 23 Feb 2013 16:13:44 -0800
- 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. ~TJ
Received on Sunday, 24 February 2013 00:14:35 UTC