Skip to content

Commit

Permalink
Check for saved lists element before trying to access it.
Browse files Browse the repository at this point in the history
This eliminates the JS error "savedListsEl is null" when save status check runs on a page that contains records that don't include the element (e.g. favorites).
  • Loading branch information
EreMaijala committed Aug 28, 2023
1 parent 2563165 commit e9abc28
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions themes/bootstrap3/js/check_save_statuses.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ VuFind.register("saveStatuses", function ItemStatuses() {
});

function checkSaveStatus(el) {
if (!userIsLoggedIn) {
const savedListsEl = el.querySelector(".savedLists");
if (!userIsLoggedIn || !savedListsEl) {
VuFind.emit("save-status-done");

return;
Expand All @@ -100,7 +101,6 @@ VuFind.register("saveStatuses", function ItemStatuses() {

el.classList.add("js-save-pending");

const savedListsEl = el.querySelector(".savedLists");
savedListsEl.classList.remove("loaded", "hidden");
savedListsEl.innerHTML +=
'<span class="js-load">' +
Expand Down

0 comments on commit e9abc28

Please sign in to comment.