Skip to content

A platform for community discussion. Free, open, simple.

FIX: return empty array when no parent for range (#14386)

Krzysztof Kotlarek38c3a44bf9b8
diff --git a/plugins/discourse-local-dates/assets/javascripts/initializers/discourse-local-dates.js.es6 b/plugins/discourse-local-dates/assets/javascripts/initializers/discourse-local-dates.js.es6
index 50d543c971e..dad88fbd251 100644
--- a/plugins/discourse-local-dates/assets/javascripts/initializers/discourse-local-dates.js.es6
+++ b/plugins/discourse-local-dates/assets/javascripts/initializers/discourse-local-dates.js.es6
@@ -63,6 +63,9 @@ function buildOptionsFromElement(element, siteSettings) {
}
function _rangeElements(element) {
+ if (!element.parentElement) {
+ return [];
+ }
return Array.from(element.parentElement.children).filter(
(span) => span.dataset.date
);