Skip to content

Commit 9eaf26f

Browse files
MichaelWest22botandrose-machine
authored andcommitted
failing test for #124
1 parent 4341fb3 commit 9eaf26f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/htmx-integration.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,33 @@ describe("Tests for the htmx integration", function () {
183183
initialBtn.innerHTML.should.equal("Bar");
184184
});
185185
*/
186+
187+
it("keeps the element live in an outer morph when node type changes", function () {
188+
this.server.respondWith(
189+
"GET",
190+
"/test",
191+
"<div id='b1' hx-swap='morph' hx-get='/test2' class='bar'>Foo</div>",
192+
);
193+
this.server.respondWith(
194+
"GET",
195+
"/test2",
196+
"<button id='b1' hx-swap='morph' hx-get='/test3' class='doh'>Foo</button>",
197+
);
198+
let initialBtn = makeForHtmxTest(
199+
"<button id='b1' hx-swap='morph' hx-get='/test'>Foo</button>",
200+
);
201+
202+
initialBtn.click();
203+
this.server.respond();
204+
let newDiv = document.getElementById("b1");
205+
206+
newDiv.classList.contains("bar").should.equal(true);
207+
newDiv.classList.contains("doh").should.equal(false);
208+
209+
newDiv.click();
210+
this.server.respond();
211+
let newBtn = document.getElementById("b1");
212+
newBtn.classList.contains("bar").should.equal(false);
213+
newBtn.classList.contains("doh").should.equal(true);
214+
});
186215
});

0 commit comments

Comments
 (0)