Merge pull request #4999 from sbwalker/dev

improve error messages
This commit is contained in:
Shaun Walker 2025-01-17 07:54:49 -05:00 committed by GitHub
commit 8058b8dba4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,9 +12,9 @@ export function onUpdate() {
let key = getKey(script); let key = getKey(script);
if (enhancedNavigation) { if (enhancedNavigation) {
// reload the script if data-reload is "always" or if the script has not been loaded previously and data-reload is "once" or "true" // reload the script if data-reload is "always" or "true"... or if the script has not been loaded previously and data-reload is "once"
let dataReload = script.getAttribute('data-reload'); let dataReload = script.getAttribute('data-reload');
if (dataReload === 'always' || (!scriptKeys.has(key) && (dataReload == 'once' || dataReload === 'true'))) { if ((dataReload === 'always' || dataReload === 'true') || (!scriptKeys.has(key) && dataReload == 'once')) {
reloadScript(script); reloadScript(script);
} }
} }
@ -43,17 +43,13 @@ function reloadScript(script) {
replaceScript(script); replaceScript(script);
} }
} catch (error) { } catch (error) {
if (script.src) { console.error(`Blazor Script Reload failed to load script: ${getKey(script)}`, error);
console.error(`Script Reload failed to load external script: ${script.src}`, error);
} else {
console.error(`Script Reload failed to load inline script: ${script.innerHTML}`, error);
}
} }
} }
function isValid(script) { function isValid(script) {
if (script.innerHTML.includes('document.write(')) { if (script.innerHTML.includes('document.write(')) {
console.log(`Script using document.write() not supported by Script Reload: ${script.innerHTML}`); console.log(`Blazor Script Reload does not support scripts using document.write(): ${script.innerHTML}`);
return false; return false;
} }
return true; return true;