diff --git a/core/static/bundled/core/components/include-index.ts b/core/static/bundled/core/components/include-index.ts index 9ee44bb8..fa046850 100644 --- a/core/static/bundled/core/components/include-index.ts +++ b/core/static/bundled/core/components/include-index.ts @@ -84,7 +84,11 @@ const refreshElement = < return; } - element.refresh(); + // This might be called at some bad timing + // This prevents crashes of the observer + if (element.refresh) { + element.refresh(); + } } }; @@ -130,7 +134,7 @@ startObserver(observer); export class LinkOnce extends elementOnce("link") { getElementQuerySelector(): string { // We get href from node.attributes instead of node.href to avoid getting the domain part - return `link[href='${this.node.attributes.getNamedItem("href").nodeValue}']`; + return `link[href='${this.node.attributes.getNamedItem("href")?.nodeValue}']`; } } @@ -142,6 +146,6 @@ export class LinkOnce extends elementOnce("link") { export class ScriptOnce extends inheritHtmlElement("script") { getElementQuerySelector(): string { // We get href from node.attributes instead of node.src to avoid getting the domain part - return `script[src='${this.node.attributes.getNamedItem("src").nodeValue}']`; + return `script[src='${this.node.attributes.getNamedItem("src")?.nodeValue}']`; } } diff --git a/core/templates/core/widgets/autocomplete_select.jinja b/core/templates/core/widgets/autocomplete_select.jinja index bcdf3a76..b2e20d64 100644 --- a/core/templates/core/widgets/autocomplete_select.jinja +++ b/core/templates/core/widgets/autocomplete_select.jinja @@ -3,7 +3,7 @@ {% endfor %} {% for css in statics.css %} - + {% endfor %} <{{ component }} name="{{ widget.name }}" {% include "django/forms/widgets/attrs.html" %}>