Skip to content

Commit

Permalink
[fix] this document requires 'TrustedHTML' assignment.
Browse files Browse the repository at this point in the history
  • Loading branch information
drunkwinter committed Aug 3, 2024
1 parent b7c94ab commit d2cbcc0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d2cbcc0

Please sign in to comment.