Skip to content

Commit

Permalink
fix: use parents htmx context instead of injecting it again
Browse files Browse the repository at this point in the history
  • Loading branch information
egil committed May 6, 2024
1 parent 9b0f58c commit 326424e
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/Htmxor/Components/HtmxAsyncLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ namespace Htmxor.Components;
/// </summary>
public sealed class HtmxAsyncLoad : ConditionalComponentBase
{
[Inject]
private HtmxContext HtmxContext { get; set; } = default!;

[SuppressMessage("Usage", "CA2227:Collection properties should be read only", Justification = "False positive. This is a parameter.")]
[Parameter(CaptureUnmatchedValues = true)]
public IDictionary<string, object>? AdditionalAttributes { get; set; }
Expand Down Expand Up @@ -63,12 +60,12 @@ protected override void OnParametersSet()

protected override void BuildRenderTree([NotNull] RenderTreeBuilder builder)
{
var request = HtmxContext.Request;
var request = Context.Request;
builder.OpenElement(1, Element);
builder.AddAttribute(2, Constants.Attributes.Id, Id);
if (request.RoutingMode == RoutingMode.Standard)
{
builder.AddAttribute(3, Constants.Attributes.HxGet, HtmxContext.Request.Path);
builder.AddAttribute(3, Constants.Attributes.HxGet, request.Path);
builder.AddAttribute(4, Constants.Attributes.HxTrigger, Constants.Triggers.Load);
builder.AddAttribute(5, Constants.Attributes.HxTarget, $"#{Id}");
builder.AddAttribute(6, Constants.Attributes.HxSwap, Constants.SwapStyles.OuterHTML);
Expand Down

0 comments on commit 326424e

Please sign in to comment.