Handle createPolicy gracefully (#2031)
This commit is contained in:
@@ -1882,12 +1882,17 @@ function createHintMarkersForGroups(groups) {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Ensure trustedTypes is available
|
// Ensure trustedTypes is available
|
||||||
if (typeof trustedTypes !== "undefined") {
|
if (typeof trustedTypes !== "undefined") {
|
||||||
const escapeHTMLPolicy = trustedTypes.createPolicy("default", {
|
try {
|
||||||
createHTML: (string) => string,
|
const escapeHTMLPolicy = trustedTypes.createPolicy("hint-policy", {
|
||||||
});
|
createHTML: (string) => string,
|
||||||
hintMarker.element.innerHTML = escapeHTMLPolicy.createHTML(
|
});
|
||||||
hintMarker.hintString.toUpperCase(),
|
hintMarker.element.innerHTML = escapeHTMLPolicy.createHTML(
|
||||||
);
|
hintMarker.hintString.toUpperCase(),
|
||||||
|
);
|
||||||
|
} catch (policyError) {
|
||||||
|
console.warn("Could not create trusted types policy:", policyError);
|
||||||
|
// Skip updating the hint marker if policy creation fails
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error("trustedTypes is not supported in this environment.");
|
console.error("trustedTypes is not supported in this environment.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user