From 7da5ffcf4e4ed238990fa5707376130d255a5abe Mon Sep 17 00:00:00 2001
From: xunguangzlj-cloud <293371022+xunguangzlj-cloud@users.noreply.github.com>
Date: Sun, 8 Nov 2026 17:56:46 +0800
Subject: [PATCH] Process out-of-band swaps inside partials
---
src/htmx.js | 1 +
test/tests/attributes/hx-swap-oob.js | 10 ++++++++++
www/src/content/reference/06-tags/01-hx-partial.md | 2 ++
3 files changed, 13 insertions(+)
diff --git a/src/htmx.js b/src/htmx.js
index 83caa151e..6fefab83a 100644
--- a/src/htmx.js
+++ b/src/htmx.js
@@ -1161,6 +1161,7 @@ var htmx = (() => {
let targetSelector = this.__attr(templateElt, 'hx-target') || (templateElt.id ? '#' + CSS.escape(templateElt.id) : null);
if (targetSelector) {
this.__processScripts(templateElt.content);
+ tasks.push(...this.__processOOB(templateElt.content, ctx.sourceElement));
let swapSpec = this.__parseSwapSpec(this.__attr(templateElt, 'hx-swap') || this.config.defaultSwap);
if (swapSpec.ignoreTitle) ctx.title = null;
let targets = this.__findAllExt(ctx.sourceElement, targetSelector);
diff --git a/test/tests/attributes/hx-swap-oob.js b/test/tests/attributes/hx-swap-oob.js
index 9c7dd818b..dcbe158e1 100644
--- a/test/tests/attributes/hx-swap-oob.js
+++ b/test/tests/attributes/hx-swap-oob.js
@@ -24,6 +24,16 @@ describe('hx-swap-oob', function() {
assertTextContentIs('#oob2', 'New Inner')
})
+ it('swaps an oob element out of an hx-partial', async function () {
+ mockResponse('GET', '/test', ' New content