Skip to content

Commit 31ace40

Browse files
don't bother with active element preservation if the active element is <body>.
1 parent 7a912d4 commit 31ace40

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/idiomorph.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,9 +1047,12 @@ var Idiomorph = (function () {
10471047
/** @type {Element[]} */
10481048
let activeElementAndParents = [];
10491049
let elt = document.activeElement;
1050-
while (elt && elt !== oldNode) {
1051-
activeElementAndParents.push(elt);
1052-
elt = elt.parentElement;
1050+
if (elt?.tagName !== "BODY" && oldNode.contains(elt)) {
1051+
while (elt) {
1052+
activeElementAndParents.push(elt);
1053+
if (elt === oldNode) break;
1054+
elt = elt.parentElement;
1055+
}
10531056
}
10541057
return activeElementAndParents;
10551058
}

0 commit comments

Comments
 (0)