Skip to content

Commit

Permalink
Fix detection of nearest dialog for shadow DOM usage (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
hadriann committed Jan 6, 2021
1 parent cd2f547 commit fa3ba8c
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 fa3ba8c

Please sign in to comment.