webcomponents / webcomponents/polyfills

[ShadyDOM] Events dispatched by Light DOM children in connectedCallback cannot be handled

Open
#94 4 comments 0 reactions 0 assignees View on GitHub
Package: shadydom Severity: High Type: Bug wontfix
Dominant language
HTML
Stars
1.2k
Forks
168
PR merge metrics
No merged PRs in 30d

Description

#### Live Demo

https://stackblitz.com/edit/shady-dom-events?file=index.html

#### Steps to Reproduce

Create two elements and nest one in the other.
Have the child dispatch an event in `connectedCallback`
Have the parent listen for that event

#### Expected Results
The event should be handled by the parent.

#### Actual Results
In polyfilled browsers the event coming from `connectedCallback` is not handled. It's almost like it doesn't exist. It does not trigger the handler and it's not even causing the capture phase.

Events dispatched past `connectedCallback` are handled as expected.

#### Workaround
It is enough to make the dispatch async by wrapping in `setTimeout(dispatch, 0)`.

### Browsers Affected

- [ ] Chrome
- [ ] Firefox
- [x] Edge
- [ ] Safari 9
- [ ] Safari 8
- [x] IE 11

### Versions
- webcomponents: v2.2.7

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.