Re: <li value=bogus> (detailed review of Semantics)

On Sun, 15 Jul 2007 00:22:11 +0200, Simon Pieters <simonp@opera.com> wrote:

>
> (This is part of my detailed review of the Semantics and structure of  
> HTML elements section.)
>
> The spec says about <li value>:
>
>     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, it must be treated as if the
>     attribute was absent. The attribute has no default value.
>
> This matches what Safari does.
>
>     http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E%0D%0A%3Col%3E%3Cli%3E.%3Cli%20value%3Dx%3E.%3Cscript%3Ew%28document.body.firstChild.firstChild.value+%22%2C%20%22+document.body.firstChild.firstChild.nextSibling.value%29%3C/script%3E
>
> In IE, if the attribute is present but parsing as an integer fails, the  
> used and the default value is 1.
>
> In Opera, if the attribute is present but parsing as an integer fails,  
> the used and the default value is 0.
>
> In Firefox, the default value is -1.
>
>
> Rendering-wise there is interop between Firefox and Safari. The lack of  
> interop suggests that pages don't rely on a specific behavior. Perhaps  
> the spec is fine as is, or it should be changed to match Firefox  
> instead, or IE -- I don't have an opinion either way.

Hmm. Negative numbers are also an issue.

    http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E%0D%0A%3Col%3E%3Cli%20value%3D-2%3E.%3Cscript%3Ew%28document.body.firstChild.firstChild.value%29%3C/script%3E

Safari acts as if the attribute was absent and getting .value returns -3.  
IE acts as if the attribute was absent and getting .value returns 0. Opera  
uses -3 and getting .value returns -3. Firefox uses 0 and getting .value  
returns 0.

-- 
Simon Pieters
Opera Software

Received on Sunday, 15 July 2007 11:55:39 UTC