- From: Erik Bruchez <ebruchez@orbeon.com>
- Date: Mon, 8 Oct 2018 17:22:35 +0200
- To: Steven Pemberton <steven.pemberton@cwi.nl>
- Cc: XForms <public-xformsusers@w3.org>, Alain Couthures <alain.couthures@agencexml.com>
- Message-ID: <CAAc0PEXaLyQ5bR_yH5jyZAgq0AJ6_S__PKKhoPffxi+PsQOd1Q@mail.gmail.com>
My reply: This is to allow what is known as *event delegation*: "Event delegation refers to the process of using event propagation (bubbling) to handle events at a higher level in the DOM than the element on which the event originated. It allows us to attach a single event listener for elements that exist now or in the future." (from an older version of [this jQuery doc page]( https://learn.jquery.com/events/event-delegation/)) In general, this is a good thing: - You use less event listeners. - A listener can listen on multiple targets. - You don't need to remove/add listeners as DOM elements are added/removed. It seems that, in the HTML world, things have moved towards letting everything bubble. For example, the old `focus` event didn't bubble, and the newer `focusin` event bubbles. If you have an event handler which gets activated by events dispatched to multiple targets, in some cases you need the ability to discriminate. This is where event context information is useful. Libraries like jQuery also allow you to associate an event handler filtered by CSS selector, which is neat. Now in the case of `xforms-select` specifically, your issue is that you cannot discriminate between this event dispatched to an `xf:case` vs. an `xf:select`. This might mean XForms shouldn't have a single event for these two scenarios, or it should have enough event context information to discriminate between the two. I don't think that this is making a case for not letting the event bubble. -Erik On Mon, Oct 8, 2018 at 12:49 PM Steven Pemberton <steven.pemberton@cwi.nl> wrote: > Good question. > > I think they shouldn't. > > Steven > > On Mon, 08 Oct 2018 06:54:36 +0200, Alain Couthures < > alain.couthures@agencexml.com> wrote: > > Hello, > > There is an interesting question about events in XForms at > https://stackoverflow.com/questions/52694052/why-do-the-xforms-select-and-xforms-deselect-elements-bubble > > What do you think? > > Alain > > > > >
Received on Monday, 8 October 2018 15:23:09 UTC