Skip to content

Commit 9310021

Browse files
committed
fix(unity-bootstrap-theme): add retry logic to initCardBoodies to for .card-body elemtns
UDS-2010
1 parent b512a85 commit 9310021

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/unity-bootstrap-theme/src/js/card-bodies.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ import { EventHandler } from "./bootstrap-helper";
1010
function initCardBodies() {
1111

1212
const cardBodies = document.querySelectorAll('.card-body');
13+
14+
// If there are no cardBodies and you have not yet exceeded 3 retries
15+
if (cardBodies.length === 0 && retryCount < 3) {
16+
setTimeout(() => initCardBodies(retryCount + 1), 500);
17+
return;
18+
}
19+
20+
// If after 3 attempts there are still no cardBodies, we simply exit
21+
if (cardBodies.length === 0) {
22+
console.warn('No .card-body found after 3 retries.');
23+
return;
24+
}
25+
1326
cardBodies.forEach((cardBody, index) => {
1427
const paragraph = cardBody.querySelector('div p');
1528
const originalText = paragraph.textContent;

0 commit comments

Comments
 (0)