Skip to content

Commit

Permalink
fix: error when trying to disable animation
Browse files Browse the repository at this point in the history
  • Loading branch information
KuznetsovRoman committed Dec 4, 2024
1 parent 4184624 commit b702711
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/browser/client-scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function disableFrameAnimationsUnsafe() {

var styleElements = [];

util.forEachRoot(function (root) {
function appendDisableAnimationStyleElement(root) {
var styleElement = document.createElement("style");
styleElement.innerHTML =
everythingSelector +
Expand All @@ -176,6 +176,26 @@ function disableFrameAnimationsUnsafe() {

root.appendChild(styleElement);
styleElements.push(styleElement);
}

function createDefaultTrustedTypesPolicy() {
if (window.trustedTypes && window.trustedTypes.createPolicy) {
window.trustedTypes.createPolicy("default", {
createHTML: function (string) {
return string;
}
});
}
}

util.forEachRoot(function (root) {
try {
appendDisableAnimationStyleElement(root);
} catch (_) {
createDefaultTrustedTypesPolicy();

appendDisableAnimationStyleElement(root);
}
});

window.__cleanupAnimation = function () {
Expand Down

0 comments on commit b702711

Please sign in to comment.