Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handlers="..." declarative events listen on the host element and therefore see no event target info for events generated in shadowDom #41

Closed
sorvell opened this issue Nov 20, 2012 · 2 comments
Assignees

Comments

@sorvell
Copy link
Contributor

sorvell commented Nov 20, 2012

Because of upper bound encapsulation, event listeners installed on a component will get the component itself as the event target when an event is generated within its shadowDom. This is unfortunate since a component knows about its own shadowDom and should be able to get this target info.

For example, in g-ratings, it would be convenient to install a listener on the component and interrogate event.target to figure out which star was pressed. We cannot do so because the element node always has event.target set to itself.

We could address this by listening for events on the element's shadowRoot. This would, however, mean that events are relevant to a particular shadowRoot.

@ghost ghost assigned sjmiles Nov 20, 2012
@sorvell
Copy link
Contributor Author

sorvell commented Nov 27, 2012

Another alternative would be to install these events on the component's youngest shadowDom. In this case, because of event bubbling we would see events from anywhere inside the composed shadowDom. (When a < shadow > tag is used to host an inherited shadowDom and an event is generated within the inherited shadowDom, it will bubble to the containing shadowDom.)

However, again due to upper bound encapsulation, the event will be retargeted so that the event.target is the < shadow > element. And again, this is unfortunate because the component should be able to see this target info. It may be worth suggesting a change to shadowDom retargeting to avoid this as it's questionable whether upper bound encapsulation should function for a shadowDom stack.

This suggests that it's most natural for the handlers attribute to mean a component is interested in the shadowDom it generates itself and an extendor must redeclare interest in an event. If we go this way, perhaps we should attempt to move the handlers attribute to the component's shadowDom < template > tag.

@sorvell sorvell closed this as completed Nov 27, 2012
@sorvell sorvell reopened this Nov 27, 2012
@frankiefu
Copy link
Member

This has been addressed, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants