Bug Tracker

Ticket #3113 (assigned bug)

Opened 6 months ago

Last modified 5 months ago

unexpected attr behavior on form with input element named 'action'

Reported by: rryan Assigned to: flesler (accepted)
Type: bug Priority: minor
Milestone: 1.3 Component: core
Version: 1.2.6 Keywords: attr
Cc: Needs: Patch

Description

Given the following form:

<form action="someaction"> <input type="hidden" name="action" value="somevalue"/> </form>

If you have the dom element for the form, 'f'.

f.action = "foo", sets the value of the input element, not the action attribute on the form.

f.setAttribute("action","foo") sets the action attribute on the form tag.

In jQuery, if you say $("#form").attr("action","foo"), it actually sets the input element named action to 'foo', instead of setting the attribute on the form tag. Is this a bug? 'attr' would seem to imply the functionality of 'setAttribute', not this magic 'action' accessor on the dom element.

Thanks for all your hard work!

Attachments

attr-form.diff (2.5 kB) - added by flesler 6 months ago.
Imported from #2959.

Change History

Changed 6 months ago by flesler

  • need changed from Review to Patch
  • owner set to flesler
  • status changed from new to assigned

This was already spotted, we do have a solution in mind. We'll review this for 1.3.

Changed 6 months ago by flesler

Imported from #2959.

Changed 5 months ago by mw44118

Slightly related: it seems impossible to select a form by using the action attribute; e.g.,

<form action="x"> </form>

$("form[action='x']") will return an empty set of nodes.

Note: See TracTickets for help on using tickets.