From d2cbcc0b2194c9922cbae4d1585dcd81d70d1402 Mon Sep 17 00:00:00 2001 From: drunkwinter <38593134+drunkwinter@users.noreply.github.com> Date: Sat, 3 Aug 2024 10:38:18 +0200 Subject: [PATCH] [fix] this document requires 'TrustedHTML' assignment. --- src/utils/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/utils/index.js b/src/utils/index.js index bde7eb2..d3eac45 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -17,6 +17,18 @@ export class Deferred { } } +// WORKAROUND: TypeError: Failed to set the 'innerHTML' property on 'Element': This document requires 'TrustedHTML' assignment. +if (window.trustedTypes && trustedTypes.createPolicy) { + if (!trustedTypes.defaultPolicy) { + const passThroughFn = (x) => x; + trustedTypes.createPolicy('default', { + createHTML: passThroughFn, + createScriptURL: passThroughFn, + createScript: passThroughFn, + }); + } +} + export function createElement(tagName, options) { const node = document.createElement(tagName); options && Object.assign(node, options);