mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-27 13:01:03 +00:00
scan through all siblings (not just until the first non-element) when doing an outerHTML swap to add things to settle
fixes https://github.com/bigskysoftware/htmx/issues/2787
This commit is contained in:
parent
df16ed8e96
commit
0ace4a731c
@ -1639,13 +1639,13 @@ var htmx = (function() {
|
||||
newElt = eltBeforeNewContent.nextSibling
|
||||
}
|
||||
settleInfo.elts = settleInfo.elts.filter(function(e) { return e !== target })
|
||||
// scan through all newly added content and add all elements to the settle info so we trigger
|
||||
// events properly on them
|
||||
while (newElt && newElt !== target) {
|
||||
if (newElt instanceof Element) {
|
||||
settleInfo.elts.push(newElt)
|
||||
newElt = newElt.nextElementSibling
|
||||
} else {
|
||||
newElt = null
|
||||
}
|
||||
newElt = newElt.nextSibling
|
||||
}
|
||||
cleanUpElement(target)
|
||||
if (target instanceof Element) {
|
||||
|
@ -163,6 +163,24 @@ describe('Core htmx Events', function() {
|
||||
}
|
||||
})
|
||||
|
||||
it('htmx:afterSwap is called when replacing outerHTML, new line content', function() {
|
||||
var called = false
|
||||
var handler = htmx.on('htmx:afterSwap', function(evt) {
|
||||
called = true
|
||||
})
|
||||
try {
|
||||
this.server.respondWith('POST', '/test', function(xhr) {
|
||||
xhr.respond(200, {}, '\n<button>Bar</button>')
|
||||
})
|
||||
var div = make("<button hx-post='/test' hx-swap='outerHTML'>Foo</button>")
|
||||
div.click()
|
||||
this.server.respond()
|
||||
should.equal(called, true)
|
||||
} finally {
|
||||
htmx.off('htmx:afterSwap', handler)
|
||||
}
|
||||
})
|
||||
|
||||
it('htmx:oobBeforeSwap is called before swap', function() {
|
||||
var called = false
|
||||
var handler = htmx.on('htmx:oobBeforeSwap', function(evt) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user