-
Notifications
You must be signed in to change notification settings - Fork 222
Add support for minimized attributes in TagHelpers. #372
Conversation
why aren't minimized attributes handled? bound and unbound attributes use the same bound value of a so far, this seems like #220 part 1 of at least 2. |
/// Tracks the minimized HTML attribute in <see cref="AllAttributes"/> and <see cref="HTMLAttributes"/>. | ||
/// </summary> | ||
/// <param name="name">The minimized HTML attribute name.</param> | ||
public void AddHtmlAttribute([NotNull] string name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will confuse everyone. suggest either leaving out this "helper" or giving it a name that hints at minimization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TagHelperExecutionContext
isn't seen by users. It's only used by codegen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method will confuse us
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't leave out the helper because it needs to do specific work to add a minimized attribute. As for renaming: I don't feel like it warrants an entirely new method name for a different form of an HTML attribute, that to me makes less sense. Going to leave as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This warrants a different name because it's doing something different. In particular, the effect is not the same as a call to AddHtmlAttribute("attribute-name", value: null)
(the basic expectation of overloads). So please rename it to AddMinimizedAttribute()
or AddMinimizedHtmlAttribute()
.
ok though I don't see anything like an understandable / helpful error message if a user writes |
⌚ |
In response to #372 (comment) : tons of validating tests in the
|
/// <remarks>If <c>true</c>, <see cref="Value"/> will be ignored.</remarks> | ||
public bool Minimized { get; set; } | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty line
@NTaylorMullen, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR. |
ca1d840
to
3b1981c
Compare
Updated. |
@@ -58,6 +59,11 @@ public GeneratedTagHelperContext() | |||
public string ExecutionContextAddTagHelperAttributeMethodName { get; set; } | |||
|
|||
/// <summary> | |||
/// The name of the <see cref="ExecutionContextTypeName"/> method used to add minimized HTML attributes. | |||
/// </summary> | |||
public string ExecutionContextAddMinimizedHtmlAttributeMethodName { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So there's going to be an MVC reaction PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Si.
⌚ for less tests to wade through |
Updated. Addressed all except #372 (comment) |
@@ -471,11 +471,18 @@ private void BeforeAttribute() | |||
return; | |||
} | |||
|
|||
// Minimized attribute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment remains misplaced. Should be two lines down.
⌚ |
023fedd
to
29a2359
Compare
Updated. |
29a2359
to
2097006
Compare
This has been open too long, Will get this in tomorrow afternoon and if more comments come in I will address them. Current review commit: 2097006 I'm rebasing/squashing for the push so you can inspect the above commit for changes applied in the last CR iteration if comments are needed. |
@@ -202,6 +202,13 @@ protected virtual string GenerateUniqueId() | |||
// First attribute wins, even if there's duplicates. | |||
var attributeValueChunk = matchingAttributes.First().Value; | |||
|
|||
// Minimized attributes are not valid for bound attributes. There will be an error logged for this | |||
// bound attribute already so we can skip. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this comment a bit more informative, describing what logs the error. "There will be" is just too vague.
|
- Updated the Razor parser to understand minimized attributes instead of just treating them like plain text. This just involved encompassing minimized attributes in their own blocks just like the other attributes found on the HTML tag. - Updated TagHelperParseTreeRewriter to only accept minimized attributes for unbound attributes. - Updated IReadOnlyTagHelperAttribute/TagHelperAttribute to have a Minimized property to indicate that an attribute was minimized. - Updated parser level block structures to represent minimized attributes as null syntax tree nodes. - Updated chunk level structures to represent minimized attributes as null chunks. #220
- Added parse level rewriting tests to validate new TagHelper rewritten structures for minimized attributes. - Updated existing parser tests to understand minimized attributes. - Added codegen test to validate understanding of minimized attributes. - Added TagHelperExecutionContext tests to validate maintaining of runtime TagHelperOutput tests. - Refactored part of the TagHelperParseTreeRewriterTest file into a base class file so we can make better rewriting tests. #220
2097006
to
0882ff4
Compare
TagHelper attributes with no value cannot be used in TagHelpers #220