Ticket #11125 (closed bug: invalid)
jQuery.event.trigger throws exception when custom event name is same as DOM object property
|Reported by:||sigmaxis||Owned by:||sigmaxis|
I have code that fires/listens to a custom event named "action" on a normal DOM form object. Prior to jQuery 1.7 this causes no issues. In jQuery 1.7+, triggering the "action" custom event on the form object results in the following exception:
elem[type] is not a function
This is in jQuery-1.7.1.js line 3175.
My understanding is that jQuery tries to run the native behaviour method (default handler) on the form object, assuming that the event name is going to refer to a method. In this case, however, the "action" event name ends up referring to the form's string "action" URL attribute.
The same error happens if I trigger a custom event named "length" on the form object. (Minor note: if the "length" value of the form is zero, as in the jsFiddle above, this may not reproduce, but it does in my real use case, when the "length" value is 4 - or any truthy value)
I can just switch to using a different custom event name as temporary workaround, but this seems like something that should be fixed.
NOTE: there is a bug (http://bugs.jquery.com/ticket/10574) that describes exactly the same line of code and the same resulting exception, but it was marked invalid because the submitter worked in an esoteric context. However, in this case I am using normal DOM object with a fairly normal custom event use case.
- Owner set to sigmaxis
- Status changed from new to pending