Fix mistake in array index

This commit is contained in:
flash2048 2018-04-05 08:38:22 +03:00 committed by Steve Sanderson
parent a82fd5099e
commit 3369208c28
2 changed files with 22 additions and 1 deletions

View File

@ -281,7 +281,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor
var segments = attributeName.Split('-');
for (var i = 0; i < segments.Length; i++)
{
if (string.IsNullOrEmpty(segments[0]))
if (string.IsNullOrEmpty(segments[i]))
{
return false;
}

View File

@ -486,5 +486,26 @@ namespace Test
frame => AssertFrame.Whitespace(frame, 6),
frame => AssertFrame.Whitespace(frame, 7));
}
[Fact]
public void Render_Bind_With_IncorrectAttributeNames()
{
//more than 3 parts
Assert.Throws<InvalidOperationException>(() => CompileToComponent(@"
@addTagHelper *, TestAssembly
<input type=""text"" bind-first-second-third=""Text"" />
@functions {
public string Text { get; set; } = ""text"";
}"));
//ends with '-'
Assert.Throws<InvalidOperationException>(() => CompileToComponent(@"
@addTagHelper *, TestAssembly
<input type=""text"" bind-first-=""Text"" />
@functions {
public string Text { get; set; } = ""text"";
}"));
}
}
}