From a3b90c7e7109265391c62f60361159cdcbe95222 Mon Sep 17 00:00:00 2001 From: Sebastien Hoek Date: Fri, 23 Aug 2024 22:02:44 +0200 Subject: [PATCH] Fix: Try to set properties to an element without knowing if it is available. --- src/plugins/select/index.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/plugins/select/index.ts b/src/plugins/select/index.ts index 51b6a21..a76d04f 100644 --- a/src/plugins/select/index.ts +++ b/src/plugins/select/index.ts @@ -307,9 +307,10 @@ class HSSelect extends HSBasePlugin implements ISelect { private setToggleIcon() { const icon = this.toggle.querySelector('[data-icon]'); - icon.innerHTML = ''; if (icon) { + icon.innerHTML = ''; + const img = htmlToElement( this.getItemByValue(this.value as string)?.options?.icon || '', ); @@ -322,13 +323,10 @@ class HSSelect extends HSBasePlugin implements ISelect { private setToggleTitle() { const title = this.toggle.querySelector('[data-title]'); - title.classList.add('truncate'); - title.innerHTML = ''; if (title) { - const titleText = - this.getItemByValue(this.value as string)?.title || this.placeholder; - title.innerHTML = titleText; + title.innerHTML = this.getItemByValue(this.value as string)?.title || this.placeholder; + title.classList.add('truncate'); this.toggle.append(title); }