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

(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 UTC