W3C home > Mailing lists > Public > www-style@w3.org > August 2008

Re: [CSS Variables] WebKit now supports variable declaration blocks

From: L. David Baron <dbaron@dbaron.org>
Date: Fri, 22 Aug 2008 16:21:40 +0100
To: David Hyatt <hyatt@apple.com>
Cc: "www-style@w3.org List" <www-style@w3.org>
Message-ID: <20080822152140.GA4860@pickering.dbaron.org>

On Monday 2008-07-28 17:56 -0500, David Hyatt wrote:
> In the next WebKit nightly you will be able to try out CSS variables  
> whose values are declarations.  Here is what the syntax looks like:
> @-webkit-variables {
>    simpleVariable: 5px;
>    complexVariable {
>        width: 5em;
>        height: 5em;
>    }
> }
> div {
>     background-color: green;
>     -webkit-var(complexVariable);
>     color: white;
> }

So are these variables intended to be mutable later via script, or
intended to be constants?  (If the latter, should they really be
called variables?)

If they're supposed to be variables, it seems like it's impossible
to get the following combination to work correctly:
 * cascading order
 * CSS object model, which only allows storing one value per
   property per declaration block
 * dynamic changes to complex variables.

In particular, if the complex variable can be changed later, I'm not
sure how to reflect in the CSS object model that there's a
declaration block a declaration like:

@define {
  complexVariable {
    color: blue;

p { var(complexVariable); color: green; }
q { color: purple; var(complexVariable); }

such that p elements are green, q elements are blue, but if we
dynamically change complexVariable to no longer declare the color
property, q elements would change to purple.  (And consider
especially dynamic mutation of sheet.cssRules[i].style.color on the
p and q rules, which is already permitted.)

Are these complex variables intended to be mutable, or are they
really constants?

> As I stated in a previous post, WebKit also currently supports the  
> double equals syntax and the dollar sign syntax for referencing  
> variables, so =complexVariable= and $complexVariable also work.

This seems a bit dangerous in case this syntax is not chosen for
variables, but is then used in CSS for something else later on.


L. David Baron                                 http://dbaron.org/
Mozilla Corporation                       http://www.mozilla.com/
Received on Friday, 22 August 2008 15:22:16 UTC

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