Skip to content

Commit 75130da

Browse files
feat(Link): add Rel parameter #4437 (#4438)
* feat(Link): 添加 Rel 属性参数 #4437 * refactor: 代码格式化 * test: 更新单元测试 --------- Co-authored-by: Argo-AsicoTech <[email protected]>
1 parent 51be23d commit 75130da

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
@namespace BootstrapBlazor.Components
22
@inherits BootstrapComponentBase
33

4-
<link @attributes="AdditionalAttributes" href="@GetHref()" rel="stylesheet" />
4+
<link @attributes="AdditionalAttributes" href="@GetHref()" rel="@Rel" />

src/BootstrapBlazor/Components/HtmlTag/Link.razor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ public partial class Link
1616
[EditorRequired]
1717
public string? Href { get; set; }
1818

19+
/// <summary>
20+
/// 获得/设置 Rel 属性值, 默认 stylesheet
21+
/// </summary>
22+
[Parameter]
23+
public string? Rel { get; set; } = "stylesheet";
24+
1925
/// <summary>
2026
/// 获得/设置 版本号 默认 null 自动生成
2127
/// </summary>

test/UnitTest/Components/LinkTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ public void Link_Ok()
1212
var cut = Context.RenderComponent<Link>(pb =>
1313
{
1414
pb.Add(a => a.Href, "http://www.blazor.zone");
15+
pb.Add(a => a.Rel, "stylesheet-test");
1516
});
1617
var versionService = cut.Services.GetRequiredService<IVersionService>();
17-
Assert.Equal($"<link href=\"http://www.blazor.zone?v={versionService.GetVersion()}\" rel=\"stylesheet\" />", cut.Markup);
18+
Assert.Equal($"<link href=\"http://www.blazor.zone?v={versionService.GetVersion()}\" rel=\"stylesheet-test\" />", cut.Markup);
1819
}
1920

2021
[Fact]

0 commit comments

Comments
 (0)