Merge branch 'release/2.2'
This commit is contained in:
commit
aedb05e5b6
|
|
@ -221,8 +221,7 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var stringValue = entry as string;
|
if (entry is string stringValue)
|
||||||
if (stringValue != null)
|
|
||||||
{
|
{
|
||||||
encoder.Encode(writer, stringValue);
|
encoder.Encode(writer, stringValue);
|
||||||
}
|
}
|
||||||
|
|
@ -239,13 +238,11 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string entryAsString;
|
if (entry is string entryAsString)
|
||||||
IHtmlContentContainer entryAsContainer;
|
|
||||||
if ((entryAsString = entry as string) != null)
|
|
||||||
{
|
{
|
||||||
destination.Append(entryAsString);
|
destination.Append(entryAsString);
|
||||||
}
|
}
|
||||||
else if ((entryAsContainer = entry as IHtmlContentContainer) != null)
|
else if (entry is IHtmlContentContainer entryAsContainer)
|
||||||
{
|
{
|
||||||
entryAsContainer.CopyTo(destination);
|
entryAsContainer.CopyTo(destination);
|
||||||
}
|
}
|
||||||
|
|
@ -262,13 +259,11 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string entryAsString;
|
if (entry is string entryAsString)
|
||||||
IHtmlContentContainer entryAsContainer;
|
|
||||||
if ((entryAsString = entry as string) != null)
|
|
||||||
{
|
{
|
||||||
destination.Append(entryAsString);
|
destination.Append(entryAsString);
|
||||||
}
|
}
|
||||||
else if ((entryAsContainer = entry as IHtmlContentContainer) != null)
|
else if (entry is IHtmlContentContainer entryAsContainer)
|
||||||
{
|
{
|
||||||
entryAsContainer.MoveTo(destination);
|
entryAsContainer.MoveTo(destination);
|
||||||
}
|
}
|
||||||
|
|
@ -282,29 +277,19 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers
|
||||||
{
|
{
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
{
|
{
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var stringValue = entry as string;
|
if (entry is string stringValue)
|
||||||
if (stringValue != null)
|
|
||||||
{
|
{
|
||||||
// Do not encode the string because encoded value remains whitespace from user's POV.
|
// Do not encode the string because encoded value remains whitespace from user's POV.
|
||||||
if (!string.IsNullOrWhiteSpace(stringValue))
|
return string.IsNullOrWhiteSpace(stringValue);
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Use NullHtmlEncoder to avoid treating encoded whitespace as non-whitespace e.g. "\t" as "	".
|
|
||||||
((IHtmlContent)entry).WriteTo(writer, NullHtmlEncoder.Default);
|
|
||||||
if (!writer.IsEmptyOrWhiteSpace)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
// Use NullHtmlEncoder to avoid treating encoded whitespace as non-whitespace e.g. "\t" as "	".
|
||||||
|
((IHtmlContent)entry).WriteTo(writer, NullHtmlEncoder.Default);
|
||||||
|
|
||||||
|
return writer.IsEmptyOrWhiteSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TagHelperContent AppendCore(object entry)
|
private TagHelperContent AppendCore(object entry)
|
||||||
|
|
@ -329,7 +314,7 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers
|
||||||
{
|
{
|
||||||
return GetContent();
|
return GetContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overrides Write(string) to find if the content written is empty/whitespace.
|
// Overrides Write(string) to find if the content written is empty/whitespace.
|
||||||
private class EmptyOrWhiteSpaceWriter : TextWriter
|
private class EmptyOrWhiteSpaceWriter : TextWriter
|
||||||
{
|
{
|
||||||
|
|
@ -360,4 +345,4 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -363,6 +363,7 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers
|
||||||
{
|
{
|
||||||
return new TheoryData<string>
|
return new TheoryData<string>
|
||||||
{
|
{
|
||||||
|
null,
|
||||||
string.Empty,
|
string.Empty,
|
||||||
" ",
|
" ",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
@ -838,4 +839,4 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue