add support for type attribute in JSInterop IncludeScript

This commit is contained in:
sbwalker
2023-05-18 09:36:09 -04:00
parent f1ec70ff14
commit 076d150f72
3 changed files with 24 additions and 9 deletions

View File

@ -108,7 +108,7 @@ Oqtane.Interop = {
}
}
},
includeScript: function (id, src, integrity, crossorigin, content, location) {
includeScript: function (id, src, integrity, crossorigin, type, content, location) {
var script;
if (src !== "") {
script = document.querySelector("script[src=\"" + CSS.escape(src) + "\"]");
@ -121,6 +121,9 @@ Oqtane.Interop = {
if (id !== "") {
script.id = id;
}
if (type !== "") {
script.type = type;
}
if (src !== "") {
script.src = src;
if (integrity !== "") {
@ -146,6 +149,13 @@ Oqtane.Interop = {
if (script.id !== id) {
script.setAttribute('id', id);
}
if (type !== "") {
if (script.type !== type) {
script.setAttribute('type', type);
}
} else {
script.removeAttribute('type');
}
if (src !== "") {
if (script.src !== this.getAbsoluteUrl(src)) {
script.removeAttribute('integrity');