Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Track TagHelperAttribute quotes #705

Closed
NTaylorMullen opened this issue Mar 1, 2016 · 3 comments
Closed

Track TagHelperAttribute quotes #705

NTaylorMullen opened this issue Mar 1, 2016 · 3 comments
Assignees
Milestone

Comments

@NTaylorMullen
Copy link
Contributor

This would enable TagHelper users to write things like <input type=checkbox /> and have it output the identical code; whereas today we output <input type="checkbox" />.

This change would actually have a significant perf impact as well. Today in TagHelperOutput we have to write an attribute to an intermediate writer to potentially escape any double quotes in the case that a user wrote <input type=' """" ' /> since we always output with double quotes.

This intermediate writing step in my tests have represented over 5% of allocations.

image

@Eilon
Copy link
Member

Eilon commented Mar 7, 2016

Is preserving the non-quotes actually important?

Also, what happens if a Tag Helper modifies that attribute? Does it "gain" the quotes after it's modified? E.g. let's say in my Tag Helper I set OutputTags["type"] = "this has spaces"; (or whatever the syntax is). Does it render <input type=this has spaces /> or <input type="this has spaces" />?

@NTaylorMullen
Copy link
Contributor Author

NTaylorMullen commented Mar 7, 2016

Actually, with the new immutability of TagHelperAttributes the unquoted scenario isn't an issue. For instance, if a TagHelper author were to do output.Attributes.SetAttribute("type", "...") they'd be saying "create a new TagHelperAttribute with name type and value ..." which would default to using a double quoted value. If they instead used the TagHelperAttribute attribute overload they'd have the option of using their own quoting.

A user would have to purposefully shoot themselves in the foot and do something like:

var myBadAttribute = new TagHelperAttribute("type", "this has spaces", QuoteType.Unquoted);
output.Attributes.SetAttribute(myBadAttribute);

@Eilon Eilon added this to the 1.0.0 milestone Apr 5, 2016
NTaylorMullen added a commit to aspnet/Mvc that referenced this issue May 3, 2016
- Updated `ScriptTagHelper` and `LinkTagHelper` to maintain their quotes on generated script tags.
- Removed `TagHelperOutputExtensions`. It's no longer needed.
- We no longer string replace quotes directly. We rely on encoding and the initial representation of an attribute to ensure quotes don't break generated attributes.
- Updated tess.
NTaylorMullen added a commit that referenced this issue May 3, 2016
- Removed `Minimized` from `TagHelperAttribute` and replaced it with `HtmlAttributeStructure`.
- Removed `AddMinimizedTagHelperAttribute` method from `TagHelperExecutionContext` since we always provide a `HtmlAttributeStructure` now.
- Stopped manually escaping double quotes because we now know how an attribute was originally written.
- Updated tests to account for new attribute format (from kvp).

#705
NTaylorMullen added a commit to aspnet/Mvc that referenced this issue May 3, 2016
- Updated `ScriptTagHelper` and `LinkTagHelper` to maintain their quotes on generated script tags.
- Removed `TagHelperOutputExtensions`. It's no longer needed.
- We no longer string replace quotes directly. We rely on encoding and the initial representation of an attribute to ensure quotes don't break generated attributes.
- Updated tests.
NTaylorMullen added a commit that referenced this issue May 19, 2016
- Removed `Minimized` from `TagHelperAttribute` and replaced it with `HtmlAttributeStructure`.
- Removed `AddMinimizedTagHelperAttribute` method from `TagHelperExecutionContext` since we always provide a `HtmlAttributeStructure` now.
- Stopped manually escaping double quotes because we now know how an attribute was originally written.
- Updated tests to account for new attribute format (from kvp).

#705
NTaylorMullen added a commit to aspnet/Mvc that referenced this issue May 19, 2016
- Updated `ScriptTagHelper` and `LinkTagHelper` to maintain their quotes on generated script tags.
- Removed `TagHelperOutputExtensions`. It's no longer needed.
- We no longer string replace quotes directly. We rely on encoding and the initial representation of an attribute to ensure quotes don't break generated attributes.
- Updated tests.
NTaylorMullen added a commit that referenced this issue May 23, 2016
- Removed `Minimized` from `TagHelperAttribute` and replaced it with `HtmlAttributeStructure`.
- Removed `AddMinimizedTagHelperAttribute` method from `TagHelperExecutionContext` since we always provide a `HtmlAttributeStructure` now.
- Stopped manually escaping double quotes because we now know how an attribute was originally written.
- Updated tests to account for new attribute format (from kvp).

#705
NTaylorMullen added a commit to aspnet/Mvc that referenced this issue May 23, 2016
- Updated `ScriptTagHelper` and `LinkTagHelper` to maintain their quotes on generated script tags.
- Removed `TagHelperOutputExtensions`. It's no longer needed.
- We no longer string replace quotes directly. We rely on encoding and the initial representation of an attribute to ensure quotes don't break generated attributes.
- Updated tests.
NTaylorMullen added a commit that referenced this issue May 25, 2016
- Removed `Minimized` from `TagHelperAttribute` and replaced it with `HtmlAttributeStructure`.
- Removed `AddMinimizedTagHelperAttribute` method from `TagHelperExecutionContext` since we always provide a `HtmlAttributeStructure` now.
- Stopped manually escaping double quotes because we now know how an attribute was originally written.
- Updated tests to account for new attribute format (from kvp).

#705
NTaylorMullen added a commit to aspnet/Mvc that referenced this issue May 25, 2016
- Updated `ScriptTagHelper` and `LinkTagHelper` to maintain their quotes on generated script tags.
- Removed `TagHelperOutputExtensions`. It's no longer needed.
- We no longer string replace quotes directly. We rely on encoding and the initial representation of an attribute to ensure quotes don't break generated attributes.
- Updated tests.
NTaylorMullen added a commit that referenced this issue May 27, 2016
- Removed `Minimized` from `TagHelperAttribute` and replaced it with `HtmlAttributeValueStyle`.
- Removed `AddMinimizedTagHelperAttribute` method from `TagHelperExecutionContext` since we always provide a `HtmlAttributeValueStyle` now.
- Stopped manually escaping double quotes because we now know how an attribute was originally written.
- Updated tests to account for new attribute format (from kvp).

#705
NTaylorMullen added a commit to aspnet/Mvc that referenced this issue May 27, 2016
- Updated `ScriptTagHelper` and `LinkTagHelper` to maintain their quotes on generated script tags.
- Removed `TagHelperOutputExtensions`. It's no longer needed.
- We no longer string replace quotes directly. We rely on encoding and the initial representation of an attribute to ensure quotes don't break generated attributes.
- Updated tests.
NTaylorMullen added a commit that referenced this issue May 27, 2016
- Removed `Minimized` from `TagHelperAttribute` and replaced it with `HtmlAttributeValueStyle`.
- Removed `AddMinimizedTagHelperAttribute` method from `TagHelperExecutionContext` since we always provide a `HtmlAttributeValueStyle` now.
- Stopped manually escaping double quotes because we now know how an attribute was originally written.
- Updated tests to account for new attribute format (from kvp).

#705
@NTaylorMullen
Copy link
Contributor Author

e14f4b0
aspnet/Mvc@cfd58f1

JunTaoLuo added a commit to aspnet/Entropy that referenced this issue May 28, 2016
pranavkm added a commit to aspnet/Entropy that referenced this issue May 29, 2016
pranavkm added a commit to aspnet/Entropy that referenced this issue May 29, 2016
pranavkm added a commit to aspnet/Entropy that referenced this issue May 31, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants