W3C home > Mailing lists > Public > www-style@w3.org > May 2012

Re: [css-variables] Maintain link between var declaration and use

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Mon, 21 May 2012 07:46:49 -0700
Message-ID: <CAAWBYDBAQRf4EMCPApBSMJz4m5Hz1zRv_U7tWpAX_B4m7x4wWA@mail.gmail.com>
To: Chris Eppstein <chris@eppsteins.net>
Cc: Christoph Päper <christoph.paeper@crissov.de>, www-style list <www-style@w3.org>
On Mon, May 21, 2012 at 5:43 AM, Chris Eppstein <chris@eppsteins.net> wrote:
>> That gains us nothing, though.  I see no good reason to switch away
>> from dashes unless we're going full-on to something that looks like a
>> function.
> Just use $ as a sigil. Function notation is such a bad idea. We don't need the ability to prefix variables, we don't need the extra keystrokes, we don't need the faux parser compatibility.
> Follow Sass's lead on this, we got it right.

We *do* need the ability to specify a default value for when the
variable you're referencing isn't defined, though.  Unfortunately,
after some research I've decided that the !default idea (opposite of
!important, puts it at a new, lower, specificity level) doesn't work
very well.

In one of the major use-cases for default values (accumulating a value
in a variable repeatedly, or cycling through variables) having a
default argument gives smaller, easier-to-understand code.  Without
it, you have to write two selectors, and make sure the second only
selects descendants of the first, so you can first provide a value and
then start interacting with it.

In the other major use-case for default values (using variables as a
hook for styling Web Components, allowing author-declared vars to
inherit into the shadow tree), !default unfortunately doesn't work at
all, because *any* specified value, no matter the specificity, wins
over inherited values.  The default argument, on the other hand, only
has effect when inheritance doesn't produce anything.

Both of those cases, and several more, also want the ability to refer
to the inherited value of a variable, rather than the current value.
This requires some sort of extra syntax - right now I'm leaning toward
another function.  You can't overload the $ to do anything new.

I think SASS made the right choice for the specific type of variable
it uses - global vars with no structure beyond the dependency graph
you set up yourself just don't have much complexity, so using a simple
non-extensible syntax for it is okay.  But I think it's *too* simple
for what CSS variables needs.

Received on Monday, 21 May 2012 14:48:02 UTC

This archive was generated by hypermail 2.4.0 : Monday, 23 January 2023 02:14:15 UTC