Update components E2E test to use splatting (#11518)
This test was already in place, and just needs some updates to work with Razor syntax instead of .cs
This commit is contained in:
parent
eba671ec88
commit
550710f304
|
|
@ -7,18 +7,12 @@
|
|||
|
||||
<div id="duplicate-on-element-override">
|
||||
<DuplicateAttributesOnElementChildComponent
|
||||
BoolAttributeBefore="true"
|
||||
StringAttributeBefore="original-text"
|
||||
UnmatchedValues="@elementValues"
|
||||
BoolAttributeAfter="false"
|
||||
StringAttributeAfter="other-text" />
|
||||
</div>
|
||||
|
||||
@functions {
|
||||
void SomeMethod()
|
||||
{
|
||||
}
|
||||
|
||||
Dictionary<string, object> elementValues = new Dictionary<string, object>()
|
||||
{
|
||||
{ "bool", true },
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.RenderTree;
|
||||
|
||||
namespace BasicTestApp
|
||||
{
|
||||
// Written in C# for flexibility and because we don't currently have the ability to write this in .razor.
|
||||
public class DuplicateAttributesOnElementChildComponent : ComponentBase
|
||||
{
|
||||
[Parameter] public string StringAttributeBefore { get; private set; }
|
||||
[Parameter] public bool BoolAttributeBefore { get; private set; }
|
||||
[Parameter] public string StringAttributeAfter { get; private set; }
|
||||
[Parameter] public bool? BoolAttributeAfter { get; private set; }
|
||||
|
||||
[Parameter(CaptureUnmatchedValues = true)] public Dictionary<string, object> UnmatchedValues { get; private set; }
|
||||
|
||||
protected override void BuildRenderTree(RenderTreeBuilder builder)
|
||||
{
|
||||
builder.OpenElement(0, "div");
|
||||
builder.AddAttribute(1, "string", StringAttributeBefore);
|
||||
builder.AddAttribute(2, "bool", BoolAttributeBefore);
|
||||
builder.AddMultipleAttributes(3, UnmatchedValues);
|
||||
if (StringAttributeAfter != null)
|
||||
{
|
||||
builder.AddAttribute(4, "string", StringAttributeAfter);
|
||||
}
|
||||
if (BoolAttributeAfter != null)
|
||||
{
|
||||
builder.AddAttribute(5, "bool", BoolAttributeAfter);
|
||||
}
|
||||
builder.CloseElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
@if (StringAttributeBefore != null)
|
||||
{
|
||||
<div string="@StringAttributeBefore"
|
||||
bool="@BoolAttributeBefore"
|
||||
@attributes="@UnmatchedValues">
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div @attributes="@UnmatchedValues"
|
||||
string="@StringAttributeAfter"
|
||||
bool="@BoolAttributeAfter">
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter] public string StringAttributeBefore { get; private set; }
|
||||
[Parameter] public bool BoolAttributeBefore { get; private set; }
|
||||
[Parameter] public string StringAttributeAfter { get; private set; }
|
||||
[Parameter] public bool? BoolAttributeAfter { get; private set; }
|
||||
|
||||
[Parameter(CaptureUnmatchedValues = true)] public Dictionary<string, object> UnmatchedValues { get; private set; }
|
||||
}
|
||||
Loading…
Reference in New Issue