Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelWest22 committed Dec 18, 2024
1 parent 1f18f87 commit 35c06a1
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion test/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ describe("Core morphing tests", function(){
document.body.removeChild(parent);
});

it('can prevent element addition w/ the beforeNodeAdded callback', function() {
it.only('can prevent element addition w/ the beforeNodeAdded callback', function() {
let parent = make("<div><p>1</p><p>2</p></div>");
document.body.append(parent);

Expand Down Expand Up @@ -474,4 +474,35 @@ describe("Core morphing tests", function(){
}
});

it('non-attribute state of element with id is not transfered to other elements when moved between different containers', function()
{
getWorkArea().append(make(`
<div>
<div id="left">
<input type="checkbox" id="first">
</div>
<div id="right">
<input type="checkbox" id="second">
</div>
</div>
`));
document.getElementById("first").indeterminate = true

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

getWorkArea().innerHTML.should.equal(finalSrc);
// second checkbox is now in firsts place and we don't want firsts indeterminate state to be retained
// on what is now the second element so we need to prevent softMatch mroph from matching persistent id's
document.getElementById("second").indeterminate.should.eql(false)
});
})

0 comments on commit 35c06a1

Please sign in to comment.