GoogleChrome / dialog-polyfill

Polyfill for the HTML dialog element
BSD 3-Clause "New" or "Revised" License
2.45k stars 245 forks source link

Fix detection of nearest dialog for shadow DOM usage (#189) #213

Closed hadriann closed 3 years ago

hadriann commented 3 years ago

Fix for issue #189 - allow DOM traversal in shadow DOM contexts.

hadriann commented 3 years ago

When element is a direct child of a shadow root, element.parentElement returns null instead of the parent shadow root. In this case, element.parentNode returns the actual parent shadow root, and element.parentNode.host returns the host element of that shadow root - i.e. the desired behavior for traversing up the DOM tree.