Re: [css-variables] cyclic dependencies involving fallback

On Sun, Dec 15, 2013 at 2:49 PM, Cameron McCormack <cam@mcc.id.au> wrote:
> The spec currently says:
>
>   Custom properties may use variables in their own values to build up
>   composite variables. This can create cyclic dependencies where two or
>   more custom properties each attempt to use the variable that the
>   other defines; doing so makes all the custom properties involved in
>   the cycle compute to their initial value (which is a guaranteed-
>   invalid value).
>
> It's not clear exactly what "attempt to use" means here.
>
>   p {
>     var-a: var(b, var(a));
>     var-b: 1;
>   }
>
> Would this result in var-a being invalid since its value includes a
> reference to itself?  Or should it be valid because we don't need to
> evaluate the var(a) fallback?
>
> I interpreted the spec to mean that any occurrences of a variable reference
> on the right hand side would count when looking for cycles, and thus var-a
> would be invalid, but a bug reporter thought otherwise
> https://bugzilla.mozilla.org/show_bug.cgi?id=950501.

The paragraph in question was written before I added defaults, so I
accidentally skipped dealing with this. :/

I can go either way.  Can you describe what makes either difficult?

Note the similar-looking but actually quite distinct case of:

p {
  var-a: var(b, 1);
  var-b: var(a, 2);
}

Similarly, I can go either way with this.  Having them just be invalid
seems okay, but so does having them resolve to a:1 and b:2.  I think
those are the only two answers - we can't choose an arbitrary one to
declare invalid and then resolve all the fallbacks from that point,
because there's no distinguished "first" one.  They've either gotta
all be invalid, or all be invalid-but-triggering-fallback, and I think
I prefer just plain invalid here, since the latter involves two-pass
resolution.  (Maybe n-pass? Not putting enough thought into it right
now.)

~TJ

Received on Monday, 16 December 2013 18:17:34 UTC