Skip to content

Commit

Permalink
add verification before setting the attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
vladpananetcetric committed Aug 5, 2024
1 parent 2c12816 commit 5b34d29
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions blocks/cards/cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function decorate(block) {
/* change to ul, li */
const ul = document.createElement('ul');
[...block.children].forEach((row) => {
const linkName = row.querySelector('h5 a').getAttribute('title');
const linkName = row.querySelector('h5 a')?.getAttribute('title');
const li = document.createElement('li');
li.innerHTML = row.innerHTML;
[...li.children].forEach((div) => {
Expand All @@ -36,7 +36,7 @@ export default function decorate(block) {
li.classList.add(`cards-card-bg-${div.textContent}`);
} else if (div.children.length === 1 && div.querySelector('picture')) {
div.className = 'cards-card-image';
div.querySelector('a').setAttribute('title', linkName);
linkName && div.querySelector('a').setAttribute('title', linkName);

Check failure on line 39 in blocks/cards/cards.js

View workflow job for this annotation

GitHub Actions / build

Expected an assignment or function call and instead saw an expression
} else {
div.className = 'cards-card-body';
}
Expand Down

0 comments on commit 5b34d29

Please sign in to comment.