Re: [mediaqueries] calc() and other syntax restrictions (was: Re: Validating media queries in Java)

Le 02/05/2013 21:46, fantasai a écrit :
>> Gunther: Don't worry, whatever conclusions that that old thread may
>> have come to, calc() is definitely allowed in Media Queries, at least
>> per spec.  (calc() is allowed*everywhere*, because it's just a
>> fill-in for its resolved type.)
> I am not so sure about that, and if that's our intent I think it could
> definitely use some clarification.

I agree with Tab. Whether or not this was originally intended, calc() is 
allowed in Media Queries per spec.

css3-mediaqueries:

> Whitespace, <integer>, <number> and other values used by this
> specification are the same as in other parts of CSS, normatively
> defined by CSS 2.1. [CSS21]

css3-values:

> The ‘calc()’ expression […] can be used wherever <length>,
> <frequency>, <angle>, <time>, <number>, or <integer> values are
> allowed.

For comparison, attr() is not allowed in MQs. css3-values:

> The attr() function is allowed as a component value in properties
> applied to an element or pseudo-element.


That said, I’m always in favor of clarification in specs. And calc() is 
indeed not very useful in MQs, since eg. the em unit is based on the 
initial font-size and not one from a stylesheet.


Oh, and while we’re on conclusions of that old thread, I think that 
micro-syntaxes like MQs and Selectors should definitely use an actual 
CSS parser, up to what Syntax 3 calls "component values". This takes 
care of escaping, block/paren nesting and error recovery rules.

And allowing multiple escaping styles is fine as long as they’re 
properly layered: the HTML parser resolves HTML escapes/entities, and 
the parsed attribute value (as in the DOM) is given to the CSS parser 
which in turn handles CSS escapes, etc.

This is all already the case: MQ3 refers to the CSS2 tokens and grammar.

Cheers,
-- 
Simon Sapin

Received on Sunday, 5 May 2013 06:06:17 UTC