parent
0c71f4f520
commit
cf6b1d7135
|
|
@ -221,7 +221,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
var tagName = startTag.GetTagName();
|
var tagName = startTag.GetTagName();
|
||||||
|
|
||||||
// Could not determine tag name, it can't be a TagHelper, continue on and track the element.
|
// Could not determine tag name, it can't be a TagHelper, continue on and track the element.
|
||||||
if (tagName == null)
|
if (tagName == null || tagName.StartsWith("!"))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -288,7 +288,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
rewritten = null;
|
rewritten = null;
|
||||||
var tagName = tagBlock.GetTagName();
|
var tagName = tagBlock.GetTagName();
|
||||||
// Could not determine tag name, it can't be a TagHelper, continue on and track the element.
|
// Could not determine tag name, it can't be a TagHelper, continue on and track the element.
|
||||||
if (tagName == null)
|
if (tagName == null || tagName.StartsWith("!"))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -243,15 +243,33 @@ namespace Microsoft.AspNetCore.Razor.Language.Syntax
|
||||||
throw new ArgumentNullException(nameof(tagBlock));
|
throw new ArgumentNullException(nameof(tagBlock));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tagBlock.Children.Count == 0 || !(tagBlock.Children[0] is MarkupTextLiteralSyntax childLiteral))
|
MarkupTextLiteralSyntax nameLiteral = null;
|
||||||
|
var isBangTag = false;
|
||||||
|
if (tagBlock.Children.Count > 0 && tagBlock.Children[0] is MarkupTextLiteralSyntax firstChild)
|
||||||
|
{
|
||||||
|
if (firstChild.GetContent().StartsWith("<") &&
|
||||||
|
tagBlock.Children.Count >= 3 &&
|
||||||
|
tagBlock.Children[1] is RazorMetaCodeSyntax &&
|
||||||
|
tagBlock.Children[2] is MarkupTextLiteralSyntax potentialBangTagName)
|
||||||
|
{
|
||||||
|
isBangTag = true;
|
||||||
|
nameLiteral = potentialBangTagName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nameLiteral = firstChild;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nameLiteral == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
SyntaxToken textToken = null;
|
SyntaxToken textToken = null;
|
||||||
for (var i = 0; i < childLiteral.LiteralTokens.Count; i++)
|
for (var i = 0; i < nameLiteral.LiteralTokens.Count; i++)
|
||||||
{
|
{
|
||||||
var token = childLiteral.LiteralTokens[i];
|
var token = nameLiteral.LiteralTokens[i];
|
||||||
|
|
||||||
if (token != null &&
|
if (token != null &&
|
||||||
(token.Kind == SyntaxKind.Whitespace || token.Kind == SyntaxKind.Text))
|
(token.Kind == SyntaxKind.Whitespace || token.Kind == SyntaxKind.Text))
|
||||||
|
|
@ -266,7 +284,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Syntax
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return textToken.Kind == SyntaxKind.Whitespace ? null : textToken.Content;
|
var name = textToken.Kind == SyntaxKind.Whitespace ? null : textToken.Content;
|
||||||
|
if (name != null && isBangTag)
|
||||||
|
{
|
||||||
|
name = "!" + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsSelfClosing(this MarkupTagBlockSyntax tagBlock)
|
public static bool IsSelfClosing(this MarkupTagBlockSyntax tagBlock)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue