ignore overridden default swap style for hx-boost

fixes https://github.com/bigskysoftware/htmx/issues/342
This commit is contained in:
carson 2021-02-05 11:41:52 -07:00
parent 5836e2365e
commit 1a6f9b1ae5
2 changed files with 15 additions and 1 deletions

View File

@ -1749,7 +1749,7 @@ return (function () {
function getSwapSpecification(elt) {
var swapInfo = getClosestAttributeValue(elt, "hx-swap");
var swapSpec = {
"swapStyle" : htmx.config.defaultSwapStyle,
"swapStyle" : getInternalData(elt).boosted ? 'innerHTML' : htmx.config.defaultSwapStyle,
"swapDelay" : htmx.config.defaultSwapDelay,
"settleDelay" : htmx.config.defaultSettleDelay
}

View File

@ -57,5 +57,19 @@ describe("hx-boost attribute", function() {
})
it('overriding default swap style does not effect boosting', function () {
htmx.config.defaultSwapStyle = "afterend";
try {
this.server.respondWith("GET", "/test", "Boosted");
var a = make('<a hx-target="this" hx-boost="true" id="a1" href="/test">Foo</a>');
a.click();
this.server.respond();
a.innerHTML.should.equal("Boosted");
} finally {
htmx.config.defaultSwapStyle = "innerHTML";
}
})
});