Re: [css3-values] nesting calc()

On Wed, Jun 20, 2012 at 12:45 AM, François REMY
<fremycompany_pub@yahoo.fr> wrote:
> I'm not an expert in CSS syntax but it seems to be a dangerous idea. Is
> there a way in CSS to distinguish a function from an identifier followed by
> parenthized expression? Example:
>
>   animation: attr(anim);
>
> and:
>
>   animation: myAnim (15s - 3s);

Yes, the first value tokenizes as FUNCTION IDENT RIGHT-PAREN, while
the second tokenizes as IDENT LEFT-PAREN DIMENSION DELIM DIMENSION
RIGHT-PAREN.

In other words, the function name and opening parenthesis must be
immediately next to each other. No whitespace (or comment, for that
matter) is allowed between them.

The only exception is when parsing the @transform attribute on an SVG
element (for legacy reasons), but that's not ambiguous, and it's a
very limited context.  It doesn't even apply to the 'transform'
property on SVG elements, just the attribute itself.

So, there's no chance of ambiguity or future-hostility here.
"foo(10px - 10%)" will *always* parse as a "foo()" function, and "foo
(10px - 10%)" will *always* parse as a "foo" identifier followed by a
paren-group.  So, it would be safe from a syntax perspective to make
paren-groups imply calc.

However, I don't want to do that.  We already use parens as the more
general "grouping" construct elsewhere in CSS (media queries), and I
think it would be weird to have paren-groups imply calc in some places
and not others.  I'd just like #1, to allow calc() inside of calc(),
with the same meaning parens inside of calc().

~TJ

Received on Monday, 25 June 2012 21:39:47 UTC