Bug Tracker

Ticket #11145 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

$(document).on() not working with name="disabled"

Reported by: stevene Owned by: gibson042
Priority: low Milestone: 1.7.2
Component: event Version: 1.7.1
Keywords: Cc:
Blocking: Blocked by:

Description

If a form includes an element with a name attribute of 'disabled', the .on function does not prevent the form from being submitted (when used with a descendant selector).

This form is not prevented from submitting:

<form action="google.com">
    <input type="text" name="disabled" value="Some text" />
    <input type="submit" />
</form>
$(document).on('submit', 'form', false);

If the name of the text input was changed to anything other than 'disabled' the form is prevented from submitting.

Strangely, if I change the method to the following, the original form would not submit (even with the name="disabled" attribute)

$('form').on('submit', false);

Example: Two identical forms, one with name="disabled"  http://jsfiddle.net/y3HVA/

Note: I am not trying to disable this field, I simply wanted to use the name 'disabled' as the attribute.

Change History

comment:1 Changed 3 years ago by gibson042

Confirmed. To fix #6911, jquery.event.dispatch delegate handler processing requires !event.target.disabled. In this case, both event.target and event.target.disabled are elements... the former a form and the latter a contained input.

I recommend we instead require event.target.disabled !== true.

comment:3 Changed 3 years ago by dmethvin

  • Owner set to gibson042
  • Status changed from new to assigned

Thanks gibson042, I'll land this soon!

comment:4 Changed 3 years ago by Richard Gibson

  • Status changed from assigned to closed
  • Resolution set to fixed

Fix #11145: Harden dispatch against a form-aliased "disabled" property

Changeset: 77de76b942bf6bde5cf17ddad15b03049c92e6be

comment:5 Changed 3 years ago by dmethvin

  • Priority changed from undecided to low
  • Component changed from unfiled to event
  • Milestone changed from None to 1.7.2
Note: See TracTickets for help on using tickets.