@wernfried/daterangepicker 5.4.1 → 5.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@ class DateRangePicker {
5
5
  constructor(element, options, cb) {
6
6
  if (typeof element === "string" && document.querySelectorAll(element).length > 1)
7
7
  throw new RangeError(`Option 'element' must match to one element only`);
8
- this.parentEl = "body";
8
+ this.parentEl = document.querySelector("body");
9
9
  this.element = element instanceof HTMLElement ? element : document.querySelector(element);
10
10
  this.isInputText = this.element instanceof HTMLInputElement && this.element.type === "text";
11
11
  this.button = null;
@@ -160,7 +160,11 @@ class DateRangePicker {
160
160
  options.template = template.join("");
161
161
  this.container = createElementFromHTML(options.template);
162
162
  }
163
- this.parentEl = document.querySelector(typeof options.parentEl === "string" ? options.parentEl : this.parentEl);
163
+ if (options.parentEl instanceof HTMLElement) {
164
+ this.parentEl = options.parentEl;
165
+ } else if (typeof options.parentEl === "string") {
166
+ this.parentEl = document.querySelector(options.parentEl) ?? this.parentEl;
167
+ }
164
168
  this.parentEl.appendChild(this.container);
165
169
  if (typeof options.timePicker === "boolean")
166
170
  this.timePicker = options.timePicker;