diff --git a/packages/react-dom/src/events/getEventTarget.js b/packages/react-dom/src/events/getEventTarget.js index 1de46cb3ef2a1..ece189b77e5cc 100644 --- a/packages/react-dom/src/events/getEventTarget.js +++ b/packages/react-dom/src/events/getEventTarget.js @@ -18,6 +18,14 @@ function getEventTarget(nativeEvent) { // Fallback to nativeEvent.srcElement for IE9 // https://github.com/facebook/react/issues/12506 let target = nativeEvent.target || nativeEvent.srcElement || window; + // This is for solve the webcomponent event not working issue. And it will works on all the browsers which are all support the shadowDom. + // https://github.com/facebook/react/issues/9242 + let targetPath = + nativeEvent.path || + (nativeEvent.composedPath && nativeEvent.composedPath()); + if (target.shadowRoot && targetPath && targetPath.length) { + target = targetPath[0]; + } // Normalize SVG element events #4963 if (target.correspondingUseElement) {