From 1895d6a716161545a23c0fe46c57c027f3fb6350 Mon Sep 17 00:00:00 2001 From: Lauren Hitchon Date: Wed, 12 Jun 2024 18:57:53 +1000 Subject: [PATCH] Update select.js (#422) --- src/components/select/select.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/select/select.js b/src/components/select/select.js index 3a1e110c6..76b530c51 100644 --- a/src/components/select/select.js +++ b/src/components/select/select.js @@ -3,9 +3,9 @@ class Select { constructor(element) { this.element = element this.select = this.element.querySelector('select') - this.optGroups = this.select.getElementsByTagName('optgroup') - this.options = this.select.getElementsByTagName('option') - this.selectId = this.select.getAttribute('id') + this.optGroups = this.select && this.select.getElementsByTagName('optgroup') + this.options = this.select && this.select.getElementsByTagName('option') + this.selectId = this.select && this.select.getAttribute('id') this.trigger = false this.dropdown = false this.customOptions = false @@ -42,6 +42,7 @@ class Select { } init() { + if (!this.select) return this.element.insertAdjacentHTML('beforeend', this.initButtonSelect() + this.initListSelect()) this.dropdown = this.element.querySelector(`.js-${this.dropdownClass}`)