Skip to content

Commit 59792eb

Browse files
committed
Merge remote-tracking branch 'origin/main' into v2
# Conflicts: # src/bunit.core/Rendering/TestRenderer.cs # tests/bunit.web.tests/Rendering/RenderedComponentTest.cs # version.json
2 parents 6032323 + c983169 commit 59792eb

File tree

8 files changed

+67
-40
lines changed

8 files changed

+67
-40
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ All notable changes to **bUnit** will be documented in this file. The project ad
66

77
## [Unreleased]
88

9+
## [1.39.5] - 2025-04-04
10+
911
### Fixed
1012

1113
- Do not set the `Uri` or `BaseUri` property on the `FakeNavigationManager` if navigation is prevented by a handler on `net7.0` or greater. Reported and fixed by [@ayyron-dev](https://github.com/ayyron-dev) in [#1647](https://github.com/bUnit-dev/bUnit/issues/1647)
14+
- Use default renderer properties for AngleSharp. Reported by [@jtleaming](https://github.com/jtleaming) in [#1692].
15+
- `FindComponents` throws an exception, when a base and derived class was searched for. Reported by [@BlueDragon709](https://github.com/BlueDragon709) in [#1691].
1216

1317
## [1.38.5] - 2025-01-12
1418

@@ -1443,7 +1447,8 @@ The latest version of the library is availble on NuGet:
14431447
- **Wrong casing on keyboard event dispatch helpers.**
14441448
The helper methods for the keyboard events was not probably cased, so that has been updated. E.g. from `Keypress(...)` to `KeyPress(...)`.
14451449

1446-
[unreleased]: https://github.com/bUnit-dev/bUnit/compare/v1.38.5...HEAD
1450+
[unreleased]: https://github.com/bUnit-dev/bUnit/compare/v1.39.5...HEAD
1451+
[1.39.5]: https://github.com/bUnit-dev/bUnit/compare/v1.38.5...1.39.5
14471452
[1.38.5]: https://github.com/bUnit-dev/bUnit/compare/v1.37.7...v1.38.5
14481453
[1.37.7]: https://github.com/bUnit-dev/bUnit/compare/v1.36.0...1.37.7
14491454
[1.36.0]: https://github.com/bUnit-dev/bUnit/compare/v1.35.3...v1.36.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ A huge thank you to the [sponsors of bUnit](https://github.com/sponsors/egil). T
3636
<table border="0">
3737
<tr>
3838
<td align="center" width="120">
39-
<a href="https://github.com/syncfusion">
39+
<a href="https://www.syncfusion.com/blazor-components?utm_source=bunit&utm_medium=cpc&utm_campaign=bunit_blazor_bancy25">
4040
<img class="avatar" src="https://avatars.githubusercontent.com/u/1699795?s=460" width="72" height="72" alt="@syncfusion" />
4141
<br />
4242
Syncfusion

docs/site/docs/verification/semantic-html-comparison.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Here are the customization options you have available to you:
105105
```html
106106
<header>
107107
<h1 id="head-1" diff:ignoreCase>HeLLo <em>world</em></h1>
108-
</header
108+
</header>
109109
```
110110

111111
To perform case insensitive comparison of the text inside the `id` attribute, do the following:

docs/site/index.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,16 @@ bUnit is available on NuGet in various incarnations. Most users should just pick
5353
A huge thank you to the [sponsors of bUnit](https://github.com/sponsors/egil). The higher tier sponsors are:
5454

5555
<div class="d-flex flex-row mb-3">
56-
<a href="https://github.com/syncfusion" class="d-block p-3 text-center">
56+
<a href="https://www.syncfusion.com/blazor-components?utm_source=bunit&utm_medium=cpc&utm_campaign=bunit_blazor_bancy25" class="d-block p-3 text-center">
5757
<img class="avatar avatar rounded-circle" src="https://avatars.githubusercontent.com/u/1699795?s=460" width="72" height="72" alt="@syncfusion" />
5858
<br />
5959
Syncfusion
6060
</a>
61+
<a href="https://github.com/JetBrainsOfficial" class="d-block p-3 text-center">
62+
<img class="avatar avatar rounded-circle" src="https://avatars.githubusercontent.com/u/60931315?v=4" width="72" height="72" alt="@JetBrainsOfficial" />
63+
<br />
64+
JetBrains
65+
</a>
6166
</div>
6267

6368
## Contributors

src/bunit/Rendering/BunitHtmlParser.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections;
22
using System.Diagnostics;
33
using AngleSharp;
4+
using AngleSharp.Css;
45
using AngleSharp.Dom;
56
using AngleSharp.Html.Parser;
67
using Bunit.Diffing;
@@ -28,7 +29,8 @@ public sealed class BunitHtmlParser : IDisposable
2829
/// with a AngleSharp context without a <see cref="BunitRenderer"/> registered.
2930
/// </summary>
3031
public BunitHtmlParser()
31-
: this(Configuration.Default.WithCss().With(new HtmlComparer())) { }
32+
: this(Configuration.Default.WithCss()
33+
.With(new HtmlComparer())) { }
3234

3335
/// <summary>
3436
/// Initializes a new instance of the <see cref="BunitHtmlParser"/> class
@@ -43,7 +45,13 @@ public BunitHtmlParser(HtmlComparer htmlComparer, BunitContext bunitContext)
4345

4446
private BunitHtmlParser(IConfiguration angleSharpConfiguration)
4547
{
46-
var config = angleSharpConfiguration.With(this);
48+
var config = angleSharpConfiguration
49+
.With(this)
50+
.WithRenderDevice(new DefaultRenderDevice
51+
{
52+
ViewPortWidth = 1920,
53+
ViewPortHeight = 1080,
54+
});
4755
context = BrowsingContext.New(config);
4856
var parseOptions = new HtmlParserOptions
4957
{

src/bunit/Rendering/BunitRenderer.cs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -634,40 +634,6 @@ private IRenderedComponent<TComponent> GetRenderedComponent<TComponent>(int comp
634634
return (IRenderedComponent<TComponent>)result;
635635
}
636636

637-
/// <summary>
638-
/// Populates the <paramref name="framesCollection"/> with <see cref="ArrayRange{RenderTreeFrame}"/>
639-
/// starting with the one that belongs to the component with ID <paramref name="componentId"/>.
640-
/// </summary>
641-
private void LoadRenderTreeFrames(int componentId, RenderTreeFrameDictionary framesCollection)
642-
{
643-
var frames = GetOrLoadRenderTreeFrame(framesCollection, componentId);
644-
645-
for (var i = 0; i < frames.Count; i++)
646-
{
647-
ref var frame = ref frames.Array[i];
648-
649-
if (frame.FrameType == RenderTreeFrameType.Component && !framesCollection.Contains(frame.ComponentId))
650-
{
651-
LoadRenderTreeFrames(frame.ComponentId, framesCollection);
652-
}
653-
}
654-
}
655-
656-
/// <summary>
657-
/// Gets the <see cref="ArrayRange{RenderTreeFrame}"/> from the <paramref name="framesCollection"/>.
658-
/// If the <paramref name="framesCollection"/> does not contain the frames, they are loaded into it first.
659-
/// </summary>
660-
private ArrayRange<RenderTreeFrame> GetOrLoadRenderTreeFrame(RenderTreeFrameDictionary framesCollection, int componentId)
661-
{
662-
if (!framesCollection.TryGetValue(componentId, out var frames))
663-
{
664-
frames = GetCurrentRenderTreeFrames(componentId);
665-
framesCollection.Add(componentId, frames);
666-
}
667-
668-
return frames;
669-
}
670-
671637
/// <inheritdoc/>
672638
protected override void HandleException(Exception exception)
673639
{
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<div class="my-component" style="width: 5%">
2+
</div>

tests/bunit.tests/Rendering/RenderedComponentTest.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using AngleSharp.Dom;
12
using Bunit.Rendering;
23

34
namespace Bunit;
@@ -219,4 +220,44 @@ public void Test022()
219220

220221
Should.Throw<ComponentDisposedException>(() => target.Markup);
221222
}
223+
224+
[Fact(DisplayName = "Searching first for derived component and then base component finds correct (#1691)")]
225+
public void Test023()
226+
{
227+
var cut = Render<Wrapper>(
228+
ps => ps.AddChildContent<BaseComponent>()
229+
.AddChildContent<DerivedComponent>());
230+
231+
Should.NotThrow(() =>
232+
{
233+
cut.FindComponents<BaseComponent>();
234+
cut.FindComponents<DerivedComponent>();
235+
});
236+
}
237+
238+
[Fact(DisplayName = "Using relative units in style attribute can be retrieved")]
239+
public void Test024()
240+
{
241+
var cut = Render<ComponentWithRelativeUnitAsWidth>();
242+
243+
var text = cut.Find(".my-component").GetInnerText();
244+
245+
text.ShouldNotBeNull();
246+
}
247+
248+
private class BaseComponent : ComponentBase
249+
{
250+
protected override void BuildRenderTree(RenderTreeBuilder builder)
251+
{
252+
builder.AddContent(0, "base");
253+
}
254+
}
255+
256+
private sealed class DerivedComponent : BaseComponent
257+
{
258+
protected override void BuildRenderTree(RenderTreeBuilder builder)
259+
{
260+
builder.AddContent(0, "derived");
261+
}
262+
}
222263
}

0 commit comments

Comments
 (0)