Fix #3807: parsing the data attributes.

This commit is contained in:
Ben
2024-02-16 19:26:01 +08:00
parent e36f13c595
commit 740b89258d
2 changed files with 27 additions and 13 deletions

View File

@ -145,6 +145,7 @@
string integrity = "";
string crossorigin = "";
string type = "";
var dataAttributes = new Dictionary<string, string>();
foreach (var attribute in attributes)
{
if (attribute.Contains("="))
@ -167,6 +168,12 @@
case "type":
type = value[1];
break;
default:
if(!string.IsNullOrWhiteSpace(value[0]) && value[0].StartsWith("data-"))
{
dataAttributes.Add(value[0], value[1]);
}
break;
}
}
}
@ -174,7 +181,7 @@
if (!string.IsNullOrEmpty(src))
{
src = (src.Contains("://")) ? src : PageState.Alias.BaseUrl + src;
scripts.Add(new { href = src, bundle = "", integrity = integrity, crossorigin = crossorigin, es6module = (type == "module"), location = location.ToString().ToLower() });
scripts.Add(new { href = src, bundle = "", integrity = integrity, crossorigin = crossorigin, es6module = (type == "module"), location = location.ToString().ToLower(), dataAttributes = dataAttributes });
}
else
{