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

Re: [css3-flexbox] clarify the syntax ambiguity around unitless zero in 'flex' shorthand

From: Kang-Hao (Kenny) Lu <kanghaol@oupeng.com>
Date: Wed, 12 Sep 2012 11:51:06 +0800
Message-ID: <505006AA.8080704@oupeng.com>
To: Daniel Holbert <dholbert@mozilla.com>
CC: WWW Style <www-style@w3.org>
(12/09/12 8:20), Daniel Holbert wrote:
> On 09/11/2012 12:59 AM, Kang-Hao (Kenny) Lu wrote:
>> I suggest the spec say
>> something like
>>
>>   | The user agent must parse the first unitless zero as a
>>   | <'flex-grow'>.
> 
> I don't think that suggested text is quite what we want.  Here are two
> counterexamples where that text wouldn't be correct:
>   (a) 'flex: 1 0 0;'
>   (b) 'flex: 1 1 0;'
> 
> In (a), the first unitless 0 should be parsed as flex-shrink (not
> flex-grow).
> 
> In (b), the first unitless 0 should in fact be parsed as flex-basis (not
> flex-grow).

Ah, right. Then, what about this:

  | If the first component value is a unitless zero, the user agent
  | must parse it as <'flex-grow'>. If the first component value
  | matches <number> and the second component value is a unitless
  | zero, the user agent must parse it as <'flex-shrink'>.
  | This restricts the range of valid values. Note: For example,
  | 'flex: 0 1 1' is invalid.

?

> Off the top of my head, I can't think of clearer spec-text for this than
> what the spec already contains in that informative block.  

I would at least insist we change

  # If not omitted, a zero <'flex-basis'> component must be either
  # specified with a unit or preceded by both flex ratios. Otherwise it
  # will either be interpreted as one of the flex ratios, or will make
  # the declaration invalid.

to

  | If not omitted, a zero <'flex-basis'> component must be either
  | specified with a unit or preceded by both flex ratios. Otherwise the
  | user agent must either interpret it as one of the flex ratios, or
  | make the declaration invalid.

because otherwise the informative block just looks like it is only a
requirement on authors. Having said that, I still think this block is
quite fuzzy because it seems to be self-contradictory (is a zero
<'flex-basis'> component that is to be interpreted as one of the flex
ratios still a <'flex-basis'> component?). Also, what comes after ",or"
seems redundant and

  | If not omitted, a zero <'flex-basis'> component must be either
  | specified with a unit or preceded by both flex ratios. Otherwise the
  | user agent must interpret it as one of the flex ratios.

should be enough. (But it all depends on what "component" means... *shrug*)



Cheers,
Kenny
-- 
Web Specialist, Oupeng Browser, Beijing
Try Oupeng: http://www.oupeng.com/
Received on Wednesday, 12 September 2012 03:51:38 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:21:00 GMT