Created attachment 414097 [details] File to launch on iOS nothing will happen by clicking on "CLICK ME" This issue is happening only on iOS. First you have to create the following DOM (the file attached is doing it): <my-custom-element onclick="alert('CUSTOM BUTTON CLICKED')"> #shadowRoot <span> "button is:" <slot></slot> </span> "Some Text" </my-custom-element> when the dom is created you can add a listener to the shadowRoot like this: ```javascript document.querySelector('my-custom-element') .shadowRoot .addEventListener('click', () => { alert('CLICK EVENT FIRED'); }); ``` now you can press the "span" and you will see no event is fired. There is no alert at all displayed. The issue is related to the listener we have on the shadowRoot. If we don't have it the first listener is working well. Another strange behaviour is if you had an other listener on the "span" like this: ```javascript document.querySelector('my-custom-element') .shadowRoot .querySelector('span') .addEventListener('click', () => { alert('SPAN CLICKED'); }); ``` Now if you press the button the probleme is fixed the 3 handlers are well called as expected.
The biggest impact of this issue is when a third party script is capturing events coming from a shadow root, it impacts the initial behaviour of the custom component.
Another information. Attaching any of those events to the shadowRoot will change the initial component behaviour: - mouseover - click - mousedown - mouseup - mousemove
Thanks for filing. I can reproduce this with the provided test case on iOS 13.6.1 and the current iOS 14.3 beta.
<rdar://problem/71468598>
This was a bizarre bug! It all comes down to WebPage::commitPotentialTap failing to dispatch click event because ShadowRoot doesn't have a renderer.
Created attachment 460637 [details] WIP
Pull request: https://github.com/WebKit/WebKit/pull/2043
Committed 252107@main (b01e40564c21): <https://commits.webkit.org/252107@main> Reviewed commits have been landed. Closing PR #2043 and removing active labels.