diff --git a/docs/articles/migrate-to-v2.md b/docs/articles/migrate-to-v2.md index 6baa3be..931a336 100644 --- a/docs/articles/migrate-to-v2.md +++ b/docs/articles/migrate-to-v2.md @@ -475,6 +475,8 @@ These changes affect fewer applications: - `Location`, `Redirect`, `Reswap(string)`, `Retarget`, and `Reselect` throw `ArgumentException` for a `null` or empty value, and `Location(string, HtmxLocationOptions)` also throws for `null` options. In 1.x, an empty value produced an empty header. +- The `value` parameter of these methods was renamed: `Location(path)`, `Redirect(url)`, `Reswap(swap)`, + `Retarget(selector)`, and `Reselect(selector)`. Update calls that pass it as a named argument. - Generated JSON in attributes keeps non-ASCII characters, such as Cyrillic, instead of escaping them as `\uXXXX`. Update snapshot tests that compare it as text. diff --git a/src/Ramstack.HtmxToolkit/HtmxResponse.cs b/src/Ramstack.HtmxToolkit/HtmxResponse.cs index dfc6296..91c547b 100644 --- a/src/Ramstack.HtmxToolkit/HtmxResponse.cs +++ b/src/Ramstack.HtmxToolkit/HtmxResponse.cs @@ -41,15 +41,15 @@ internal HtmxResponse(HttpResponse response) => /// Sets the HX-Location header to perform a client-side redirect /// without a full-page reload. /// - /// The path or serialized JSON options to assign to the header. + /// The path to request, or the serialized JSON options to assign to the header. /// /// The current instance. /// - public HtmxResponse Location(string value) + public HtmxResponse Location(string path) { - Argument.ThrowIfNullOrEmpty(value); + Argument.ThrowIfNullOrEmpty(path); - return SetHeader(this, HtmxResponseHeaderNames.Location, value); + return SetHeader(this, HtmxResponseHeaderNames.Location, path); } /// @@ -162,15 +162,15 @@ public HtmxResponse PreventHistoryUpdate() => /// /// Sets the HX-Redirect header to perform a client-side redirect with a full-page reload. /// - /// The URL to redirect to. + /// The URL to redirect to. /// /// The current instance. /// - public HtmxResponse Redirect(string value) + public HtmxResponse Redirect(string url) { - Argument.ThrowIfNullOrEmpty(value); + Argument.ThrowIfNullOrEmpty(url); - return SetHeader(this, HtmxResponseHeaderNames.Redirect, value); + return SetHeader(this, HtmxResponseHeaderNames.Redirect, url); } /// @@ -185,54 +185,54 @@ public HtmxResponse Refresh() => /// /// Sets the HX-Reswap header to specify how the response will be swapped. /// - /// The swap style to assign to the header. + /// The swap style to assign to the header. /// /// The current instance. /// - public HtmxResponse Reswap(HtmxSwap value) => - SetHeader(this, HtmxResponseHeaderNames.Reswap, value.GetSwapValue()); + public HtmxResponse Reswap(HtmxSwap swap) => + SetHeader(this, HtmxResponseHeaderNames.Reswap, swap.GetSwapValue()); /// /// Sets the HX-Reswap header to specify how the response will be swapped. /// - /// The swap style, optionally followed by swap modifiers. + /// The swap style, optionally followed by swap modifiers. /// /// The current instance. /// - public HtmxResponse Reswap(string value) + public HtmxResponse Reswap(string swap) { - Argument.ThrowIfNullOrEmpty(value); + Argument.ThrowIfNullOrEmpty(swap); - return SetHeader(this, HtmxResponseHeaderNames.Reswap, value); + return SetHeader(this, HtmxResponseHeaderNames.Reswap, swap); } /// /// Sets the HX-Retarget header to change the target of the content update /// to a different element on the page. /// - /// The CSS selector to assign to the header. + /// The CSS selector to assign to the header. /// /// The current instance. /// - public HtmxResponse Retarget(string value) + public HtmxResponse Retarget(string selector) { - Argument.ThrowIfNullOrEmpty(value); + Argument.ThrowIfNullOrEmpty(selector); - return SetHeader(this, HtmxResponseHeaderNames.Retarget, value); + return SetHeader(this, HtmxResponseHeaderNames.Retarget, selector); } /// /// Sets the HX-Reselect header to select the part of the response to swap in. /// - /// The CSS selector to assign to the header. + /// The CSS selector to assign to the header. /// /// The current instance. /// - public HtmxResponse Reselect(string value) + public HtmxResponse Reselect(string selector) { - Argument.ThrowIfNullOrEmpty(value); + Argument.ThrowIfNullOrEmpty(selector); - return SetHeader(this, HtmxResponseHeaderNames.Reselect, value); + return SetHeader(this, HtmxResponseHeaderNames.Reselect, selector); } ///