egil / Htmxor

Supercharges Blazor static server side rendering (SSR) by seamlessly integrating the Htmx.org frontend library.
MIT License
109 stars 12 forks source link

Tweaks to swap style builder and related types #28

Closed egil closed 2 months ago

egil commented 2 months ago

These were the changes I was thinking about for your PR. See any issues with them @tanczosm?

tanczosm commented 2 months ago

HtmxResponse line 145:

    public HtmxResponse Reswap(string modifier)
    {
        if (string.IsNullOrWhiteSpace(modifier))
        {
            headers.Remove(HtmxResponseHeaderNames.Reswap);
        }
        else
        {
            headers[HtmxResponseHeaderNames.Reswap] = modifier;
        }

        return this;
    }

The remove aspect for headers is an undocumented side effect which I'm fine with adding but just augment the xmldoc. Also, on line 171 you call Reswap(modifier) in which modifier is nullable even though the parameter of that Reswap overload isn't nullable. Perhaps use either Reswap(modifier ?? string.Empty) or throw an exception. Being honest, I'm thinking if you call reswap with a SwapStyle.Default and no modifier then it's purely a mistake that would have no effect and might be worth alerting the developer via the thrown exception.

Also is AjaxContext impacted by this at all with the Swap property?

egil commented 2 months ago

Good point. Ill throw an argument null exception if modifier is null or whitespace.

As for AjaxContent, lets cover that in another PR.