Fix aspnet/AspNetCoredotnet/aspnetcore-tooling#6186
The issue here is that the compiler generates a different syntax tree
for `data-` attributes :(. I've added a note to dotnet/aspnetcore-tooling#6112 to follow up on
the compiler behavior. We used to parse data- attributes differently for
components, but I really don't think having the compiler special case
them makes sense.
For now I've added a workaround here to lower `data-` attributes in a
fashion similar to other dynamic attribute values.
\n\nCommit migrated from f5109fbfec
This commit is contained in:
parent
7f3a187455
commit
f973693438
|
|
@ -1348,6 +1348,22 @@ namespace Microsoft.AspNetCore.Razor.Language
|
||||||
// We need to capture this in the IR so that we can give each piece the correct source mappings
|
// We need to capture this in the IR so that we can give each piece the correct source mappings
|
||||||
public override void VisitCSharpExplicitExpression(CSharpExplicitExpressionSyntax node)
|
public override void VisitCSharpExplicitExpression(CSharpExplicitExpressionSyntax node)
|
||||||
{
|
{
|
||||||
|
if (_builder.Current is HtmlAttributeIntermediateNode)
|
||||||
|
{
|
||||||
|
// This can happen inside a data- attribute
|
||||||
|
_builder.Push(new CSharpExpressionAttributeValueIntermediateNode()
|
||||||
|
{
|
||||||
|
Prefix = string.Empty,
|
||||||
|
Source = this.BuildSourceSpanFromNode(node),
|
||||||
|
});
|
||||||
|
|
||||||
|
base.VisitCSharpExplicitExpression(node);
|
||||||
|
|
||||||
|
_builder.Pop();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_builder.Current is CSharpExpressionAttributeValueIntermediateNode)
|
if (_builder.Current is CSharpExpressionAttributeValueIntermediateNode)
|
||||||
{
|
{
|
||||||
base.VisitCSharpExplicitExpression(node);
|
base.VisitCSharpExplicitExpression(node);
|
||||||
|
|
@ -1385,6 +1401,22 @@ namespace Microsoft.AspNetCore.Razor.Language
|
||||||
|
|
||||||
public override void VisitCSharpImplicitExpression(CSharpImplicitExpressionSyntax node)
|
public override void VisitCSharpImplicitExpression(CSharpImplicitExpressionSyntax node)
|
||||||
{
|
{
|
||||||
|
if (_builder.Current is HtmlAttributeIntermediateNode)
|
||||||
|
{
|
||||||
|
// This can happen inside a data- attribute
|
||||||
|
_builder.Push(new CSharpExpressionAttributeValueIntermediateNode()
|
||||||
|
{
|
||||||
|
Prefix = string.Empty,
|
||||||
|
Source = this.BuildSourceSpanFromNode(node),
|
||||||
|
});
|
||||||
|
|
||||||
|
base.VisitCSharpImplicitExpression(node);
|
||||||
|
|
||||||
|
_builder.Pop();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_builder.Current is CSharpExpressionAttributeValueIntermediateNode)
|
if (_builder.Current is CSharpExpressionAttributeValueIntermediateNode)
|
||||||
{
|
{
|
||||||
base.VisitCSharpImplicitExpression(node);
|
base.VisitCSharpImplicitExpression(node);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue