Skip to content

Commit

Permalink
add excemption to icon-decoration in order to convert hh:mm:ss back t…
Browse files Browse the repository at this point in the history
…o its original text
  • Loading branch information
berwa committed Oct 2, 2024
1 parent 9deff38 commit b383efc
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions scripts/aem.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,23 @@ function decorateIcon(span, prefix = '', alt = '') {
const iconName = Array.from(span.classList)
.find((c) => c.startsWith('icon-'))
.substring(5);
const img = document.createElement('img');
img.dataset.iconName = iconName;
img.src = `${window.hlx.codeBasePath}${prefix}/icons/${iconName}.svg`;
img.alt = alt;
img.loading = 'lazy';
// BEGIN CHANGE TechDivision
img.setAttribute('aria-label', alt !== '' ? alt : iconName);
// END CHANGE TechDivision
span.append(img);
// handle special case of hh:mm:ss which would generate an "icon" mm
if (iconName === 'mm') {
// replace the server-side rendered icon-span by the original text
span.replaceWith(document.createTextNode(':mm:'));
} else {
// END CHANGE TechDivision
const img = document.createElement('img');
img.dataset.iconName = iconName;
img.src = `${window.hlx.codeBasePath}${prefix}/icons/${iconName}.svg`;
img.alt = alt;
img.loading = 'lazy';
// BEGIN CHANGE TechDivision
img.setAttribute('aria-label', alt !== '' ? alt : iconName);
// END CHANGE TechDivision
span.append(img);
}
}

/**
Expand Down

0 comments on commit b383efc

Please sign in to comment.