Improvements to add support for script type and data-* attributes. Also added Script and Stylesheet classes to simplify Resource declarations.
This commit is contained in:
		| @ -117,12 +117,17 @@ namespace Oqtane.UI | ||||
|         } | ||||
|  | ||||
|         public Task IncludeScript(string id, string src, string integrity, string crossorigin, string type, string content, string location) | ||||
|         { | ||||
|             return IncludeScript(id, src, integrity, crossorigin, type, content, location, null); | ||||
|         } | ||||
|  | ||||
|         public Task IncludeScript(string id, string src, string integrity, string crossorigin, string type, string content, string location, Dictionary<string, string> dataAttributes) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 _jsRuntime.InvokeVoidAsync( | ||||
|                     "Oqtane.Interop.includeScript", | ||||
|                     id, src, integrity, crossorigin, type, content, location); | ||||
|                     id, src, integrity, crossorigin, type, content, location, dataAttributes); | ||||
|                 return Task.CompletedTask; | ||||
|             } | ||||
|             catch | ||||
|  | ||||
| @ -176,7 +176,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(), dataAttributes = dataAttributes }); | ||||
|                 scripts.Add(new { href = src, type = type, bundle = "", integrity = integrity, crossorigin = crossorigin, location = location.ToString().ToLower(), dataAttributes = dataAttributes }); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
| @ -186,8 +186,8 @@ | ||||
|                     count += 1; | ||||
|                     id = $"page{PageState.Page.PageId}-script{count}"; | ||||
|                 } | ||||
|                 index = script.IndexOf(">") + 1; | ||||
|                 await interop.IncludeScript(id, "", "", "", "", script.Substring(index, script.IndexOf("</script>") - index), location.ToString().ToLower()); | ||||
|                 var pos = script.IndexOf(">") + 1; | ||||
|                 await interop.IncludeScript(id, "", "", "", type, script.Substring(pos, script.IndexOf("</script>") - pos), location.ToString().ToLower(), dataAttributes); | ||||
|             } | ||||
|             index = content.IndexOf("<script", index + 1); | ||||
|         } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 sbwalker
					sbwalker