diff --git a/src/idiomorph.js b/src/idiomorph.js index 257c040..ab21454 100644 --- a/src/idiomorph.js +++ b/src/idiomorph.js @@ -1085,7 +1085,8 @@ var Idiomorph = (function () { * @returns {Element[]} */ function findIdElements(root) { - let elements = Array.from(root.querySelectorAll("[id]")); + // root could be a text or comment node which doesn't have `querySelectorAll` + let elements = Array.from(root.querySelectorAll?.("[id]") ?? []); // root could be a document fragment which doesn't have `getAttribute` if (root.getAttribute?.("id")) { elements.push(root); diff --git a/test/core.js b/test/core.js index 5e10210..7d559c8 100644 --- a/test/core.js +++ b/test/core.js @@ -121,6 +121,28 @@ describe("Core morphing tests", function () { ); }); + it("morphs outerHTML properly when oldNode is a text node", function () { + let parent = make("
Before
After
Before
After
", + ); + }); + it("morphs innerHTML as content properly when argument is null", function () { let initial = make("