Merge pull request #4921 from sbwalker/dev

render page-script elements at end of head content
This commit is contained in:
Shaun Walker 2024-12-17 12:31:40 -05:00 committed by GitHub
commit 2b7dd3fed5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -70,10 +70,13 @@
var pagescript = script.Replace("script", "page-script");
if (!pagescript.Contains("><"))
{
// convert inline script body to content attribute
var content = pagescript.Substring(pagescript.IndexOf(">") + 1, pagescript.LastIndexOf("<") - pagescript.IndexOf(">") - 1);
pagescript = pagescript.Replace(">" + content, " content=\"" + content.Replace("\"","'") + "\">");
}
headcontent = headcontent.Replace(script, pagescript);
// move page-script to end of headcontent as Blazor will move anything after a page-script element to the top of the body
headcontent = headcontent.Replace(script, "");
headcontent = headcontent + pagescript;
}
index = headcontent.IndexOf("<script");
}