Skip to content

Commit

Permalink
its not clear that we need this.
Browse files Browse the repository at this point in the history
  • Loading branch information
botandrose-machine committed Jan 14, 2025
1 parent 1c19fdd commit 369e4fd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 33 deletions.
9 changes: 2 additions & 7 deletions src/idiomorph.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,13 +473,8 @@ var Idiomorph = (function () {
function moveBefore(parentNode, element, after) {
// @ts-ignore - use proposed moveBefore feature
if (parentNode.moveBefore) {
try {
// @ts-ignore - use proposed moveBefore feature
parentNode.moveBefore(element, after);
} catch (e) {
// fall back to insertBefore as some browsers may fail on moveBefore when trying to move Dom disconnected nodes to pantry
parentNode.insertBefore(element, after);
}
// @ts-ignore - use proposed moveBefore feature
parentNode.moveBefore(element, after);
} else {
parentNode.insertBefore(element, after);
}
Expand Down
26 changes: 0 additions & 26 deletions test/retain-hidden-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,32 +338,6 @@ describe("Hidden state preservation tests", function () {
states.should.eql([true]);
});

it("check moveBefore function fails back to insertBefore if moveBefore fails", function () {
getWorkArea().append(
make(`
<div>
<input type="checkbox" id="first">
<input type="checkbox" id="second">
</div>
`),
);
// replace moveBefore function with a boolean which will fail the try catch
document.getElementById("first").parentNode.moveBefore = true;
document.getElementById("second").parentNode.moveBefore = true;

let finalSrc = `
<div>
<input type="checkbox" id="second">
<input type="checkbox" id="first">
</div>
`;
Idiomorph.morph(getWorkArea(), finalSrc, {
morphStyle: "innerHTML",
});

getWorkArea().innerHTML.should.equal(finalSrc);
});

it("check moveBefore function falls back to insertBefore if moveBefore is missing", function () {
getWorkArea().append(
make(`
Expand Down

0 comments on commit 369e4fd

Please sign in to comment.