diff options
author | Carson Gross <carson@bigsky.software> | 2024-08-05 13:37:31 -0600 |
---|---|---|
committer | Carson Gross <carson@bigsky.software> | 2024-08-05 13:37:31 -0600 |
commit | 084df38c31f10244c75099b3fac2e051cc287ebd (patch) | |
tree | 6c3b6e8b5e78f786f887dd37b018dabee828897d /test | |
parent | ce46e436fd5348d74848b490d3996157b4942364 (diff) | |
download | htmx-084df38c31f10244c75099b3fac2e051cc287ebd.tar.gz htmx-084df38c31f10244c75099b3fac2e051cc287ebd.zip |
only removed templates explicitly used for encapsulating oob swaps
fixes https://github.com/bigskysoftware/htmx/issues/2776
Diffstat (limited to 'test')
-rw-r--r-- | test/attributes/hx-swap-oob.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/attributes/hx-swap-oob.js b/test/attributes/hx-swap-oob.js index 7ad0094d..f2510656 100644 --- a/test/attributes/hx-swap-oob.js +++ b/test/attributes/hx-swap-oob.js @@ -176,6 +176,30 @@ describe('hx-swap-oob attribute', function() { should.equal(byId('d1'), null) }) + it('oob swap removes templates used for oob encapsulation only properly', function() { + this.server.respondWith('GET', '/test', '' + + 'Clicked<template><div hx-swap-oob="outerHTML" id="d1">Foo</div></template>') + var div = make('<button hx-get="/test" id="b1">Click Me</button>' + + '<div id="d1" ></div>') + var btn = byId('b1'); + btn.click() + this.server.respond() + should.equal(byId('b1').innerHTML, "Clicked") + should.equal(byId('d1').innerHTML, "Foo") + }) + + it('oob swap keeps templates not used for oob swap encapsulation', function() { + this.server.respondWith('GET', '/test', '' + + 'Clicked<template></template>') + var div = make('<button hx-get="/test" id="b1">Click Me</button>' + + '<div id="d1" ></div>') + var btn = byId('b1'); + btn.click() + this.server.respond() + should.equal(byId('b1').innerHTML, "Clicked<template></template>") + should.equal(byId('d1').innerHTML, "") + }) + for (const config of [{ allowNestedOobSwaps: true }, { allowNestedOobSwaps: false }]) { it('oob swap supports table row in fragment along other oob swap elements with config ' + JSON.stringify(config), function() { Object.assign(htmx.config, config) |