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

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

From: Andrew Fedoniouk <news@terrainformatica.com>
Date: Sat, 23 Feb 2013 11:32:34 -0800
Message-ID: <CALRQH7_XegVZps=-w2=yU16id=HXw0h6HwGF8n=sXbe9eC88rA@mail.gmail.com>
To: "www-style@w3.org" <www-style@w3.org>
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 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:21:06 GMT