diff --git a/.gitignore b/.gitignore index a2be8b5..ee25af0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ /.rpt2_cache/ package-lock.json dist -yarn.lock \ No newline at end of file +yarn.lock +yarn-error.log \ No newline at end of file diff --git a/src/helpers.js b/src/helpers.js index 5d404b5..bad72b8 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -30,7 +30,9 @@ export const tabIndexByName = tab => { export const invertNumArray = show_tabs => { if (show_tabs && show_tabs.length) { const total_tabs = []; - for (let i = 0; i < ha_elements().tabs.length; i += 1) total_tabs.push(i); + const haElem = ha_elements(); + if (!haElem || !haElem.tabs) return []; + for (let i = 0; i < haElem.tabs.length; i += 1) total_tabs.push(i); return total_tabs.filter(el => !show_tabs.includes(el)); } }; diff --git a/src/style-header.js b/src/style-header.js index 99ad6a7..36ef43b 100644 --- a/src/style-header.js +++ b/src/style-header.js @@ -145,6 +145,7 @@ export const styleHeader = (config, ch, haElem = ha_elements()) => { if (config.tab_icons && headerType.tabs.length) { for (const tab in config.tab_icons) { const index = tabIndexByName(tab); + if (!headerType.tabs[index]) continue; const haIcon = headerType.tabs[index].querySelector('ha-icon'); if (!config.tab_icons[tab]) haIcon.icon = haElem.lovelace.config.views[index].icon; else haIcon.icon = config.tab_icons[tab];