Skip to content

Commit 0ab2a1e

Browse files
authored
Fix an assumption in ComponentBindLoweringPass (dotnet/razor#212)
\n\nCommit migrated from dotnet/razor@315f804
1 parent 67ef6b7 commit 0ab2a1e

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -507,15 +507,19 @@ private static IntermediateToken GetAttributeContent(TagHelperPropertyIntermedia
507507
return GetToken(node);
508508
}
509509

510-
// In error cases we won't have a single token, but we still want to generate the code.
511510
IntermediateToken GetToken(IntermediateNode parent)
512511
{
513-
return
514-
parent.Children.Count == 1 ? (IntermediateToken)parent.Children[0] : new IntermediateToken()
515-
{
516-
Kind = TokenKind.CSharp,
517-
Content = string.Join(string.Empty, parent.Children.OfType<IntermediateToken>().Select(t => t.Content)),
518-
};
512+
if (parent.Children.Count == 1 && parent.Children[0] is IntermediateToken token)
513+
{
514+
return token;
515+
}
516+
517+
// In error cases we won't have a single token, but we still want to generate the code.
518+
return new IntermediateToken()
519+
{
520+
Kind = TokenKind.CSharp,
521+
Content = string.Join(string.Empty, parent.Children.OfType<IntermediateToken>().Select(t => t.Content)),
522+
};
519523
}
520524
}
521525
}

0 commit comments

Comments
 (0)