diff --git a/dist/dialog-polyfill.esm.js b/dist/dialog-polyfill.esm.js index da774bc..5aea677 100644 --- a/dist/dialog-polyfill.esm.js +++ b/dist/dialog-polyfill.esm.js @@ -64,7 +64,9 @@ function findNearestDialog(el) { if (el.localName === 'dialog') { return /** @type {HTMLDialogElement} */ (el); } - if (el.parentElement) { + if (el.assignedSlot) { + el = el.assignedSlot; + } else if (el.parentElement) { el = el.parentElement; } else if (el.parentNode) { el = el.parentNode.host; diff --git a/dist/dialog-polyfill.js b/dist/dialog-polyfill.js index aee7d96..c9954d6 100644 --- a/dist/dialog-polyfill.js +++ b/dist/dialog-polyfill.js @@ -70,7 +70,9 @@ if (el.localName === 'dialog') { return /** @type {HTMLDialogElement} */ (el); } - if (el.parentElement) { + if (el.assignedSlot) { + el = el.assignedSlot; + } else if (el.parentElement) { el = el.parentElement; } else if (el.parentNode) { el = el.parentNode.host; diff --git a/index.js b/index.js index 8adc5ad..2b2fdcd 100644 --- a/index.js +++ b/index.js @@ -65,7 +65,9 @@ function findNearestDialog(el) { if (el.localName === 'dialog') { return /** @type {HTMLDialogElement} */ (el); } - if (el.parentElement) { + if (el.assignedSlot) { + el = el.assignedSlot; + } else if (el.parentElement) { el = el.parentElement; } else if (el.parentNode) { el = el.parentNode.host;