Skip to content

Commit

Permalink
Re-enable markup frame type support
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamescaper committed Oct 10, 2023
1 parent ae2b22e commit ab45e10
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/BlazorBindings.Core/NativeComponentAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,15 @@ private int ApplyPrependFrame(
{
if (!string.IsNullOrWhiteSpace(frame.MarkupContent))
{
throw new NotImplementedException($"Not supported frame type: {frame.FrameType}");
if (_targetElement is IHandleChildContentText handleChildContentText)
{
handleChildContentText.HandleText(siblingIndex, frame.MarkupContent);
}
else
{
var typeName = _targetElement?.TargetElement?.GetType()?.Name;
throw new NotImplementedException($"Element {typeName} does not support text content: " + frame.MarkupContent);
}
}
// We don't need any adapter for Markup frames, but we care about frame position, therefore we simply insert null here.
Children.Insert(siblingIndex, null);
Expand Down
17 changes: 14 additions & 3 deletions src/BlazorBindings.UnitTests/Elements/LabelTests.razor
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
Assert.That(label.Text, Is.EqualTo("345"));
}

[Test]
public async Task AddLabelWithMarkupContent()
{
var label = await Render<MC.Label>(
@<Label TextColor="Colors.White">
345
</Label>);

Assert.That(label.Text, Is.EqualTo("345"));
}

[Test]
public async Task AddLabelWithDynamicTextContent()
{
Expand Down Expand Up @@ -66,9 +77,9 @@
<Span>1</Span>
<Span>2</Span>
@if (insertSpan)
{
<Span>10</Span>
}
{
<Span>10</Span>
}
<Span>3</Span>
</Label>
);
Expand Down

0 comments on commit ab45e10

Please sign in to comment.