W3C home > Mailing lists > Public > www-style@w3.org > October 2011

Re: Better Variables through Custom Properties

From: Roland Steiner <rolandsteiner@google.com>
Date: Tue, 25 Oct 2011 14:03:52 -0700
Message-ID: <CACFPSphdsoOMNuDMOgKBcN15HjhFFxebam1AAbyF=8KGQM_GrQ@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: Boris Zbarsky <bzbarsky@mit.edu>, www-style@w3.org
As a preface, let me stress that I'm happy if we get this kind of variables
regardless of the details, so I don't want to derail the thread by
bikeshedding (below I just address some parts where I feel there are
misunderstandings - feel free to skip them).

TL;DR: If we have to choose between current and inherited value accessors,
my vote would be for 'inherited', because it's IMHO simpler as well as more
powerful. Conversely, accessing the current value adds a whole level
of complications, implementation-wise.

On Tue, Oct 25, 2011 at 12:45, Tab Atkins Jr. <jackalmage@gmail.com> wrote:

> 1. You can only do that if you only have a single layer of dependency.
>  Multiple layers require you to add wrappers to your HTML, which is
> horribad.  (Adding wrappers for layout purposes is one thing.  Adding
> wrappers *so you can derive variables* is beyond the pale.)
>

I'm certainly not advocating adding wrappers. One might need to introduce
additional variables, but wrappers shouldn't be needed in either approach.


> > OTOH, with the current value you also have this question:
> > .x {
> >   data-foo: red;
> >   data-bar: data(foo);
> >   color: data(bar);
> > }
> > #y {
> >   data-foo: green;
> > }
> > <div class=x id=y> Red or Green? </div>
> > I'd argue it should be green, but that means local "helper variables" are
> > not all that reliable.
>
> This is *exactly* what you want - being able to use the cascade is a
> decent part of the appeal of this approach.  Note that with your
> approach it's impossible to do something similar unless there's a
> wrapper you can target instead.


I'd contend you *don't need* this. But what I wanted to get at with this
example is an implementation issue: you couldn't just apply and overwrite
properties in ascending cascade order - this would leave the text red in
above example.


- Roland
Received on Tuesday, 25 October 2011 21:04:45 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:45 GMT