W3C home > Mailing lists > Public > public-html@w3.org > April 2011

Re: Browser inconsistencies in implementing name getters on forms and form element collections

From: Simon Pieters <simonp@opera.com>
Date: Fri, 15 Apr 2011 17:26:46 +0200
To: "HTML WG" <public-html@w3.org>, "Boris Zbarsky" <bzbarsky@mit.edu>
Message-ID: <op.vtzjuwlcidj3kv@simon-pieterss-macbook.local>
On Thu, 14 Apr 2011 15:46:24 +0200, Boris Zbarsky <bzbarsky@mit.edu> wrote:

> Consider the following testcase:
>
>    <!DOCTYPE html>
>    <form name="x">
>      <img name="y">
>    </form>
>    <script>
>      alert(document.forms["x"].y);
>      alert(document.forms["x"].elements.y);
>    </script>
>
> The results are as follows:
>
> IE9: alerts undefined twice (in both standards and quirks mode
>       as far as I can tell).
> Opera 11: alerts [object HTMLImageElement], then undefined
> Firefox: alerts [object HTMLImageElement], then undefined
> Chrome: alerts [object HTMLImageElement] twice
> Safari: alerts [object HTMLImageElement] twice
>
> Chrome and Safari are consistent with what the spec currently says for  
> the namegetter on HTMLFormElement, but not with the behavior specified  
> for form.elements.
>
> Opera and Firefox do what the spec currently says for form.elements, but  
> not for HTMLFormElement.
>
> IE currently does what the spec currently says.
>
> I'm pretty sure I've seen code in the past that switches on "IE vs  
> Netscape" and uses form.x for the latter while using getElementById for  
> the former, but that was a good long while ago.  So I think we're  
> willing to risk the compat hit in Gecko of changing to the currently  
> specced behavior (which will incidentaly be simpler than what we do  
> now).  Are Opera and WebKit willing to do that too?  Or does the spec  
> need to change?
>
> -Boris

Is this just for <img>?

If Gecko changes and finds no compat problems then I'm sure Opera would  
change to match the spec too. If however you do find compat problems then  
that would be a good reason to change the spec.

cheers
-- 
Simon Pieters
Opera Software
Received on Friday, 15 April 2011 15:27:19 UTC

This archive was generated by hypermail 2.3.1 : Monday, 29 September 2014 09:39:24 UTC