Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/idiomorph.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 18 additions & 0 deletions test/fidelity.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,24 @@ describe("Tests to ensure that idiomorph merges properly", function () {
);
});

it("should wrap an IDed node", function () {
getWorkArea().innerHTML = `<hr id="a">`;
let initial = getWorkArea().firstElementChild;
let finalSrc = `<div><hr id="a"></div>`;
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 = `<hr>`;
let initial = getWorkArea().firstElementChild;
let finalSrc = `<div><hr></div>`;
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("<main></main>", "<main><p>hello you</p></main>");
});
Expand Down