React to aspnet/Razor#604
This commit is contained in:
parent
9ea5a939cf
commit
59334dcf17
|
|
@ -157,51 +157,52 @@ namespace Microsoft.AspNetCore.Mvc.Razor.TagHelpers
|
|||
throw new ArgumentNullException(nameof(output));
|
||||
}
|
||||
|
||||
IReadOnlyList<TagHelperAttribute> attributes;
|
||||
if (output.Attributes.TryGetAttributes(attributeName, out attributes))
|
||||
for (var i = 0; i < output.Attributes.Count; i++)
|
||||
{
|
||||
for (var i = 0; i < attributes.Count; i++)
|
||||
var attribute = output.Attributes[i];
|
||||
if (!string.Equals(attribute.Name, attributeName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var attribute = attributes[i];
|
||||
var stringValue = attribute.Value as string;
|
||||
if (stringValue != null)
|
||||
continue;
|
||||
}
|
||||
|
||||
var stringValue = attribute.Value as string;
|
||||
if (stringValue != null)
|
||||
{
|
||||
string resolvedUrl;
|
||||
if (TryResolveUrl(stringValue, resolvedUrl: out resolvedUrl))
|
||||
{
|
||||
string resolvedUrl;
|
||||
output.Attributes[i] = new TagHelperAttribute(attribute.Name, resolvedUrl);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var htmlContent = attribute.Value as IHtmlContent;
|
||||
if (htmlContent != null)
|
||||
{
|
||||
var htmlString = htmlContent as HtmlEncodedString;
|
||||
if (htmlString != null)
|
||||
{
|
||||
// No need for a StringWriter in this case.
|
||||
stringValue = htmlString.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var writer = new StringWriter())
|
||||
{
|
||||
htmlContent.WriteTo(writer, HtmlEncoder);
|
||||
stringValue = writer.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
IHtmlContent resolvedUrl;
|
||||
if (TryResolveUrl(stringValue, resolvedUrl: out resolvedUrl))
|
||||
{
|
||||
attribute.Value = resolvedUrl;
|
||||
output.Attributes[i] = new TagHelperAttribute(attribute.Name, resolvedUrl);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var htmlContent = attribute.Value as IHtmlContent;
|
||||
if (htmlContent != null)
|
||||
else if (htmlString == null)
|
||||
{
|
||||
var htmlString = htmlContent as HtmlEncodedString;
|
||||
if (htmlString != null)
|
||||
{
|
||||
// No need for a StringWriter in this case.
|
||||
stringValue = htmlString.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var writer = new StringWriter())
|
||||
{
|
||||
htmlContent.WriteTo(writer, HtmlEncoder);
|
||||
stringValue = writer.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
IHtmlContent resolvedUrl;
|
||||
if (TryResolveUrl(stringValue, resolvedUrl: out resolvedUrl))
|
||||
{
|
||||
attribute.Value = resolvedUrl;
|
||||
}
|
||||
else if (htmlString == null)
|
||||
{
|
||||
// Not a ~/ URL. Just avoid re-encoding the attribute value later.
|
||||
attribute.Value = new HtmlString(stringValue);
|
||||
}
|
||||
// Not a ~/ URL. Just avoid re-encoding the attribute value later.
|
||||
output.Attributes[i] = new TagHelperAttribute(attribute.Name, new HtmlString(stringValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
// not function properly.
|
||||
Src = output.Attributes[SrcAttributeName].Value as string;
|
||||
|
||||
output.Attributes[SrcAttributeName] = _fileVersionProvider.AddFileVersionToPath(Src);
|
||||
output.Attributes.SetAttribute(SrcAttributeName, _fileVersionProvider.AddFileVersionToPath(Src));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
// inputType may be more specific than default the generator chooses below.
|
||||
if (!output.Attributes.ContainsName("type"))
|
||||
{
|
||||
output.Attributes["type"] = inputType;
|
||||
output.Attributes.SetAttribute("type", inputType);
|
||||
}
|
||||
|
||||
TagBuilder tagBuilder;
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers.Internal
|
|||
// Perf: Avoid allocating enumerator
|
||||
for (var i = 0; i < requiredAttributes.Length; i++)
|
||||
{
|
||||
IReadOnlyTagHelperAttribute attribute;
|
||||
TagHelperAttribute attribute;
|
||||
if (!context.AllAttributes.TryGetAttribute(requiredAttributes[i], out attribute))
|
||||
{
|
||||
// Missing attribute.
|
||||
|
|
|
|||
|
|
@ -254,7 +254,10 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
|
||||
if (Href != null)
|
||||
{
|
||||
output.Attributes[HrefAttributeName].Value = _fileVersionProvider.AddFileVersionToPath(Href);
|
||||
var index = output.Attributes.IndexOfName(HrefAttributeName);
|
||||
output.Attributes[index] = new TagHelperAttribute(
|
||||
HrefAttributeName,
|
||||
_fileVersionProvider.AddFileVersionToPath(Href));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -303,7 +306,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
continue;
|
||||
}
|
||||
|
||||
attributes[HrefAttributeName] = url;
|
||||
attributes.SetAttribute(HrefAttributeName, url);
|
||||
BuildLinkTag(attributes, builder);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -217,7 +217,10 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
|
||||
if (Src != null)
|
||||
{
|
||||
output.Attributes[SrcAttributeName].Value = _fileVersionProvider.AddFileVersionToPath(Src);
|
||||
var index = output.Attributes.IndexOfName(SrcAttributeName);
|
||||
output.Attributes[index] = new TagHelperAttribute(
|
||||
SrcAttributeName,
|
||||
_fileVersionProvider.AddFileVersionToPath(Src));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -267,7 +270,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
continue;
|
||||
}
|
||||
|
||||
attributes[SrcAttributeName] = url;
|
||||
attributes.SetAttribute(SrcAttributeName, url);
|
||||
BuildScriptTag(attributes, builder);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
|
||||
if (tagHelperOutput.Attributes.TryGetAttribute("class", out classAttribute))
|
||||
{
|
||||
tagHelperOutput.Attributes["class"] = classAttribute.Value + " " + attribute.Value;
|
||||
tagHelperOutput.Attributes.SetAttribute("class", classAttribute.Value + " " + attribute.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -158,12 +158,10 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
TagHelperContext context)
|
||||
{
|
||||
var existingAttribute = context.AllAttributes[allAttributeIndex];
|
||||
var copiedAttribute = new TagHelperAttribute
|
||||
{
|
||||
Name = existingAttribute.Name,
|
||||
Value = existingAttribute.Value,
|
||||
Minimized = existingAttribute.Minimized
|
||||
};
|
||||
var copiedAttribute = new TagHelperAttribute(
|
||||
existingAttribute.Name,
|
||||
existingAttribute.Value,
|
||||
existingAttribute.Minimized);
|
||||
|
||||
// Move backwards through context.AllAttributes from the provided index until we find a familiar attribute
|
||||
// in tagHelperOutput where we can insert the copied value after the familiar one.
|
||||
|
|
|
|||
|
|
@ -978,7 +978,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
|||
page.EndAddHtmlAttributeValues(executionContext);
|
||||
|
||||
// Assert
|
||||
var htmlAttribute = Assert.Single(executionContext.HTMLAttributes);
|
||||
var htmlAttribute = Assert.Single(executionContext.HtmlAttributes);
|
||||
Assert.Equal("someattr", htmlAttribute.Name, StringComparer.Ordinal);
|
||||
var htmlContent = Assert.IsAssignableFrom<IHtmlContent>(htmlAttribute.Value);
|
||||
Assert.Equal(expectedValue, HtmlContentUtilities.HtmlContentToString(htmlContent), StringComparer.Ordinal);
|
||||
|
|
@ -1016,7 +1016,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
|||
page.EndAddHtmlAttributeValues(executionContext);
|
||||
|
||||
// Assert
|
||||
Assert.Empty(executionContext.HTMLAttributes);
|
||||
Assert.Empty(executionContext.HtmlAttributes);
|
||||
var attribute = Assert.Single(executionContext.AllAttributes);
|
||||
Assert.Equal("someattr", attribute.Name, StringComparer.Ordinal);
|
||||
Assert.Equal(expectedValue, (string)attribute.Value, StringComparer.Ordinal);
|
||||
|
|
@ -1044,7 +1044,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
|||
page.EndAddHtmlAttributeValues(executionContext);
|
||||
|
||||
// Assert
|
||||
var htmlAttribute = Assert.Single(executionContext.HTMLAttributes);
|
||||
var htmlAttribute = Assert.Single(executionContext.HtmlAttributes);
|
||||
Assert.Equal("someattr", htmlAttribute.Name, StringComparer.Ordinal);
|
||||
Assert.Equal("someattr", (string)htmlAttribute.Value, StringComparer.Ordinal);
|
||||
Assert.False(htmlAttribute.Minimized);
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.TagHelpers
|
|||
var tagHelper = new UrlResolutionTagHelper(urlHelperFactory.Object, new HtmlTestEncoder());
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
|
||||
|
|
@ -115,8 +115,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.TagHelpers
|
|||
var tagHelper = new UrlResolutionTagHelper(urlHelperFactory.Object, new HtmlTestEncoder());
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
|
||||
|
|
@ -170,8 +170,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.TagHelpers
|
|||
var tagHelper = new UrlResolutionTagHelper(urlHelperFactory.Object, new HtmlTestEncoder());
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
|
||||
|
|
@ -225,8 +225,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.TagHelpers
|
|||
var tagHelper = new UrlResolutionTagHelper(urlHelperFactory.Object, new HtmlTestEncoder());
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
|
||||
|
|
@ -255,8 +255,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.TagHelpers
|
|||
var tagHelper = new UrlResolutionTagHelper(urlHelperFactory: null, htmlEncoder: null);
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
|
||||
|
|
@ -300,8 +300,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.TagHelpers
|
|||
var tagHelper = new UrlResolutionTagHelper(urlHelperFactory.Object, new HtmlTestEncoder());
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
|
||||
|
|
|
|||
|
|
@ -92,8 +92,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
// Arrange
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
var output = new TagHelperOutput(
|
||||
|
|
@ -141,8 +141,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
// Arrange
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
var output = new TagHelperOutput(
|
||||
|
|
@ -225,8 +225,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
"'asp-fragment' attribute.";
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
|
||||
|
|
@ -260,8 +260,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
"'asp-route' must not have an 'asp-action' or 'asp-controller' attribute.";
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
|
||||
|
|
|
|||
|
|
@ -114,8 +114,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
var viewContext = CreateViewContext();
|
||||
var expectedAttribute = new TagHelperAttribute("method", method.ToString().ToLowerInvariant());
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(new List<IReadOnlyTagHelperAttribute> { expectedAttribute })),
|
||||
allAttributes: new TagHelperAttributeList(new[] { expectedAttribute }),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
var output = new TagHelperOutput(
|
||||
|
|
@ -167,8 +166,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
// Arrange
|
||||
var testViewContext = CreateViewContext();
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
var expectedAttribute = new TagHelperAttribute("asp-ROUTEE-NotRoute", "something");
|
||||
|
|
@ -239,8 +238,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
// Arrange
|
||||
var viewContext = CreateViewContext();
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
var output = new TagHelperOutput(
|
||||
|
|
@ -290,8 +289,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
// Arrange
|
||||
var viewContext = CreateViewContext();
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
var output = new TagHelperOutput(
|
||||
|
|
@ -371,8 +370,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
return Task.FromResult<TagHelperContent>(tagHelperContent);
|
||||
});
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
|
||||
|
|
@ -419,8 +418,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
"'asp-action' or 'asp-controller' or 'asp-route' attribute.";
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
|
||||
|
|
@ -450,8 +449,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
"'asp-route' must not have an 'asp-action' or 'asp-controller' attribute.";
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
|
||||
|
|
|
|||
|
|
@ -87,8 +87,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
"<input name=\"HtmlEncode[[IsACar]]\" type=\"HtmlEncode[[hidden]]\" value=\"HtmlEncode[[false]]\" />";
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
var output = new TagHelperOutput(
|
||||
|
|
@ -193,8 +193,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
var expectedTagName = "not-input";
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
var originalAttributes = new TagHelperAttributeList
|
||||
|
|
@ -257,8 +257,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
var expectedPostContent = "original post-content";
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
var originalAttributes = new TagHelperAttributeList
|
||||
|
|
@ -343,7 +343,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
};
|
||||
if (!string.IsNullOrEmpty(inputTypeName))
|
||||
{
|
||||
contextAttributes["type"] = inputTypeName; // Support restoration of type attribute, if any.
|
||||
contextAttributes.SetAttribute("type", inputTypeName); // Support restoration of type attribute, if any.
|
||||
}
|
||||
|
||||
var expectedAttributes = new TagHelperAttributeList
|
||||
|
|
@ -444,7 +444,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
};
|
||||
if (!string.IsNullOrEmpty(inputTypeName))
|
||||
{
|
||||
contextAttributes["type"] = inputTypeName; // Support restoration of type attribute, if any.
|
||||
contextAttributes.SetAttribute("type", inputTypeName); // Support restoration of type attribute, if any.
|
||||
}
|
||||
|
||||
var expectedAttributes = new TagHelperAttributeList
|
||||
|
|
@ -541,7 +541,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
};
|
||||
if (!string.IsNullOrEmpty(inputTypeName))
|
||||
{
|
||||
contextAttributes["type"] = inputTypeName; // Support restoration of type attribute, if any.
|
||||
contextAttributes.SetAttribute("type", inputTypeName); // Support restoration of type attribute, if any.
|
||||
}
|
||||
|
||||
var expectedAttributes = new TagHelperAttributeList
|
||||
|
|
@ -651,7 +651,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
};
|
||||
if (!string.IsNullOrEmpty(inputTypeName))
|
||||
{
|
||||
contextAttributes["type"] = inputTypeName; // Support restoration of type attribute, if any.
|
||||
contextAttributes.SetAttribute("type", inputTypeName); // Support restoration of type attribute, if any.
|
||||
}
|
||||
|
||||
var expectedAttributes = new TagHelperAttributeList
|
||||
|
|
@ -784,8 +784,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
var expectedTagName = "not-input";
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
|
||||
|
|
@ -868,8 +868,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
var expectedTagName = "not-input";
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers.Internal
|
|||
};
|
||||
var attributes = new TagHelperAttributeList
|
||||
{
|
||||
["first-attr"] = "value",
|
||||
["not-in-any-mode"] = "value"
|
||||
new TagHelperAttribute("first-attr", "value"),
|
||||
new TagHelperAttribute("not-in-any-mode", "value")
|
||||
};
|
||||
var context = MakeTagHelperContext(attributes);
|
||||
|
||||
|
|
@ -49,9 +49,9 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers.Internal
|
|||
};
|
||||
var attributes = new TagHelperAttributeList
|
||||
{
|
||||
["first-attr"] = "value",
|
||||
["second-attr"] = "value",
|
||||
["not-in-any-mode"] = "value"
|
||||
new TagHelperAttribute("first-attr", "value"),
|
||||
new TagHelperAttribute("second-attr", "value"),
|
||||
new TagHelperAttribute("not-in-any-mode", "value")
|
||||
};
|
||||
var context = MakeTagHelperContext(attributes);
|
||||
|
||||
|
|
@ -77,10 +77,10 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers.Internal
|
|||
};
|
||||
var attributes = new TagHelperAttributeList
|
||||
{
|
||||
["first-attr"] = "value",
|
||||
["second-attr"] = "value",
|
||||
["third-attr"] = "value",
|
||||
["not-in-any-mode"] = "value"
|
||||
new TagHelperAttribute("first-attr", "value"),
|
||||
new TagHelperAttribute("second-attr", "value"),
|
||||
new TagHelperAttribute("third-attr", "value"),
|
||||
new TagHelperAttribute("not-in-any-mode", "value")
|
||||
};
|
||||
var context = MakeTagHelperContext(attributes);
|
||||
|
||||
|
|
|
|||
|
|
@ -190,8 +190,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
var expectedPostContent = "original post-content";
|
||||
|
||||
var tagHelperContext = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
var htmlAttributes = new TagHelperAttributeList
|
||||
|
|
|
|||
|
|
@ -200,10 +200,10 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-fallback-href"] = "test.css",
|
||||
["asp-fallback-test-class"] = "hidden",
|
||||
["asp-fallback-test-property"] = "visibility",
|
||||
["asp-fallback-test-value"] = "hidden"
|
||||
new TagHelperAttribute("asp-fallback-href", "test.css"),
|
||||
new TagHelperAttribute("asp-fallback-test-class", "hidden"),
|
||||
new TagHelperAttribute("asp-fallback-test-property", "visibility"),
|
||||
new TagHelperAttribute("asp-fallback-test-value", "hidden")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -216,10 +216,10 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-fallback-href-include"] = "*.css",
|
||||
["asp-fallback-test-class"] = "hidden",
|
||||
["asp-fallback-test-property"] = "visibility",
|
||||
["asp-fallback-test-value"] = "hidden"
|
||||
new TagHelperAttribute("asp-fallback-href-include", "*.css"),
|
||||
new TagHelperAttribute("asp-fallback-test-class", "hidden"),
|
||||
new TagHelperAttribute("asp-fallback-test-property", "visibility"),
|
||||
new TagHelperAttribute("asp-fallback-test-value", "hidden")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -233,11 +233,11 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-fallback-href"] = "test.css",
|
||||
["asp-fallback-test-class"] = "hidden",
|
||||
["asp-fallback-test-property"] = "visibility",
|
||||
["asp-fallback-test-value"] = "hidden",
|
||||
["asp-append-version"] = "true"
|
||||
new TagHelperAttribute("asp-fallback-href", "test.css"),
|
||||
new TagHelperAttribute("asp-fallback-test-class", "hidden"),
|
||||
new TagHelperAttribute("asp-fallback-test-property", "visibility"),
|
||||
new TagHelperAttribute("asp-fallback-test-value", "hidden"),
|
||||
new TagHelperAttribute("asp-append-version", "true")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -251,11 +251,11 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-fallback-href-include"] = "*.css",
|
||||
["asp-fallback-test-class"] = "hidden",
|
||||
["asp-fallback-test-property"] = "visibility",
|
||||
["asp-fallback-test-value"] = "hidden",
|
||||
["asp-append-version"] = "true"
|
||||
new TagHelperAttribute("asp-fallback-href-include", "*.css"),
|
||||
new TagHelperAttribute("asp-fallback-test-class", "hidden"),
|
||||
new TagHelperAttribute("asp-fallback-test-property", "visibility"),
|
||||
new TagHelperAttribute("asp-fallback-test-value", "hidden"),
|
||||
new TagHelperAttribute("asp-append-version", "true")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -318,7 +318,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-href-include"] = "*.css"
|
||||
new TagHelperAttribute("asp-href-include", "*.css")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -328,8 +328,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-href-include"] = "*.css",
|
||||
["asp-href-exclude"] = "*.min.css"
|
||||
new TagHelperAttribute("asp-href-include", "*.css"),
|
||||
new TagHelperAttribute("asp-href-exclude", "*.min.css")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -340,8 +340,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-href-include"] = "*.css",
|
||||
["asp-append-version"] = "true"
|
||||
new TagHelperAttribute("asp-href-include", "*.css"),
|
||||
new TagHelperAttribute("asp-append-version", "true")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -352,9 +352,9 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-href-include"] = "*.css",
|
||||
["asp-href-exclude"] = "*.min.css",
|
||||
["asp-append-version"] = "true"
|
||||
new TagHelperAttribute("asp-href-include", "*.css"),
|
||||
new TagHelperAttribute("asp-href-exclude", "*.min.css"),
|
||||
new TagHelperAttribute("asp-append-version", "true")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -463,8 +463,9 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
// This is commented out on purpose: ["asp-href-include"] = "*.css",
|
||||
["asp-href-exclude"] = "*.min.css"
|
||||
// This is commented out on purpose: new TagHelperAttribute("asp-href-include", "*.css"),
|
||||
// Note asp-href-include attribute isn't included.
|
||||
new TagHelperAttribute("asp-href-exclude", "*.min.css")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -475,10 +476,11 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
// This is commented out on purpose: ["asp-fallback-href"] = "test.css",
|
||||
["asp-fallback-test-class"] = "hidden",
|
||||
["asp-fallback-test-property"] = "visibility",
|
||||
["asp-fallback-test-value"] = "hidden"
|
||||
// This is commented out on purpose: new TagHelperAttribute("asp-fallback-href", "test.css"),
|
||||
// Note asp-href-include attribute isn't included.
|
||||
new TagHelperAttribute("asp-fallback-test-class", "hidden"),
|
||||
new TagHelperAttribute("asp-fallback-test-property", "visibility"),
|
||||
new TagHelperAttribute("asp-fallback-test-value", "hidden")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -491,10 +493,11 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-fallback-href"] = "test.css",
|
||||
["asp-fallback-test-class"] = "hidden",
|
||||
// This is commented out on purpose: ["asp-fallback-test-property"] = "visibility",
|
||||
["asp-fallback-test-value"] = "hidden"
|
||||
new TagHelperAttribute("asp-fallback-href", "test.css"),
|
||||
new TagHelperAttribute("asp-fallback-test-class", "hidden"),
|
||||
// This is commented out on purpose: new TagHelperAttribute("asp-fallback-test-property", "visibility"),
|
||||
// Note asp-href-include attribute isn't included.
|
||||
new TagHelperAttribute("asp-fallback-test-value", "hidden")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -507,11 +510,11 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
// This is commented out on purpose: ["asp-fallback-href-include"] = "test.css",
|
||||
["asp-fallback-href-exclude"] = "**/*.min.css",
|
||||
["asp-fallback-test-class"] = "hidden",
|
||||
["asp-fallback-test-property"] = "visibility",
|
||||
["asp-fallback-test-value"] = "hidden"
|
||||
// This is commented out on purpose: new TagHelperAttribute("asp-fallback-href-include", "test.css"),
|
||||
new TagHelperAttribute("asp-fallback-href-exclude", "**/*.min.css"),
|
||||
new TagHelperAttribute("asp-fallback-test-class", "hidden"),
|
||||
new TagHelperAttribute("asp-fallback-test-property", "visibility"),
|
||||
new TagHelperAttribute("asp-fallback-test-value", "hidden")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -641,13 +644,13 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
var context = MakeTagHelperContext(
|
||||
attributes: new TagHelperAttributeList
|
||||
{
|
||||
["rel"] = "stylesheet",
|
||||
["href"] = "/css/site.css",
|
||||
["asp-href-include"] = "**/*.css"
|
||||
new TagHelperAttribute("rel", "stylesheet"),
|
||||
new TagHelperAttribute("href", "/css/site.css"),
|
||||
new TagHelperAttribute("asp-href-include", "**/*.css")
|
||||
});
|
||||
var output = MakeTagHelperOutput("link", attributes: new TagHelperAttributeList
|
||||
{
|
||||
["rel"] = "stylesheet",
|
||||
new TagHelperAttribute("rel", "stylesheet"),
|
||||
});
|
||||
var hostingEnvironment = MakeHostingEnvironment();
|
||||
var viewContext = MakeViewContext();
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
});
|
||||
|
||||
var tagHelperContext = new TagHelperContext(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>(),
|
||||
Enumerable.Empty<TagHelperAttribute>(),
|
||||
new Dictionary<object, object>(),
|
||||
"someId");
|
||||
|
||||
|
|
|
|||
|
|
@ -102,10 +102,10 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
outputAttributes.Concat(
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["data-extra"] = "something",
|
||||
["src"] = "/blank.js",
|
||||
["asp-fallback-src"] = "http://www.example.com/blank.js",
|
||||
["asp-fallback-test"] = "isavailable()",
|
||||
new TagHelperAttribute("data-extra", "something"),
|
||||
new TagHelperAttribute("src", "/blank.js"),
|
||||
new TagHelperAttribute("asp-fallback-src", "http://www.example.com/blank.js"),
|
||||
new TagHelperAttribute("asp-fallback-test", "isavailable()"),
|
||||
}));
|
||||
var tagHelperContext = MakeTagHelperContext(allAttributes);
|
||||
var viewContext = MakeViewContext();
|
||||
|
|
@ -149,8 +149,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-fallback-src"] = "test.js",
|
||||
["asp-fallback-test"] = "isavailable()"
|
||||
new TagHelperAttribute("asp-fallback-src", "test.js"),
|
||||
new TagHelperAttribute("asp-fallback-test", "isavailable()")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -161,8 +161,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-fallback-src-include"] = "*.js",
|
||||
["asp-fallback-test"] = "isavailable()"
|
||||
new TagHelperAttribute("asp-fallback-src-include", "*.js"),
|
||||
new TagHelperAttribute("asp-fallback-test", "isavailable()")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -173,9 +173,9 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-fallback-src"] = "test.js",
|
||||
["asp-fallback-src-include"] = "*.js",
|
||||
["asp-fallback-test"] = "isavailable()"
|
||||
new TagHelperAttribute("asp-fallback-src", "test.js"),
|
||||
new TagHelperAttribute("asp-fallback-src-include", "*.js"),
|
||||
new TagHelperAttribute("asp-fallback-test", "isavailable()")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -187,9 +187,9 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-fallback-src-include"] = "*.js",
|
||||
["asp-fallback-src-exclude"] = "*.min.js",
|
||||
["asp-fallback-test"] = "isavailable()"
|
||||
new TagHelperAttribute("asp-fallback-src-include", "*.js"),
|
||||
new TagHelperAttribute("asp-fallback-src-exclude", "*.min.js"),
|
||||
new TagHelperAttribute("asp-fallback-test", "isavailable()")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -202,9 +202,9 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-fallback-src"] = "test.js",
|
||||
["asp-fallback-test"] = "isavailable()",
|
||||
["asp-append-version"] = "true"
|
||||
new TagHelperAttribute("asp-fallback-src", "test.js"),
|
||||
new TagHelperAttribute("asp-fallback-test", "isavailable()"),
|
||||
new TagHelperAttribute("asp-append-version", "true")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -216,9 +216,9 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-fallback-src-include"] = "*.js",
|
||||
["asp-fallback-test"] = "isavailable()",
|
||||
["asp-append-version"] = "true"
|
||||
new TagHelperAttribute("asp-fallback-src-include", "*.js"),
|
||||
new TagHelperAttribute("asp-fallback-test", "isavailable()"),
|
||||
new TagHelperAttribute("asp-append-version", "true")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -230,10 +230,10 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-fallback-src"] = "test.js",
|
||||
["asp-fallback-src-include"] = "*.js",
|
||||
["asp-fallback-test"] = "isavailable()",
|
||||
["asp-append-version"] = "true"
|
||||
new TagHelperAttribute("asp-fallback-src", "test.js"),
|
||||
new TagHelperAttribute("asp-fallback-src-include", "*.js"),
|
||||
new TagHelperAttribute("asp-fallback-test", "isavailable()"),
|
||||
new TagHelperAttribute("asp-append-version", "true")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -246,10 +246,10 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-fallback-src-include"] = "*.js",
|
||||
["asp-fallback-src-exclude"] = "*.min.js",
|
||||
["asp-fallback-test"] = "isavailable()",
|
||||
["asp-append-version"] = "true"
|
||||
new TagHelperAttribute("asp-fallback-src-include", "*.js"),
|
||||
new TagHelperAttribute("asp-fallback-src-exclude", "*.min.js"),
|
||||
new TagHelperAttribute("asp-fallback-test", "isavailable()"),
|
||||
new TagHelperAttribute("asp-append-version", "true")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -311,7 +311,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-src-include"] = "*.js"
|
||||
new TagHelperAttribute("asp-src-include", "*.js")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -321,8 +321,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-src-include"] = "*.js",
|
||||
["asp-src-exclude"] = "*.min.js"
|
||||
new TagHelperAttribute("asp-src-include", "*.js"),
|
||||
new TagHelperAttribute("asp-src-exclude", "*.min.js")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -333,8 +333,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-src-include"] = "*.js",
|
||||
["asp-append-version"] = "true"
|
||||
new TagHelperAttribute("asp-src-include", "*.js"),
|
||||
new TagHelperAttribute("asp-append-version", "true")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -345,9 +345,9 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-src-include"] = "*.js",
|
||||
["asp-src-exclude"] = "*.min.js",
|
||||
["asp-append-version"] = "true"
|
||||
new TagHelperAttribute("asp-src-include", "*.js"),
|
||||
new TagHelperAttribute("asp-src-exclude", "*.min.js"),
|
||||
new TagHelperAttribute("asp-append-version", "true")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -408,8 +408,9 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
// This is commented out on purpose: ["asp-src-include"] = "*.js",
|
||||
["asp-src-exclude"] = "*.min.js"
|
||||
// This is commented out on purpose: new TagHelperAttribute("asp-src-include", "*.js"),
|
||||
// Note asp-src-include attribute isn't included.
|
||||
new TagHelperAttribute("asp-src-exclude", "*.min.js")
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -420,8 +421,9 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
// This is commented out on purpose: ["asp-fallback-src"] = "test.js",
|
||||
["asp-fallback-test"] = "isavailable()",
|
||||
// This is commented out on purpose: new TagHelperAttribute("asp-fallback-src", "test.js"),
|
||||
// Note asp-src-include attribute isn't included.
|
||||
new TagHelperAttribute("asp-fallback-test", "isavailable()"),
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -432,8 +434,9 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
["asp-fallback-src"] = "test.js",
|
||||
// This is commented out on purpose: ["asp-fallback-test"] = "isavailable()"
|
||||
new TagHelperAttribute("asp-fallback-src", "test.js"),
|
||||
// This is commented out on purpose: new TagHelperAttribute("asp-fallback-test", "isavailable()")
|
||||
// Note asp-src-include attribute isn't included.
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -444,9 +447,10 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
new TagHelperAttributeList
|
||||
{
|
||||
// This is commented out on purpose: ["asp-fallback-src-include"] = "test.js",
|
||||
["asp-fallback-src-exclude"] = "**/*.min.js",
|
||||
["asp-fallback-test"] = "isavailable()",
|
||||
// This is commented out on purpose: new TagHelperAttribute("asp-fallback-src-include", "test.js"),
|
||||
// Note asp-src-include attribute isn't included.
|
||||
new TagHelperAttribute("asp-fallback-src-exclude", "**/*.min.js"),
|
||||
new TagHelperAttribute("asp-fallback-test", "isavailable()"),
|
||||
},
|
||||
tagHelper =>
|
||||
{
|
||||
|
|
@ -528,11 +532,11 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
var tagHelperContext = MakeTagHelperContext(
|
||||
attributes: new TagHelperAttributeList
|
||||
{
|
||||
["data-extra"] = "something",
|
||||
["src"] = "/blank.js",
|
||||
["data-more"] = "else",
|
||||
["asp-fallback-src"] = "http://www.example.com/blank.js",
|
||||
["asp-fallback-test"] = "isavailable()",
|
||||
new TagHelperAttribute("data-extra", "something"),
|
||||
new TagHelperAttribute("src", "/blank.js"),
|
||||
new TagHelperAttribute("data-more", "else"),
|
||||
new TagHelperAttribute("asp-fallback-src", "http://www.example.com/blank.js"),
|
||||
new TagHelperAttribute("asp-fallback-test", "isavailable()"),
|
||||
});
|
||||
|
||||
var viewContext = MakeViewContext();
|
||||
|
|
@ -540,8 +544,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
var output = MakeTagHelperOutput("src",
|
||||
attributes: new TagHelperAttributeList
|
||||
{
|
||||
["data-extra"] = "something",
|
||||
["data-more"] = "else",
|
||||
new TagHelperAttribute("data-extra", "something"),
|
||||
new TagHelperAttribute("data-more", "else"),
|
||||
});
|
||||
|
||||
var hostingEnvironment = MakeHostingEnvironment();
|
||||
|
|
@ -575,8 +579,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
var context = MakeTagHelperContext(
|
||||
attributes: new TagHelperAttributeList
|
||||
{
|
||||
["src"] = "/js/site.js",
|
||||
["asp-src-include"] = "**/*.js"
|
||||
new TagHelperAttribute("src", "/js/site.js"),
|
||||
new TagHelperAttribute("asp-src-include", "**/*.js")
|
||||
});
|
||||
var output = MakeTagHelperOutput("script", attributes: new TagHelperAttributeList());
|
||||
var hostingEnvironment = MakeHostingEnvironment();
|
||||
|
|
@ -617,8 +621,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
var context = MakeTagHelperContext(
|
||||
attributes: new TagHelperAttributeList
|
||||
{
|
||||
["src"] = "/js/site.js",
|
||||
["asp-src-include"] = "**/*.js"
|
||||
new TagHelperAttribute("src", "/js/site.js"),
|
||||
new TagHelperAttribute("asp-src-include", "**/*.js")
|
||||
});
|
||||
var output = MakeTagHelperOutput("script", attributes: new TagHelperAttributeList());
|
||||
var hostingEnvironment = MakeHostingEnvironment();
|
||||
|
|
@ -659,8 +663,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
var context = MakeTagHelperContext(
|
||||
attributes: new TagHelperAttributeList
|
||||
{
|
||||
["src"] = "/js/site.js",
|
||||
["asp-append-version"] = "true"
|
||||
new TagHelperAttribute("src", "/js/site.js"),
|
||||
new TagHelperAttribute("asp-append-version", "true")
|
||||
});
|
||||
var output = MakeTagHelperOutput("script", attributes: new TagHelperAttributeList());
|
||||
|
||||
|
|
@ -694,8 +698,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
var context = MakeTagHelperContext(
|
||||
attributes: new TagHelperAttributeList
|
||||
{
|
||||
["src"] = "/bar/js/site.js",
|
||||
["asp-append-version"] = "true"
|
||||
new TagHelperAttribute("src", "/bar/js/site.js"),
|
||||
new TagHelperAttribute("asp-append-version", "true")
|
||||
});
|
||||
var output = MakeTagHelperOutput("script", attributes: new TagHelperAttributeList());
|
||||
var hostingEnvironment = MakeHostingEnvironment();
|
||||
|
|
@ -728,10 +732,10 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
var context = MakeTagHelperContext(
|
||||
attributes: new TagHelperAttributeList
|
||||
{
|
||||
["src"] = "/js/site.js",
|
||||
["asp-fallback-src-include"] = "fallback.js",
|
||||
["asp-fallback-test"] = "isavailable()",
|
||||
["asp-append-version"] = "true"
|
||||
new TagHelperAttribute("src", "/js/site.js"),
|
||||
new TagHelperAttribute("asp-fallback-src-include", "fallback.js"),
|
||||
new TagHelperAttribute("asp-fallback-test", "isavailable()"),
|
||||
new TagHelperAttribute("asp-append-version", "true")
|
||||
});
|
||||
var output = MakeTagHelperOutput("script", attributes: new TagHelperAttributeList());
|
||||
var hostingEnvironment = MakeHostingEnvironment();
|
||||
|
|
@ -769,9 +773,9 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
var context = MakeTagHelperContext(
|
||||
attributes: new TagHelperAttributeList
|
||||
{
|
||||
["src"] = "/js/site.js",
|
||||
["asp-src-include"] = "*.js",
|
||||
["asp-append-version"] = "true"
|
||||
new TagHelperAttribute("src", "/js/site.js"),
|
||||
new TagHelperAttribute("asp-src-include", "*.js"),
|
||||
new TagHelperAttribute("asp-append-version", "true")
|
||||
});
|
||||
var output = MakeTagHelperOutput("script", attributes: new TagHelperAttributeList());
|
||||
var hostingEnvironment = MakeHostingEnvironment();
|
||||
|
|
|
|||
|
|
@ -201,8 +201,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
var modelExpression = new ModelExpression(nameAndId.Name, modelExplorer);
|
||||
|
||||
var tagHelperContext = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
var output = new TagHelperOutput(
|
||||
|
|
@ -290,8 +290,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
var modelExpression = new ModelExpression(nameAndId.Name, modelExplorer);
|
||||
|
||||
var tagHelperContext = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
var output = new TagHelperOutput(
|
||||
|
|
@ -394,8 +394,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
var modelExpression = new ModelExpression(name: string.Empty, modelExplorer: modelExplorer);
|
||||
|
||||
var tagHelperContext = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
var output = new TagHelperOutput(
|
||||
|
|
@ -557,8 +557,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
bool allowMultiple)
|
||||
{
|
||||
// Arrange
|
||||
var contextAttributes = new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>());
|
||||
var contextAttributes = new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>());
|
||||
var originalAttributes = new TagHelperAttributeList();
|
||||
var propertyName = "Property1";
|
||||
var tagName = "select";
|
||||
|
|
|
|||
|
|
@ -960,7 +960,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
Assert.Equal(expectedBuilderAttribute.Value, attribute.Value);
|
||||
}
|
||||
|
||||
private class CaseSensitiveTagHelperAttributeComparer : IEqualityComparer<IReadOnlyTagHelperAttribute>
|
||||
private class CaseSensitiveTagHelperAttributeComparer : IEqualityComparer<TagHelperAttribute>
|
||||
{
|
||||
public readonly static CaseSensitiveTagHelperAttributeComparer Default =
|
||||
new CaseSensitiveTagHelperAttributeComparer();
|
||||
|
|
@ -969,7 +969,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
{
|
||||
}
|
||||
|
||||
public bool Equals(IReadOnlyTagHelperAttribute attributeX, IReadOnlyTagHelperAttribute attributeY)
|
||||
public bool Equals(TagHelperAttribute attributeX, TagHelperAttribute attributeY)
|
||||
{
|
||||
if (attributeX == attributeY)
|
||||
{
|
||||
|
|
@ -983,7 +983,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
(attributeX.Minimized || Equals(attributeX.Value, attributeY.Value));
|
||||
}
|
||||
|
||||
public int GetHashCode(IReadOnlyTagHelperAttribute attribute)
|
||||
public int GetHashCode(TagHelperAttribute attribute)
|
||||
{
|
||||
return attribute.GetHashCode();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,8 +124,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
};
|
||||
|
||||
var tagHelperContext = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
var htmlAttributes = new TagHelperAttributeList
|
||||
|
|
|
|||
|
|
@ -114,8 +114,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
var expectedContent = "original content";
|
||||
var expectedPostContent = "original post-content";
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
var output = new TagHelperOutput(
|
||||
|
|
@ -184,8 +184,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
output.Content.AppendHtml(outputContent);
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
|
||||
|
|
@ -243,8 +243,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
});
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
|
||||
|
|
@ -283,8 +283,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
output.PostContent.SetContent(expectedPostContent);
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
var expectedPreContent = "original pre-content";
|
||||
var expectedContent = "original content";
|
||||
var tagHelperContext = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
var output = new TagHelperOutput(
|
||||
|
|
@ -120,8 +120,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
validationSummaryTagHelper.ViewContext = expectedViewContext;
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
|
||||
|
|
@ -176,8 +176,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
validationSummaryTagHelper.ViewContext = viewContext;
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
|
||||
|
|
@ -225,8 +225,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
validationSummaryTagHelper.ViewContext = viewContext;
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
|
||||
|
|
@ -281,8 +281,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
validationSummaryTagHelper.ViewContext = viewContext;
|
||||
|
||||
var context = new TagHelperContext(
|
||||
allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
|
||||
Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
Enumerable.Empty<TagHelperAttribute>()),
|
||||
items: new Dictionary<object, object>(),
|
||||
uniqueId: "test");
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace TagHelpersWebSite.TagHelpers
|
|||
output.Attributes.Clear();
|
||||
|
||||
var urlHelper = UrlHelperFactory.GetUrlHelper(ViewContext);
|
||||
output.Attributes["href"] = urlHelper.Action(Action, Controller, methodParameters);
|
||||
output.Attributes.SetAttribute("href", urlHelper.Action(Action, Controller, methodParameters));
|
||||
|
||||
output.PreContent.SetContent("My ");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace TagHelpersWebSite.TagHelpers
|
|||
{
|
||||
public override void Process(TagHelperContext context, TagHelperOutput output)
|
||||
{
|
||||
output.Attributes.Add(new TagHelperAttribute { Name = "processed", Minimized = true });
|
||||
output.Attributes.Add(new TagHelperAttribute("processed"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ namespace TagHelpersWebSite.TagHelpers
|
|||
style += ";";
|
||||
}
|
||||
|
||||
output.Attributes["style"] = style + prettyStyle;
|
||||
output.Attributes.SetAttribute("style", style + prettyStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue