diff --git a/Oqtane.Client/UI/ThemeBuilder.razor b/Oqtane.Client/UI/ThemeBuilder.razor index 2b40e59e..792572b8 100644 --- a/Oqtane.Client/UI/ThemeBuilder.razor +++ b/Oqtane.Client/UI/ThemeBuilder.razor @@ -24,6 +24,7 @@ } // include page resources + string batch = DateTime.Now.ToString("yyyyMMddHHmmssfff"); var links = new List(); var scripts = new List(); foreach (Resource resource in PageState.Page.Resources) @@ -31,18 +32,18 @@ switch (resource.ResourceType) { case ResourceType.Stylesheet: - links.Add(new { id = "app-stylesheet" + links.Count.ToString("00"), rel = "stylesheet", href = resource.Url, type = "text/css", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "", key = "" }); + links.Add(new { id = "app-stylesheet-" + batch + "-" + (links.Count + 1).ToString("00"), rel = "stylesheet", href = resource.Url, type = "text/css", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "", key = "" }); break; case ResourceType.Script: - scripts.Add(new { id = "app-script" + scripts.Count.ToString("00"), src = resource.Url, integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "", content = "", location = "body", key = "" }); + scripts.Add(new { id = "app-script-" + batch + "-" + (scripts.Count + 1).ToString("00"), src = resource.Url, integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "", content = "", location = "body", key = "" }); break; } } await interop.IncludeLinks(links.ToArray()); await interop.IncludeScripts(scripts.ToArray()); // remove any page resource references which are no longer required for this page - await interop.RemoveElementsById("app-stylesheet", "app-stylesheet" + links.Count.ToString("00"), ""); - await interop.RemoveElementsById("app-script", "app-script" + scripts.Count.ToString("00"), ""); + await interop.RemoveElementsById("app-stylesheet", "", "app-stylesheet-" + batch + "-00"); + await interop.RemoveElementsById("app-script", "", "app-script-" + batch + "-00"); // add favicon if (PageState.Site.FaviconFileId != null) diff --git a/Oqtane.Server/wwwroot/js/interop.js b/Oqtane.Server/wwwroot/js/interop.js index f94c3472..90668589 100644 --- a/Oqtane.Server/wwwroot/js/interop.js +++ b/Oqtane.Server/wwwroot/js/interop.js @@ -45,6 +45,9 @@ Oqtane.Interop = { document.head.appendChild(meta); } else { + if (id !== "") { + meta.setAttribute("id", id); + } if (meta.content !== content) { meta.setAttribute("content", content); } @@ -77,6 +80,9 @@ Oqtane.Interop = { document.head.appendChild(link); } else { + if (link.id !== id) { + link.setAttribute('id', id); + } if (link.rel !== rel) { link.setAttribute('rel', rel); } @@ -148,6 +154,9 @@ Oqtane.Interop = { }); } else { + if (script.id !== id) { + script.setAttribute('id', id); + } if (src !== "") { if (script.src !== this.getAbsoluteUrl(src)) { script.removeAttribute('integrity');