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()); diff --git a/src/Ramstack.HtmxToolkit/Configuration/HtmxV4Config.cs b/src/Ramstack.HtmxToolkit/Configuration/HtmxV4Config.cs index 02d5eae..b910914 100644 --- a/src/Ramstack.HtmxToolkit/Configuration/HtmxV4Config.cs +++ b/src/Ramstack.HtmxToolkit/Configuration/HtmxV4Config.cs @@ -63,10 +63,14 @@ 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 + [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 5eef6ab..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.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",