handle id attribute automatically for headcontent inline scripts

This commit is contained in:
sbwalker
2023-05-18 08:26:51 -04:00
parent 5da4dadc31
commit 7336417634
8 changed files with 25 additions and 10 deletions

View File

@ -86,6 +86,7 @@
if (PageState.Page.HeadContent != null && PageState.Page.HeadContent.Contains("<script"))
{
var interop = new Interop(JSRuntime);
var count = 0;
var index = PageState.Page.HeadContent.IndexOf("<script");
while (index >= 0)
{
@ -128,6 +129,11 @@
}
else
{
if (id == "")
{
count += 1;
id = $"page{PageState.Page.PageId}-script{count}";
}
index = script.IndexOf(">") + 1;
await interop.IncludeScript(id, "", "", "", script.Substring(index, script.IndexOf("</script>") - index), "head");
}