diff --git a/src/features/accesskit/visible_alt_text.js b/src/features/accesskit/visible_alt_text.js index 9ed2a2666..4e7a2a627 100644 --- a/src/features/accesskit/visible_alt_text.js +++ b/src/features/accesskit/visible_alt_text.js @@ -26,8 +26,10 @@ const processImages = function (imageElements) { const imageBlocks = new Map(); imageElements.forEach(imageElement => { const { alt } = imageElement; - const imageBlock = imageElement.closest(imageBlockSelector); - imageBlocks.set(imageBlock, alt); + if (alt) { + const imageBlock = imageElement.closest(imageBlockSelector); + imageBlocks.set(imageBlock, alt); + } }); for (const [imageBlock, alt] of imageBlocks) {