diff --git a/src/idiomorph.js b/src/idiomorph.js index 8d62384..25d0ba7 100644 --- a/src/idiomorph.js +++ b/src/idiomorph.js @@ -236,7 +236,7 @@ var Idiomorph = (function () { const results = fn(); if (activeElementId && activeElementId !== document.activeElement?.id) { - activeElement = ctx.target.querySelector(`#${activeElementId}`); + activeElement = ctx.target.querySelector(`[id="${activeElementId}"]`); activeElement?.focus(); } if (activeElement && !activeElement.selectionEnd && selectionEnd) { diff --git a/test/restore-focus.js b/test/restore-focus.js index 4e76d4e..1c4a54a 100644 --- a/test/restore-focus.js +++ b/test/restore-focus.js @@ -651,6 +651,25 @@ describe("Option to forcibly restore focus after morph", function () { assertFocus("focused"); }); + it("restores focus state with reparented numeric id", function () { + assertFocusPreservationWithoutMoveBefore( + ` +