[whatwg] Treatment of negative values for li
Aryeh Gregor
Simetrical+w3c at gmail.com
Thu Aug 12 13:24:14 PDT 2010
The HTML5 spec doesn't say UAs should treat <li value="-1"> different
from a negative value specified for any long. For example, a get on
the reflected attribute li.value should return "-1". In this test
case:
<!doctype html>
<script>
var el = document.createElement("li");
el.setAttribute("value", "-1");
alert(el.value);
</script>
Chrome dev, Safari 5, and Opera 10.60 all alert "-1" as expected, but
Firefox 4.0b3 and IE8/9 (all modes) alert "0". In fact, Firefox and
IE clamp all negative values to 0. Does anyone think this behavior is
valuable, or should Firefox and IE change to match the spec? I don't
see any reason to treat negative values specially, if the author goes
out of their way to specify them.
Relatedly, only Opera seems to handle markup like
<!doctype html>
<ol>
<li value="-2">...
<li value="-1">...
<li value="0">...
<li value="1">...
</ol>
correctly. IE8 and WebKit give 1, 2, 3, 1 (treating nonpositive value
attribute the same as if it were missing), and Firefox gives 0, 0, 0,
1 (clamping negative values to 0). Opera gives -2, -1, 0, 1 as
expected. Again, I think the spec is correct here, but since browsers
disagree so widely, I'm asking for opinions before I file bugs against
browsers.
More information about the whatwg
mailing list