W3C home > Mailing lists > Public > whatwg@whatwg.org > June 2009

[whatwg] Plus Signs in Signed Integers

From: Smylers <Smylers@stripey.com>
Date: Thu, 18 Jun 2009 17:33:33 +0100
Message-ID: <20090618163333.GG4461@stripey.com>
The algorithm for parsing signed integers does not allow an optional
plus sign before positive integers; that is, parsing "+4" will return an
error at step 8 of this algorithm:


That is inconsistent with the algorithm for non-negative integers, which
tolerates (and ignores) a leading plus sign (step 6):


It also doesn't seem to match browser behaviour: the <ol> element's
start attribute is an integer, so I tried this out in various browsers:

  <ol start=+4>
    <li>Plus four

All the ones I had to hand (Firefox, Opera, Konqueror, Dillo, Lynx,
Links, and W3M) numbered the element with "4".

I've no idea if any web content is relying on this, but there doesn't
seem to be any harm in being consistent with both current browser
behaviour and non-negative integers.

To check that it is specifically the plus sign they are ignoring and not
any non-digit character I also tried:

  <ol start=H2SO4>
    <li>Acid test

That should cause parsing an integer to abort and so the default of
start=1 to be used.  Opera, Links, and W3M get that right.  Konqueror,
Dillo, and Lynx all also seem to manage the aborting, but use a default
of zero instead.  Firefox parses the "2" out of "H2SO4", seemingly using
the first integer it can find in the attribute, so possibly isn't
special-casing "+".

Received on Thursday, 18 June 2009 09:33:33 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:13 UTC