Skip to content

Commit f413569

Browse files
botandrose-machinebotandrose
authored andcommitted
don't bother with active element preservation if the active element is <body>.
1 parent 3e372e9 commit f413569

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
@@ -1061,9 +1061,12 @@ var Idiomorph = (function () {
10611061
/** @type {Element[]} */
10621062
let activeElementAndParents = [];
10631063
let elt = document.activeElement;
1064-
while (elt && elt !== oldNode) {
1065-
activeElementAndParents.push(elt);
1066-
elt = elt.parentElement;
1064+
if (elt?.tagName !== "BODY" && oldNode.contains(elt)) {
1065+
while (elt) {
1066+
activeElementAndParents.push(elt);
1067+
if (elt === oldNode) break;
1068+
elt = elt.parentElement;
1069+
}
10671070
}
10681071
return activeElementAndParents;
10691072
}

0 commit comments

Comments
 (0)