Skip to content

Commit

Permalink
Update ScriptTagHelper.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
salihozkara committed May 16, 2024
1 parent 46241bc commit b8d88d2
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ public class ScriptTagHelper : AbpTagHelper
{
protected AbpBundlingOptions Options { get; }

[HtmlAttributeName("src")]
public string Src { get; set; } = default!;

public ScriptTagHelper(IOptions<AbpBundlingOptions> options)
{
Options = options.Value;
Expand All @@ -25,7 +22,9 @@ public override void Process(TagHelperContext context, TagHelperOutput output)
output.Attributes.Add("defer", "");
}

if (!Src.IsNullOrWhiteSpace() && Options.DeferScripts.Any(x => Src.Equals(x, StringComparison.OrdinalIgnoreCase)))
var src = output.Attributes["src"]?.Value?.ToString();

if (!src.IsNullOrWhiteSpace() && Options.DeferScripts.Any(x => src.Equals(x, StringComparison.OrdinalIgnoreCase)))
{
output.Attributes.Add("defer", "");
}
Expand Down

0 comments on commit b8d88d2

Please sign in to comment.