Skip to content

Commit

Permalink
Merge pull request #213 from hadriann/patch-nearest-dialog
Browse files Browse the repository at this point in the history
Fix detection of nearest dialog for shadow DOM usage (#189)
  • Loading branch information
samthor committed Jan 7, 2021
2 parents cd2f547 + fa3ba8c commit 75df500
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
8 changes: 7 additions & 1 deletion dist/dialog-polyfill.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ function findNearestDialog(el) {
if (el.localName === 'dialog') {
return /** @type {HTMLDialogElement} */ (el);
}
el = el.parentElement;
if (el.parentElement) {
el = el.parentElement;
} else if (el.parentNode) {
el = el.parentNode.host;
} else {
el = null;
}
}
return null;
}
Expand Down
8 changes: 7 additions & 1 deletion dist/dialog-polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@
if (el.localName === 'dialog') {
return /** @type {HTMLDialogElement} */ (el);
}
el = el.parentElement;
if (el.parentElement) {
el = el.parentElement;
} else if (el.parentNode) {
el = el.parentNode.host;
} else {
el = null;
}
}
return null;
}
Expand Down
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ function findNearestDialog(el) {
if (el.localName === 'dialog') {
return /** @type {HTMLDialogElement} */ (el);
}
el = el.parentElement;
if (el.parentElement) {
el = el.parentElement;
} else if (el.parentNode) {
el = el.parentNode.host;
} else {
el = null;
}
}
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dialog-polyfill",
"version": "0.5.4",
"version": "0.5.5",
"description": "Polyfill for the dialog element",
"main": "dist/dialog-polyfill.js",
"module": "dist/dialog-polyfill.esm.js",
Expand Down

0 comments on commit 75df500

Please sign in to comment.