Re: [css-variables] using variables in shorthands

On Fri, Mar 9, 2012 at 7:35 AM, Florian Rivoal <florianr@opera.com> wrote:
> Am I missing something? Does anyone have a better solution? I am left with
> the impression that the variables proposal has a fundamental
> incompatibility with shorthands.

You're not missing anything here - this is indeed problematic.  I can
come up with only three ways to resolve it:

1. Drop this property-like thing we have going, or at least drop
inheritance.  Revert to SASS-like variables, possibly returning to the
@var syntax from my earlier blog posts.  This avoids the whole issue.

2. Since var properties can only refer to other var properties, define
a separate inheritance step for them.  They "compute" separately from
(and before) other properties do, so that by the time you look at a
normal property's specified value to see how to expand it, the
variable is already fully resolveable.

3. Somehow hack the way we expose computed values to hide the problems
here.  I have no idea how this would work, because of the fact that
longhands turn into shorthands over time.


I'm against #1 if we can avoid it.  I like multiple aspects of the
current solution, and think there's a lot of opportunity for cool
extensions in the future.  A lot would be lost if we went back to the
"all vars are global" version.

#2 seems a little hacky, but there's nothing *theoretically* wrong
with it.  I have no clue how hard it might be to implement, though.  I
prefer this option if it's possible, though.  (This does constrain our
options in the future somewhat.  We can't, for example, use the
inherited value of an arbitrary normal property as a variable - there
wouldn't be any circularity concerns, but it would require us to wait
for the "real" inheritance to happen first, and would thus break our
invariant unless we get hacky.  I don't think this is a huge deal,
though.)

I have no clue what #3 might entail, so I can't really evaluate it.
If anyone has any good ideas, I'll listen.

Thoughts?

~TJ

Received on Tuesday, 13 March 2012 18:05:53 UTC