Add `srcset` to list of application relative resolvable URLs.

- Now allow the attribute to exist on `img` and `source` tags.
- Updated existing `UrlResolutionTagHelper` functional test to validate `srcset` attribute.

#2964
This commit is contained in:
N. Taylor Mullen 2015-08-14 12:11:05 -07:00
parent 82dced7877
commit e73e73acdd
4 changed files with 10 additions and 8 deletions

View File

@ -31,6 +31,7 @@ namespace Microsoft.AspNet.Mvc.Razor.TagHelpers
[TargetElement("html", Attributes = "manifest")] [TargetElement("html", Attributes = "manifest")]
[TargetElement("iframe", Attributes = "src")] [TargetElement("iframe", Attributes = "src")]
[TargetElement("img", Attributes = "src", TagStructure = TagStructure.WithoutEndTag)] [TargetElement("img", Attributes = "src", TagStructure = TagStructure.WithoutEndTag)]
[TargetElement("img", Attributes = "srcset", TagStructure = TagStructure.WithoutEndTag)]
[TargetElement("input", Attributes = "src", TagStructure = TagStructure.WithoutEndTag)] [TargetElement("input", Attributes = "src", TagStructure = TagStructure.WithoutEndTag)]
[TargetElement("input", Attributes = "formaction", TagStructure = TagStructure.WithoutEndTag)] [TargetElement("input", Attributes = "formaction", TagStructure = TagStructure.WithoutEndTag)]
[TargetElement("ins", Attributes = "cite")] [TargetElement("ins", Attributes = "cite")]
@ -41,6 +42,7 @@ namespace Microsoft.AspNet.Mvc.Razor.TagHelpers
[TargetElement("q", Attributes = "cite")] [TargetElement("q", Attributes = "cite")]
[TargetElement("script", Attributes = "src")] [TargetElement("script", Attributes = "src")]
[TargetElement("source", Attributes = "src", TagStructure = TagStructure.WithoutEndTag)] [TargetElement("source", Attributes = "src", TagStructure = TagStructure.WithoutEndTag)]
[TargetElement("source", Attributes = "srcset", TagStructure = TagStructure.WithoutEndTag)]
[TargetElement("track", Attributes = "src", TagStructure = TagStructure.WithoutEndTag)] [TargetElement("track", Attributes = "src", TagStructure = TagStructure.WithoutEndTag)]
[TargetElement("video", Attributes = "src")] [TargetElement("video", Attributes = "src")]
[TargetElement("video", Attributes = "poster")] [TargetElement("video", Attributes = "poster")]
@ -65,7 +67,7 @@ namespace Microsoft.AspNet.Mvc.Razor.TagHelpers
{ "form", new[] { "action" } }, { "form", new[] { "action" } },
{ "html", new[] { "manifest" } }, { "html", new[] { "manifest" } },
{ "iframe", new[] { "src" } }, { "iframe", new[] { "src" } },
{ "img", new[] { "src" } }, { "img", new[] { "src", "srcset" } },
{ "input", new[] { "src", "formaction" } }, { "input", new[] { "src", "formaction" } },
{ "ins", new[] { "cite" } }, { "ins", new[] { "cite" } },
{ "link", new[] { "href" } }, { "link", new[] { "href" } },
@ -73,7 +75,7 @@ namespace Microsoft.AspNet.Mvc.Razor.TagHelpers
{ "object", new[] { "archive", "data" } }, { "object", new[] { "archive", "data" } },
{ "q", new[] { "cite" } }, { "q", new[] { "cite" } },
{ "script", new[] { "src" } }, { "script", new[] { "src" } },
{ "source", new[] { "src" } }, { "source", new[] { "src", "srcset" } },
{ "track", new[] { "src" } }, { "track", new[] { "src" } },
{ "video", new[] { "poster", "src" } }, { "video", new[] { "poster", "src" } },
}; };

View File

@ -9,12 +9,12 @@
<link href="HtmlEncode[[/]]Person/HtmlEncode[[John Doe]]/CSS" rel="stylesheet"> <link href="HtmlEncode[[/]]Person/HtmlEncode[[John Doe]]/CSS" rel="stylesheet">
<video poster="HtmlEncode[[~/SomeUrl]]" src="HtmlEncode[[~/SomeUrl]]/HtmlEncode[[video]]" /> <video poster="HtmlEncode[[~/SomeUrl]]" src="HtmlEncode[[~/SomeUrl]]/HtmlEncode[[video]]" />
<audio src="HtmlEncode[[~/SomeUrl]]"> <audio src="HtmlEncode[[~/SomeUrl]]">
<source src="HtmlEncode[[/]]Person"> <source src="HtmlEncode[[/]]Person" srcset="HtmlEncode[[/]]Person">
<track src="HtmlEncode[[/]]emailHtmlEncode[[~/SomeUrl]]"> <track src="HtmlEncode[[/]]emailHtmlEncode[[~/SomeUrl]]">
</audio> </audio>
<embed src="HtmlEncode[[/]]email@dyanmicUrl"> <embed src="HtmlEncode[[/]]email@dyanmicUrl">
<iframe src="HtmlEncode[[~/SomeUrl]]" /> <iframe src="HtmlEncode[[~/SomeUrl]]" />
<img src="HtmlEncode[[/]]HtmlEncode[[~/SomeUrl]]"> <img src="HtmlEncode[[/]]HtmlEncode[[John Doe]]" srcset="HtmlEncode[[/]]HtmlEncode[[John Doe]]">
<script src="HtmlEncode[[/]]Person/HtmlEncode[[John Doe]]/JS"></script> <script src="HtmlEncode[[/]]Person/HtmlEncode[[John Doe]]/JS"></script>
<input src="HtmlEncode[[/]]/Person" itemscope itemid="HtmlEncode[[/]]Person" formaction="HtmlEncode[[~/SomeUrl]]"> <input src="HtmlEncode[[/]]/Person" itemscope itemid="HtmlEncode[[/]]Person" formaction="HtmlEncode[[~/SomeUrl]]">
<button formaction="HtmlEncode[[/]]\Person" /> <button formaction="HtmlEncode[[/]]\Person" />

View File

@ -9,12 +9,12 @@
<link href="/Person/John Doe/CSS" rel="stylesheet"> <link href="/Person/John Doe/CSS" rel="stylesheet">
<video poster="/SomeUrl" src="/SomeUrl/video" /> <video poster="/SomeUrl" src="/SomeUrl/video" />
<audio src="/SomeUrl"> <audio src="/SomeUrl">
<source src="/Person"> <source src="/Person" srcset="/Person">
<track src="/email~/SomeUrl"> <track src="/email~/SomeUrl">
</audio> </audio>
<embed src="/email@dyanmicUrl"> <embed src="/email@dyanmicUrl">
<iframe src="/SomeUrl" /> <iframe src="/SomeUrl" />
<img src="/~/SomeUrl"> <img src="/John Doe" srcset="/John Doe">
<script src="/Person/John Doe/JS"></script> <script src="/Person/John Doe/JS"></script>
<input src="//Person" itemscope itemid="/Person" formaction="/SomeUrl"> <input src="//Person" itemscope itemid="/Person" formaction="/SomeUrl">
<button formaction="/\Person" /> <button formaction="/\Person" />

View File

@ -15,12 +15,12 @@
<link href="~/Person/@Model.Name/CSS" rel="stylesheet"> <link href="~/Person/@Model.Name/CSS" rel="stylesheet">
<video poster=@dynamicUrl src='@dynamicUrl/@("video")' /> <video poster=@dynamicUrl src='@dynamicUrl/@("video")' />
<audio src="@(dynamicUrl)"> <audio src="@(dynamicUrl)">
<source src="~/Person"> <source src="~/Person" srcset="~/Person">
<track src="~/email@(dynamicUrl)"> <track src="~/email@(dynamicUrl)">
</audio> </audio>
<embed src="~/email@dyanmicUrl"> <embed src="~/email@dyanmicUrl">
<iframe src=@(dynamicUrl) /> <iframe src=@(dynamicUrl) />
<img src="~/@dynamicUrl"> <img src="~/@Model.Name" srcset="~/@Model.Name">
<script src="~/Person/@Model.Name/JS"></script> <script src="~/Person/@Model.Name/JS"></script>
<input src="~//Person" itemscope itemid="~/Person" formaction=@dynamicUrl> <input src="~//Person" itemscope itemid="~/Person" formaction=@dynamicUrl>
<button formaction="~/\Person" /> <button formaction="~/\Person" />