Skip to content

Commit

Permalink
Fix timing issue in RecordCoverImageTest. (vufind-org#4127)
Browse files Browse the repository at this point in the history
Co-authored-by: Thomas Wagener <[email protected]>
  • Loading branch information
demiankatz and ThoWagen authored Dec 3, 2024
1 parent dc17ec1 commit 6f1f43e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function testCoverLoading(
$this->waitForPageLoad($page);
$session->wait(
$this->getDefaultTimeout(),
'document.querySelector("img.recordcover").complete && document.querySelector("img.recordcover").src'
'document.querySelector("img.recordcover").dataset.loaded !== undefined'
);
// Verify the expected backlink (or lack thereof):
$backlinkSelector = 'p.cover-source';
Expand Down
13 changes: 8 additions & 5 deletions themes/bootstrap3/js/covers.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,14 @@ VuFind.register('covers', function covers() {
function checkLoaded(container) {
container.querySelectorAll('.recordcover').forEach(
(img) => {
img.addEventListener('load', () => {
if (img.getBoundingClientRect().width < 2) {
img.classList.add('hidden');
}
});
if (img.dataset.loaded === undefined) {
img.addEventListener('load', () => {
if (img.getBoundingClientRect().width < 2) {
img.classList.add('hidden');
}
img.dataset.loaded = 'true';
});
}
}
);
}
Expand Down
13 changes: 8 additions & 5 deletions themes/bootstrap5/js/covers.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,14 @@ VuFind.register('covers', function covers() {
function checkLoaded(container) {
container.querySelectorAll('.recordcover').forEach(
(img) => {
img.addEventListener('load', () => {
if (img.getBoundingClientRect().width < 2) {
img.classList.add('hidden');
}
});
if (img.dataset.loaded === undefined) {
img.addEventListener('load', () => {
if (img.getBoundingClientRect().width < 2) {
img.classList.add('hidden');
}
img.dataset.loaded = 'true';
});
}
}
);
}
Expand Down

0 comments on commit 6f1f43e

Please sign in to comment.