diff --git a/src/idiomorph.js b/src/idiomorph.js index 25d0ba7..60d29d1 100644 --- a/src/idiomorph.js +++ b/src/idiomorph.js @@ -548,7 +548,8 @@ var Idiomorph = (function () { const target = /** @type {Element} - will always be found */ ( - ctx.target.querySelector(`[id="${id}"]`) || + (ctx.target.id === id && ctx.target) || + ctx.target.querySelector(`[id="${id}"]`) || ctx.pantry.querySelector(`[id="${id}"]`) ); removeElementFromAncestorsIdMaps(target, ctx); diff --git a/test/fidelity.js b/test/fidelity.js index 438b67f..1c5c1ad 100644 --- a/test/fidelity.js +++ b/test/fidelity.js @@ -77,6 +77,24 @@ describe("Tests to ensure that idiomorph merges properly", function () { ); }); + it("should wrap an IDed node", function () { + getWorkArea().innerHTML = `
`; + let initial = getWorkArea().firstElementChild; + let finalSrc = `

`; + let ret = Idiomorph.morph(initial, finalSrc); + getWorkArea().innerHTML.should.equal(finalSrc); + // ret.map(e=>e.outerHTML).should.eql([finalSrc]); + }); + + it("should wrap an anonymous node", function () { + getWorkArea().innerHTML = `
`; + let initial = getWorkArea().firstElementChild; + let finalSrc = `

`; + let ret = Idiomorph.morph(initial, finalSrc); + getWorkArea().innerHTML.should.equal(finalSrc); + // ret.map(e=>e.outerHTML).should.eql([finalSrc]); + }); + it("should append a node", function () { testFidelity("
", "

hello you

"); });