From 826ecc1b50bbd7976cd6c977e41f94b5694468ad Mon Sep 17 00:00:00 2001 From: rameel Date: Mon, 31 Aug 2026 19:07:19 +0500 Subject: [PATCH 1/3] Rename DefaultSwapEmpty to AllowEmptySwapAfterOOB --- src/Ramstack.HtmxToolkit/Configuration/HtmxV4Config.cs | 9 ++++++--- .../TagHelpers/HtmxConfigTagHelperTests.cs | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Ramstack.HtmxToolkit/Configuration/HtmxV4Config.cs b/src/Ramstack.HtmxToolkit/Configuration/HtmxV4Config.cs index 02d5eae..0df3e36 100644 --- a/src/Ramstack.HtmxToolkit/Configuration/HtmxV4Config.cs +++ b/src/Ramstack.HtmxToolkit/Configuration/HtmxV4Config.cs @@ -63,10 +63,13 @@ public HtmxSwap? DefaultSwap } /// - /// Gets or sets a value indicating whether an empty response body replaces the main swap target. - /// The HTMX default is undefined. + /// Gets or sets a value indicating whether the main swap is performed + /// when the response contained only out-of-band elements. + /// <hx-partial> content always prevents the main swap. + /// The HTMX default is and can be overridden + /// using the swapEmpty modifier on hx-swap. /// - public bool? DefaultSwapEmpty + public bool? AllowEmptySwapAfterOOB { get; set => SetField(ref field, value); diff --git a/tests/Ramstack.HtmxToolkit.Tests/TagHelpers/HtmxConfigTagHelperTests.cs b/tests/Ramstack.HtmxToolkit.Tests/TagHelpers/HtmxConfigTagHelperTests.cs index 5eef6ab..e8d064e 100644 --- a/tests/Ramstack.HtmxToolkit.Tests/TagHelpers/HtmxConfigTagHelperTests.cs +++ b/tests/Ramstack.HtmxToolkit.Tests/TagHelpers/HtmxConfigTagHelperTests.cs @@ -250,7 +250,7 @@ public async Task ProcessAsync_SerializesOnlyHtmx4Options() htmx.MetaCharacter = "-"; htmx.History = HtmxHistoryMode.Reload; htmx.DefaultSwap = HtmxSwap.OuterMorph; - htmx.DefaultSwapEmpty = true; + htmx.AllowEmptySwapAfterOOB = true; htmx.DefaultSettleDelay = 1; htmx.IncludeIndicatorCss = false; htmx.IndicatorClass = "indicator"; @@ -273,7 +273,7 @@ public async Task ProcessAsync_SerializesOnlyHtmx4Options() Assert.That(json.Keys, Is.EquivalentTo(new[] { - "logAll", "prefix", "metaCharacter", "history", "defaultSwap", "defaultSwapEmpty", + "logAll", "prefix", "metaCharacter", "history", "defaultSwap", "allowEmptySwapAfterOOB", "defaultSettleDelay", "includeIndicatorCSS", "indicatorClass", "requestClass", "inlineScriptNonce", "extensions", "implicitInheritance", "defaultTimeout", "mode", "defaultFocusScroll", "transitions", "morphIgnore", "morphSkip", "morphSkipChildren", From 5f62ef5f18871a5d9e72d7e688c14fd596839667 Mon Sep 17 00:00:00 2001 From: rameel Date: Mon, 31 Aug 2026 19:14:43 +0500 Subject: [PATCH 2/3] Rename property to AllowEmptySwapAfterOob --- src/Ramstack.HtmxToolkit/Configuration/HtmxV4Config.cs | 3 ++- .../TagHelpers/HtmxConfigTagHelperTests.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Ramstack.HtmxToolkit/Configuration/HtmxV4Config.cs b/src/Ramstack.HtmxToolkit/Configuration/HtmxV4Config.cs index 0df3e36..b910914 100644 --- a/src/Ramstack.HtmxToolkit/Configuration/HtmxV4Config.cs +++ b/src/Ramstack.HtmxToolkit/Configuration/HtmxV4Config.cs @@ -69,7 +69,8 @@ public HtmxSwap? DefaultSwap /// The HTMX default is and can be overridden /// using the swapEmpty modifier on hx-swap. /// - public bool? AllowEmptySwapAfterOOB + [JsonPropertyName("allowEmptySwapAfterOOB")] + public bool? AllowEmptySwapAfterOob { get; set => SetField(ref field, value); diff --git a/tests/Ramstack.HtmxToolkit.Tests/TagHelpers/HtmxConfigTagHelperTests.cs b/tests/Ramstack.HtmxToolkit.Tests/TagHelpers/HtmxConfigTagHelperTests.cs index e8d064e..3ff36d1 100644 --- a/tests/Ramstack.HtmxToolkit.Tests/TagHelpers/HtmxConfigTagHelperTests.cs +++ b/tests/Ramstack.HtmxToolkit.Tests/TagHelpers/HtmxConfigTagHelperTests.cs @@ -250,7 +250,7 @@ public async Task ProcessAsync_SerializesOnlyHtmx4Options() htmx.MetaCharacter = "-"; htmx.History = HtmxHistoryMode.Reload; htmx.DefaultSwap = HtmxSwap.OuterMorph; - htmx.AllowEmptySwapAfterOOB = true; + htmx.AllowEmptySwapAfterOob = true; htmx.DefaultSettleDelay = 1; htmx.IncludeIndicatorCss = false; htmx.IndicatorClass = "indicator"; From 4c95bca4945f76b6e4590483ee645c94613de148 Mon Sep 17 00:00:00 2001 From: rameel Date: Mon, 31 Aug 2026 20:40:50 +0500 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cdec1a5..d75e6ad 100644 --- a/README.md +++ b/README.md @@ -773,7 +773,7 @@ version explicitly. Each configuration type follows the names used by that HTMX and 2.x expose `DefaultSwapStyle` and `Timeout`, while HTMX 4.x exposes `DefaultSwap` and `DefaultTimeout`. Selecting different versions in the same configuration throws an exception. -HTMX 4.x is currently in beta. To target it, select it explicitly: +To target HTMX 4.x, select it explicitly: ```csharp builder.Services.AddHtmxToolkit(options => options.UseHtmxV4());