[Bug 16491] Add simpler and better event registration system

https://www.w3.org/Bugs/Public/show_bug.cgi?id=16491

--- Comment #13 from Glenn Maynard <glenn@zewt.org> ---
The distinction between bubbling and capturing listeners is useful, since
otherwise you'd be firing every single even handler up the DOM tree twice.

But we don't need to try to eliminate every possible condition you might
short-circuit your event listener with.  Maybe somebody would want to do
something weird like "if(e.eventPhase != e.AT_TARGET)", but they should use
script for that.  The same applies to checking e.isTrusted, or shiftKey, or
countless other possible filters.

> FWIW, one of the other big features of the new event registration system is the Selector filter, which also just avoids having to type "if(!e.target.matchesSelector('...')) return"

(I think matchesSelector was renamed to just "matches".)

No, delegation is more than that.  You want to know if any node between
yourself (the delegate) and the target matches the selector.  That is, given

<div class=delegate>
    <div class=box>
        <span>hello</span>
    </div>
</div>

If you put a listener on .delegate to listen to clicks on .box, it should still
fire if you click within the span, even though the target itself doesn't match
the selector.  In other words, starting at the target, search up through parent
nodes to find the first one that matches the selector.  (This is
http://api.jquery.com/closest.)

Also, you'll want to know what element actually matched the selector.  jQuery
sets currentTarget to the matched element, and sets an additional property
delegateTarget which is the original currentTarget (the element the event
listener is bound to).

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Friday, 15 February 2013 20:34:21 UTC