Bug Tracker

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#11145 closed bug (fixed)

$(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:
Blocked by: Blocking:


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" />
$(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 (5)

comment:1 Changed 4 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 4 years ago by dmethvin

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

Thanks gibson042, I'll land this soon!

comment:4 Changed 4 years ago by Richard Gibson

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

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

Changeset: 77de76b942bf6bde5cf17ddad15b03049c92e6be

comment:5 Changed 4 years ago by dmethvin

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