Skip to content

Commit

Permalink
Simplify property setting
Browse files Browse the repository at this point in the history
  • Loading branch information
tanczosm committed Jan 30, 2024
1 parent 413d468 commit bbc37a5
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/Htmxor/Http/HtmxResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ private void MergeTrigger(string headerKey, string eventName, object? detail = n
{
var detailNode = JsonSerializer.SerializeToNode(detail, _serializerOptions);

if (!json.TryAdd(eventName, detailNode ?? JsonValue.Create(string.Empty)))
json[eventName] = detailNode ?? JsonValue.Create(string.Empty);
json[eventName] = detailNode ?? JsonValue.Create(string.Empty);

_headers[headerKey] = json.ToJsonString(_serializerOptions);
}
Expand Down Expand Up @@ -221,8 +220,7 @@ private void MergeTrigger(string headerKey, string eventName, object? detail = n
{
var clone = property.Value?.DeepClone();

if (!json.TryAdd(property.Key, clone))
json[property.Key] = clone;
json[property.Key] = clone;
}
}
else
Expand All @@ -232,8 +230,7 @@ private void MergeTrigger(string headerKey, string eventName, object? detail = n

// Merge all events into the json object
foreach (var eventName in eventNames)
if (!json.TryAdd(eventName, JsonValue.Create(string.Empty)))
json[eventName] = JsonValue.Create(string.Empty);
json[eventName] = JsonValue.Create(string.Empty);
}
}

Expand Down

0 comments on commit bbc37a5

Please sign in to comment.