Skip to content

Commit 4a2b220

Browse files
committed
oob swaps need to set swappingClass for when they use css transitions now
1 parent a77903b commit 4a2b220

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/htmx.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,6 +1886,10 @@ var htmx = (function() {
18861886
if (!swapOptions) {
18871887
swapOptions = {}
18881888
}
1889+
1890+
target = resolveTarget(target)
1891+
target.classList.add(htmx.config.swappingClass)
1892+
18891893
// optional transition API promise callbacks
18901894
let settleResolve = null
18911895
let settleReject = null
@@ -1895,7 +1899,6 @@ var htmx = (function() {
18951899
let doSwap = function() {
18961900
maybeCall(swapOptions.beforeSwapCallback)
18971901

1898-
target = resolveTarget(target)
18991902
const rootNode = swapOptions.contextElement ? getRootNode(swapOptions.contextElement, false) : getDocument()
19001903

19011904
// preserve focus and selection
@@ -4933,8 +4936,6 @@ var htmx = (function() {
49334936
swapSpec.ignoreTitle = ignoreTitle
49344937
}
49354938

4936-
target.classList.add(htmx.config.swappingClass)
4937-
49384939
if (responseInfoSelect) {
49394940
selectOverride = responseInfoSelect
49404941
}

test/attributes/hx-swap-oob.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ describe('hx-swap-oob attribute', function() {
435435
make('<table id="table"><tbody></tbody></table>')
436436
div.click()
437437
this.server.respond()
438-
byId('table').innerHTML.should.equal('<tbody><tr><td>Swapped15</td></tr></tbody>')
438+
byId('table').innerHTML.should.equal('<tbody class=""><tr><td>Swapped15</td></tr></tbody>')
439439
})
440440

441441
it('works with a swap delay', function(done) {

0 commit comments

Comments
 (0)