Merge pull request #2823 from sbwalker/dev
add support for type attribute in JSInterop IncludeScript
This commit is contained in:
@ -92,12 +92,17 @@ namespace Oqtane.UI
|
||||
|
||||
// external scripts need to specify src, inline scripts need to specify id and content
|
||||
public Task IncludeScript(string id, string src, string integrity, string crossorigin, string content, string location)
|
||||
{
|
||||
return IncludeScript(id, src, integrity, crossorigin, "", content, location);
|
||||
}
|
||||
|
||||
public Task IncludeScript(string id, string src, string integrity, string crossorigin, string type, string content, string location)
|
||||
{
|
||||
try
|
||||
{
|
||||
_jsRuntime.InvokeVoidAsync(
|
||||
"Oqtane.Interop.includeScript",
|
||||
id, src, integrity, crossorigin, content, location);
|
||||
id, src, integrity, crossorigin, type, content, location);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
catch
|
||||
|
@ -84,10 +84,10 @@
|
||||
var script = PageState.Page.HeadContent.Substring(index, PageState.Page.HeadContent.IndexOf("</script>", index) + 9 - index);
|
||||
var attributes = script.Substring(0, script.IndexOf(">")).Replace("\"", "").Split(" ");
|
||||
string id = "";
|
||||
string url = "";
|
||||
string src = "";
|
||||
string integrity = "";
|
||||
string crossorigin = "";
|
||||
bool es6module = false;
|
||||
string type = "";
|
||||
foreach (var attribute in attributes)
|
||||
{
|
||||
if (attribute.Contains("="))
|
||||
@ -99,7 +99,7 @@
|
||||
id = value[1];
|
||||
break;
|
||||
case "src":
|
||||
url = value[1];
|
||||
src = value[1];
|
||||
break;
|
||||
case "integrity":
|
||||
integrity = value[1];
|
||||
@ -108,15 +108,15 @@
|
||||
crossorigin = value[1];
|
||||
break;
|
||||
case "type":
|
||||
es6module = (value[1] == "module");
|
||||
type = value[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
if (!string.IsNullOrEmpty(src))
|
||||
{
|
||||
url = (url.Contains("://")) ? url : PageState.Alias.BaseUrl + url;
|
||||
await interop.IncludeScript(id, url, integrity, crossorigin, "", "head");
|
||||
src = (src.Contains("://")) ? src : PageState.Alias.BaseUrl + src;
|
||||
await interop.IncludeScript(id, src, integrity, crossorigin, type, "", "head");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user