This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 28444 - [Shadow]: Make event retargeting optional
Summary: [Shadow]: Make event retargeting optional
Status: RESOLVED MOVED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - Component Model (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Hayato Ito
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 15480
  Show dependency treegraph
 
Reported: 2015-04-08 16:00 UTC by Dimitri Glazkov
Modified: 2015-05-27 02:51 UTC (History)
6 users (show)

See Also:


Attachments

Description Dimitri Glazkov 2015-04-08 16:00:41 UTC
From https://lists.w3.org/Archives/Public/public-webapps/2015AprJun/0052.html

Annevk: "I think opt-in (or only
with isolated) would be better and perhaps if the API needs to change
anyway we can do that, but we could probably live with opt-out as
well. When you use shadow DOM to compose, global reasoning about state
and events is a fairly established pattern that we should enable."
Comment 1 Dimitri Glazkov 2015-04-08 18:27:59 UTC
As far as I understand, the event.path is the mechanism to enable global reasoning about events. Optional event retargeting seems to be only complicating already complex algos. Consider a scenario where you have a mix of trees with and without retargeting.
Comment 2 Anne 2015-04-13 09:32:36 UTC
Yeah, which is why perhaps we should only do retargeting if the tree is explicitly closed. (Isolated would also have to do it of course.)

That seems like a much more logical model and allows for event.path and event.target to be consistent. The current approach seems a lot like the originalTarget approach from XBL.
Comment 3 Dimitri Glazkov 2015-04-13 17:42:47 UTC
(In reply to Anne from comment #2)
> Yeah, which is why perhaps we should only do retargeting if the tree is
> explicitly closed. (Isolated would also have to do it of course.)

This suggestion is interesting, but it is orthogonal to the complexity concern. I would still need extra branch points in the retargeting algos in order to account for nested trees that interleave the setting with and without retargeting (whether or not coupled to the closed/open setting), plus the extra transitive complexity of managing insertion points.

 
> That seems like a much more logical model and allows for event.path and
> event.target to be consistent. The current approach seems a lot like the
> originalTarget approach from XBL.

Can you explain a bit more why event.path seems bad? As far as I can tell, it works well for consumers with event delegation needs.
Comment 4 Dimitri Glazkov 2015-04-13 18:01:23 UTC
+dfreedm to comment on the coupling of closed/open and retargeting opt-in idea.
Comment 5 Daniel Freedman 2015-04-13 22:17:16 UTC
I think retargeting events for "open" shadowroots is still the right paradigm.

When composing elements with ShadowRoots together, it is far more useful to think of those elements as one whole, rather than their constituent pieces.
With retargeting, a developer can use very simple event delegation in their own scope with event.target for discrete composition points, rather than some more complicated ancestry checking.

For example:

If I have a fancy tab bar that controls content

  <tab-bar>
    #shadow-root
      <t-ab id="one">
        #shadow-root
          <fancy-ripple-effect></fancy-ripple-effect>
          Tab One!
      </t-ab>
      <t-ab id="two">
        (..snip..)
        Tab Two!
      </t-ab>
  </tab-bar>

and click on the first tab, with retargeting I can just check event.target === #one to show the associated content.

With event retargeting, each composition boundary can have this simple event delegation construct and be very intuitive for development.

I see event.path as more useful for a global event delegation mechanism, such as for determining desired scrolling behavior with touch events:

  for (var i = 0, el; el = touchEvent.path[i]; i++)
    if (el._shouldStopScrolling)
      touchEvent.preventDefault();
Comment 6 Hayato Ito 2015-04-27 03:17:25 UTC
Let me move this bug to v2 since it is not a blocker for v1.
Comment 7 Hayato Ito 2015-05-27 02:51:37 UTC
Moved to https://github.com/w3c/webcomponents/issues/89