Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Duplicate
-
5.4
-
None
Description
Considers we bind an event on an element (<a> for example) and this element contains some other element (<span> for instance).
The event that will be triggered returns an ElementWrapper wrapping the span element if we clicked on span, instead of returning a wrapped element of the <a> element.
Consequently, in the case of a a[data-update-zone] containing some span or img elements, clicking on one of these elements raises a javascript error : "Attempt to wrap a null DOM element" when handling the callback.
Indeed, in the wrapped callback (line 95 in the coffeescript jquery dom) the ElementWrapper is instantiated with the "event.target" returned by jquery, which is not the element on which we defined the event, but the deeper element on which the event occurs. jQuery.com says "The target property can be the element that registered for the event or a descendant of it.", whereas "this" will be "the current DOM element within the event bubbling phase." just like "event.currentTarget".