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

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

If parent element for range does not exists, range calculator should return empty array. In that case duration calculations will stop because of:

if (_rangeElements(element).length === 2) {
  opts.duration = _calculateDuration(element);
}
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 50d543c..dad88fb 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
   );

GitHub sha: 38c3a44bf9b81c28757108d12e7847e9a6f8faea

This commit appears in #14386 which was approved by martin. It was merged by lis2.