You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by "Howard M. Lewis Ship (JIRA)" <ji...@apache.org> on 2013/03/15 01:22:13 UTC

[jira] [Commented] (TAP5-2077) ElementWrapper#onevent jQuery implementation can return a wrong ElementWrapper

    [ https://issues.apache.org/jira/browse/TAP5-2077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13602928#comment-13602928 ] 

Howard M. Lewis Ship commented on TAP5-2077:
--------------------------------------------

I think your patch is backwards.  

The intent it to unify the Prototype and jQuery behavior behind the t5/core/dom facade.

So it is by design that you get the element on which the event occurred, rather than the element on which the event handler was registered.  In most cases, the event handler is added to the <body> or even the document but the behavior applies to the element on which the event occurred (or a container of that element).

If this differs from the jQuery model; well a bunch of stuff does, core/dom is a bit of a mongrel. Use jQuery directly if you want jQuery semantics.
                
> ElementWrapper#onevent jQuery implementation can return a wrong ElementWrapper
> ------------------------------------------------------------------------------
>
>                 Key: TAP5-2077
>                 URL: https://issues.apache.org/jira/browse/TAP5-2077
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.4
>            Reporter: Julien Blatecky
>              Labels: dom, javascript, jquery, patch
>         Attachments: elementwrapper.onevent.patch
>
>
> 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".

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira