File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff 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} ) ;
You can’t perform that action at this time.
0 commit comments