Profile: try/catch в renderChips click + console.error при отсутствии el
This commit is contained in:
parent
fd8f6b38d0
commit
ce3c863e66
@ -78,14 +78,17 @@ const ProfileView = {
|
|||||||
|
|
||||||
renderChips(elId, items, selected) {
|
renderChips(elId, items, selected) {
|
||||||
const el = document.getElementById(elId);
|
const el = document.getElementById(elId);
|
||||||
|
if (!el) { console.error('renderChips: no element', elId); return; }
|
||||||
items.forEach(([key, label]) => {
|
items.forEach(([key, label]) => {
|
||||||
const chip = document.createElement('span');
|
const chip = document.createElement('span');
|
||||||
chip.className = 'chip' + (selected.has(key) ? ' active' : '');
|
chip.className = 'chip' + (selected.has(key) ? ' active' : '');
|
||||||
chip.textContent = label;
|
chip.textContent = label;
|
||||||
chip.onclick = () => {
|
chip.onclick = () => {
|
||||||
if (selected.has(key)) selected.delete(key); else selected.add(key);
|
try {
|
||||||
chip.classList.toggle('active');
|
if (selected.has(key)) selected.delete(key); else selected.add(key);
|
||||||
TG_APP.haptic('selection');
|
chip.classList.toggle('active');
|
||||||
|
TG_APP.haptic('selection');
|
||||||
|
} catch (e) { console.warn('chip click err', e); }
|
||||||
};
|
};
|
||||||
el.appendChild(chip);
|
el.appendChild(chip);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user