Skip to content

Commit

Permalink
Fix setting of HTML contents in JS to run inline scripts properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
EreMaijala committed Aug 22, 2024
1 parent d942971 commit ceaa741
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion themes/bootstrap3/js/check_item_statuses.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ VuFind.register('itemStatuses', function ItemStatuses() {
) {
// Full status mode is on -- display the HTML and hide extraneous junk:
callnumAndLocations.forEach((callnumAndLocation) => {
callnumAndLocation.innerHTML = VuFind.updateCspNonce(result.full_status);
VuFind.setElementContents(callnumAndLocation, VuFind.updateCspNonce(result.full_status));
});
el.querySelectorAll('.callnumber,.hideIfDetailed,.location,.status').forEach((e) => { e.classList.add('hidden'); });
} else if (typeof(result.missing_data) !== 'undefined'
Expand Down
4 changes: 2 additions & 2 deletions themes/bootstrap3/js/hierarchy_tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ VuFind.register('hierarchyTree', function HierarchyTree() {
const queryParams = new URLSearchParams({id: id, source: treeEl.dataset.source});
fetch(VuFind.path + '/Hierarchy/GetRecord?' + queryParams.toString())
.then((response) => response.text())
.then((content) => recordEl.innerHTML = VuFind.updateCspNonce(content) );
.then((content) => VuFind.setElementContents(recordEl, VuFind.updateCspNonce(content)) );
return true;
}

Expand Down Expand Up @@ -239,7 +239,7 @@ VuFind.register('hierarchyTree', function HierarchyTree() {
if (loadIndicatorEl) {
loadIndicatorEl.classList.add('hidden');
}
treePlaceholderEl.outerHTML = VuFind.updateCspNonce(json.html);
VuFind.setElementContents(treePlaceholderEl, VuFind.updateCspNonce(json.html), {}, 'outerHTML');
setupTree(containerEl);
})
.catch(() => {
Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap5/js/check_item_statuses.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ VuFind.register('itemStatuses', function ItemStatuses() {
) {
// Full status mode is on -- display the HTML and hide extraneous junk:
callnumAndLocations.forEach((callnumAndLocation) => {
callnumAndLocation.innerHTML = VuFind.updateCspNonce(result.full_status);
VuFind.setElementContents(callnumAndLocation, VuFind.updateCspNonce(result.full_status));
});
el.querySelectorAll('.callnumber,.hideIfDetailed,.location,.status').forEach((e) => { e.classList.add('hidden'); });
} else if (typeof(result.missing_data) !== 'undefined'
Expand Down
4 changes: 2 additions & 2 deletions themes/bootstrap5/js/hierarchy_tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ VuFind.register('hierarchyTree', function HierarchyTree() {
const queryParams = new URLSearchParams({id: id, source: treeEl.dataset.source});
fetch(VuFind.path + '/Hierarchy/GetRecord?' + queryParams.toString())
.then((response) => response.text())
.then((content) => recordEl.innerHTML = VuFind.updateCspNonce(content) );
.then((content) => VuFind.setElementContents(recordEl, VuFind.updateCspNonce(content)) );
return true;
}

Expand Down Expand Up @@ -239,7 +239,7 @@ VuFind.register('hierarchyTree', function HierarchyTree() {
if (loadIndicatorEl) {
loadIndicatorEl.classList.add('hidden');
}
treePlaceholderEl.outerHTML = VuFind.updateCspNonce(json.html);
VuFind.setElementContents(treePlaceholderEl, VuFind.updateCspNonce(json.html), {}, 'outerHTML');
setupTree(containerEl);
})
.catch(() => {
Expand Down

0 comments on commit ceaa741

Please sign in to comment.