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

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?

One possible solution for the problem is to specify that variables must:
a) always be declared before being used and
b) do not change their type in run-time.

So this may work in principle:

@variables {
   var1: 1px;
   var2: #ff0;
   var3: solid;
}
div {
  border: var(var1) var(var2) var(var3);
}

In this case parser can properly assign variables among border-width,
border-color, border-style.

But even in this case we have problem with 'solid' value.
CSS knows about length and color types but it has no notion of
different enumeration types.
Name tokens like 'none' may belong to different "enumeration value sets".

It seems that we will need to add some additional parsing feature for variables:
c) "type functions":

@variables {
   var1: 1px;
   var2: #ff0;
   var3: border-style(solid);
}
var3 here is declared with additional type declaration, it could be
name of property
that expect given name token.

Did we discuss this problem already? If "yes" - terribly sorry and
I'll appreciate
if someone will provide link to the discussion.

-- 
Andrew Fedoniouk.

http://terrainformatica.com

Received on Saturday, 23 February 2013 19:33:02 UTC