diff --git a/src/idiomorph.js b/src/idiomorph.js index bbd972e..333a2e3 100644 --- a/src/idiomorph.js +++ b/src/idiomorph.js @@ -1019,7 +1019,7 @@ var Idiomorph = (function () { throw `Do not understand how to morph head style ${headStyle}`; } - const doc = oldNode.ownerDocument; + const doc = ownerDocumentOf(oldNode); return { target: oldNode, @@ -1452,6 +1452,27 @@ var Idiomorph = (function () { }; })(); + /** + * `
`); + getWorkArea().append(form); + form.innerHTML = ` + + `; + for (const elt of form.querySelectorAll("input")) { + elt.parentElement.moveBefore = undefined; + } + let input = document.getElementById("focused"); + input.focus(); + input.setSelectionRange(1, 2); + + Idiomorph.morph( + form, + ` + + `, + { morphStyle: "innerHTML" }, + ); + + let focused = document.getElementById("focused"); + (document.activeElement === focused).should.equal(true); + focused.selectionStart.should.equal(1); + focused.selectionEnd.should.equal(2); + }); + it("restores focus and selection state with outerHTML morphStyle", function () { const div = make(`