whatwg/html

Make <li> ordinal value calculation precise

```Fixes #1608. As noted there, the existing prose was using confusing
concepts of attributes being "treated as if they were absent" and
"attribute values" that were distinct from the usual meaning.```
domenic authored and annevk committed Aug 4, 2016
Showing with 68 additions and 28 deletions.
1. +68 −28 source
96 source
 the attribute is omitted, the list is an ascending list (1, 2, 3, ...).

The start attribute, if present, must be a valid integer giving the ordinal value of the first list item.

valid integer. It is used to determine the starting value of the list.

If the start attribute is present, user agents must parse it as an integer, in order to determine the attribute's value. The default value, used if the attribute is missing or if the value cannot be converted to a number according to the referenced algorithm, is 1 if the element has no reversed attribute, and is the number of child li elements otherwise.

An ol element has a starting value, which is an integer determined as follows:

The first item in the list has the ordinal value given by the ol element's start attribute, unless that li element has a value attribute with a value that can be successfully parsed, in which case it has the ordinal value given by that value attribute.

1. If the ol element has a start attribute, then:

Each subsequent item in the list has the ordinal value given by its value attribute, if it has one, or, if it doesn't, the ordinal value of the previous item, plus one if the reversed is absent, or minus one if it is present.

1. Let parsed be the result of parsing the value of the attribute as an integer.

2. If parsed is not an error, then return parsed.

2. If the ol element has a reversed attribute, then return the number of child li elements.

3. Return 1.

parent element's list, as defined for those elements. Otherwise, the list item has no defined list-related relationship to any other li element.

If the parent element is an ol element, then the li element has an ordinal value.

The value attribute, if present, must be a valid integer giving the ordinal value of the list item.

valid integer. It is used to determine the ordinal value of the list item, when the parent element is an ol element.

If the value attribute is present, user agents must parse it as an integer, in order to determine the attribute's value. If the attribute's value cannot be converted to a number, the attribute must be treated as if it was absent. The attribute has no default value.

If the parent element is an ol element, then the li element has an ordinal value, which is an integer determined as follows:

The value attribute is processed relative to the element's parent ol element (q.v.), if there is one. If there is not, the attribute has no effect.

1. If the li element has a value attribute, then:

1. Let parsed be the result of parsing the value of the attribute as an integer.

2. If parsed is not an error, then return parsed.

2. If the li element is the first li child of its parent ol element, then return the ol element's starting value.

3. Let previous be the ordinal value of the first preceding sibling that is an li element.

4. If the parent ol element has a reversed attribute, then return previous − 1.

5. Return previous + 1.

The value IDL attribute must reflect the value of the value content attribute.

The element's value IDL attribute does not directly correspond to its ordinal value; it simply reflects the content attribute. For example, given this list:

<ol>
<li>Item 1
<li value="3">Item 3
<li>Item 4
</ol>

The ordinal values are 1, 3, and 4, whereas the value IDL attributes return 0, 3, 0 on getting.

start ol Ordinal value of the first item Starting value of the list Valid integer
step David Vest, David Woolley, David Zbarsky, Dave Methvin, DeWitt Clinton, Dean Edridge, Dean Edwards,