Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2077

ElementWrapper#onevent jQuery implementation can return a wrong ElementWrapper

    XMLWordPrintableJSON

Details

    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".

      Attachments

        1. elementwrapper.onevent.patch
          0.9 kB
          Julien Blatecky

        Issue Links

          Activity

            People

              Unassigned Unassigned
              julien1619 Julien Blatecky
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: