Smidge interfering with 'asp-append-version' tag helper creating duplicate src attributes
See original GitHub issueIf I use asp-append-version on a script tag in a project which includes Smidge 4.0.4 it results in markup with two src
attributes, for example.
Script reference:
<script src="~/main.js" asp-append-version="true"></script>
Markup (view source):
<script src="/main.js?v=xtltRP-8iJXgGK7LWJBGthatLEu0oYmDmTR3iRmR7ho" src="/main.js"></script>
This will fail W3C validation. It also interferes with a sites content security policy causing nonce attributes added to the tag to be ignored (due to the duplicate src
).
Haven’t tested but I imagine the problem will be there with other tag helpers targeting script src
attribute.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Asp.NET Core custom Input Tag Helper rendering ...
Since it creates it differently, it doesn't do a merge of the attributes to avoid duplicates, but creates them again.
Read more >Image Tag Helper in ASP.NET Core
When asp-append-version is specified with a true value along with a src attribute, the Image Tag Helper is invoked.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This will be released with 4.1.0 soon
I’ve pushed a fix for this. Now Smidge will validate if there are
asp-
attributes on script/link tags when trying to render a Smidge bundle and if there are it will throw an InvalidOperationException because these attributes from the Script/Link TagHelper will not work or be compatible with Smidge bundles.If the script/link src/href is not a Smidge bundle, then it will just let the default Script/Link tag helpers execute as per normal. This was what was attempted to be done before but because the Smidge Script/Link tag helpers have their own src/href attributes, it would end up adding 2x to the output causing this issue.