Adding a <slot> to any component moves the whole template into the Shadow DOM. This breaks delegate event binding like click.delegate=β¦ because the global event handler canβt see the event from inside the Shadow DOM.
While I did understand the cause after thinking about it for a while (after being puzzled why my click handlers stopped working), Iβm quite sure that this side-effect will affect many people unexpectedly. (A good example is that realworld inside this repo has the same bug in its FollowButton.)
π€ Expected Behavior
Either click.delegate should work inside Shadow DOM or <slot> should not automatically trigger a Shadow DOM.
π Possible Solution
One workaround would be to register a delegate event handler inside each Shadow DOM component. But that probably reduces the benefits of having that global handler in the first place.
π» Code Sample
Component:
export class ShadowButton {
public onClick() {
console.log('CLICK');
}
}
π Bug Report
Adding a
<slot>
to any component moves the whole template into the Shadow DOM. This breaksdelegate
event binding likeclick.delegate=β¦
because the global event handler canβt see the event from inside the Shadow DOM.While I did understand the cause after thinking about it for a while (after being puzzled why my click handlers stopped working), Iβm quite sure that this side-effect will affect many people unexpectedly. (A good example is that
realworld
inside this repo has the same bug in itsFollowButton
.)π€ Expected Behavior
Either
click.delegate
should work inside Shadow DOM or<slot>
should not automatically trigger a Shadow DOM.π Possible Solution
One workaround would be to register a
delegate
event handler inside each Shadow DOM component. But that probably reduces the benefits of having that global handler in the first place.π» Code Sample
Component:
Template:
π Your Environment
Aurelia
0.4.0-dev.201910020524