Skip to content

Commit 5c3adb6

Browse files
committed
fix: handle potential errors when retrieving collapsed groups from localStorage
1 parent 36fb32e commit 5c3adb6

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/view/frontend/web/js/toolbar.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ function _registerMageforgeToolbar() {
3535
// ====================================================================
3636

3737
init() {
38-
const saved = localStorage.getItem('mageforge-toolbar-collapsed-groups');
39-
if (saved) {
40-
try { JSON.parse(saved).forEach(key => this.collapsedGroups.add(key)); } catch (_) {}
41-
}
38+
try {
39+
const saved = localStorage.getItem('mageforge-toolbar-collapsed-groups');
40+
if (saved) {
41+
try { JSON.parse(saved).forEach(key => this.collapsedGroups.add(key)); } catch (_) {}
42+
}
43+
} catch (_) {}
4244
this.createToolbar();
4345
},
4446

src/view/frontend/web/js/toolbar/audits/low-contrast-text.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function hasDirectText(el) {
9898
function isVisible(el) {
9999
if (el.offsetWidth === 0 && el.offsetHeight === 0) return false;
100100
const style = getComputedStyle(el);
101-
return style.visibility !== 'hidden' && style.display !== 'none' && style.opacity !== '0';
101+
return style.visibility !== 'hidden' && style.display !== 'none' && parseFloat(style.opacity) > 0;
102102
}
103103

104104
/**

0 commit comments

Comments
 (0)