#140 enhancement
Matt Kantor

Form.down on forms with inputs named "id" is broken in Webkit browsers

Reported by Matt Kantor | September 14th, 2009 @ 07:50 PM

When calling Element.down or Element.select on forms which have inputs named "id" as children, the form's id is changed to the string version of the input element. This is difficult to explain, so you should probably just read the test case:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <title>Test Case</title>
        <script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6/prototype.js"></script>
        <script>
            document.observe('dom:loaded', function() {
                var form = $('real-id');
                alert(form.readAttribute('id')); // "real-id"

                form.down('span'); // causes the bug with any child of form (doesn't have to be the input named "id")
                alert(form.readAttribute('id')); // "[object HTMLInputElement]" in Webkit browsers
            });
        </script>
    </head>
    <body>
        <form id="real-id">
            <input name="id" />
            <span></span>
        </form>
    </body>
</html>

The bug is present if there is any doctype at all (HTML 4.01 Transitional, XHTML 1.0 Transitional, and XHTML 1.1 were tested), but doesn't occur when there is no doctype (presumably Webkit's version of "quirks mode"?).

The bug isn't related to readAttribute (this was just an easy way to demo it). You will see the changed id when using outerHTML or anything similar.

The bug seems to only happen when using form.down/form.select. Double-dollar doesn't cause the bug (in my test case replacing "form.down('span')" with "$$('#real-id span')" works correctly). Form.getInputs works correctly as well.


Prototype version: 1.6.1
Browsers tested with incorrect behavior:

  • Chrome 2.0.172.43 XP
  • Safari 4 Beta (528.16) XP
  • Safai 4.0.3 (531.9.1) XP

Browsers tested with correct behavior:

  • Firefox 3.0.14 Linux
  • Firefox 3.5.2 XP
  • IE8 XP

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Shared Ticket Bins

Attachments

Pages