Prevent multiple <a> tags in progressively enhanced usa-link #40
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Prevented multiple tags in progressively enhanced
usa-link
Fixed an issue in which there are nested tags in theusa-link
when a childLink is provided.Problem statement
We want only one tag in the output HTML when we use the progressively enhanced
usa-link
.Desired state:
The actual state
Consequences of remaining in the current state
It is invalid HTML.
Solution
I removed the wrapper tag and instead added the
usa-link
class to the existing link that is passed as a child. It's quite possible I did not follow Web Component best practices or your company best practices, or that there are other things I'm not considering, so there are lots of limitations :)Testing and review
I added a test that asserts that there is only one tag.