fix for trusted types (#444)

This commit is contained in:
ishmeals
2024-06-10 17:12:58 -04:00
committed by GitHub
parent c71fae01e9
commit 96a35a8f1e

View File

@@ -1146,7 +1146,19 @@ function createHintMarkersForGroups(groups) {
for (let i = 0; i < hintMarkers.length; i++) {
const hintMarker = hintMarkers[i];
hintMarker.hintString = hintStrings[i];
hintMarker.element.innerHTML = hintMarker.hintString.toUpperCase();
try {
hintMarker.element.innerHTML = hintMarker.hintString.toUpperCase();
} catch (e) {
// Ensure trustedTypes is available
if (typeof trustedTypes !== 'undefined') {
const escapeHTMLPolicy = trustedTypes.createPolicy("default", {
createHTML: (string) => string,
});
hintMarker.element.innerHTML = escapeHTMLPolicy.createHTML(hintMarker.hintString.toUpperCase());
} else {
console.error("trustedTypes is not supported in this environment.");
}
}
}
return hintMarkers;