From 1dc5d3d0d19f17d94d0eb68d00ea8b90f70180ee Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Wed, 26 Feb 2025 12:09:33 -0600 Subject: [PATCH 1/3] failing test to expose issue with numeric ids. --- test/core.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/core.js b/test/core.js index dcf09ff..5e10210 100644 --- a/test/core.js +++ b/test/core.js @@ -185,6 +185,13 @@ describe("Core morphing tests", function () { initial.outerHTML.should.equal(final.outerHTML); }); + it("can handle numeric ids", function () { + let initial = make(`

`); + let final = `

`; + Idiomorph.morph(initial, final); + initial.outerHTML.should.equal(final); + }); + it("ignores active element when ignoreActive set to true", function () { let initialSource = "
Foo
"; getWorkArea().innerHTML = initialSource; From e1369ad995f5922376fb2a253ad0657a0cf7a09e Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Wed, 26 Feb 2025 12:12:21 -0600 Subject: [PATCH 2/3] work around numeric ids not being valid css selectors when prepended with #. --- src/idiomorph.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/idiomorph.js b/src/idiomorph.js index 219cd4f..8d62384 100644 --- a/src/idiomorph.js +++ b/src/idiomorph.js @@ -548,8 +548,8 @@ var Idiomorph = (function () { const target = /** @type {Element} - will always be found */ ( - ctx.target.querySelector(`#${id}`) || - ctx.pantry.querySelector(`#${id}`) + ctx.target.querySelector(`[id="${id}"]`) || + ctx.pantry.querySelector(`[id="${id}"]`) ); removeElementFromAncestorsIdMaps(target, ctx); moveBefore(parentNode, target, after); From d47ae96beb755da74dfdbdf0739b015cd9daa85c Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Wed, 26 Feb 2025 12:29:11 -0600 Subject: [PATCH 3/3] update CHANGELOG.md. --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1444893..86dc23e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ * Removed: * Remove AMD publish target since its EOL: https://github.com/requirejs/requirejs/issues/1816#issuecomment-707503323 +* Fixed: + * Fix error when morphing elements with numeric ids (@botandrose, @ksbrooksjr) + ## [0.7.2] - 2025-02-20 * Fixed: