fix: innerHTML trusted-types

This commit is contained in:
JellyBrick
2024-11-03 18:16:36 +09:00
parent aab9358d67
commit 516fbff3d7
6 changed files with 51 additions and 16 deletions

View File

@ -8,6 +8,8 @@ import { LoggerPrefix } from '@/utils';
import { t } from '@/i18n';
import { defaultTrustedTypePolicy } from '@/utils/trusted-types';
import { ElementFromHtml } from '../utils/renderer';
import type { RendererContext } from '@/types/contexts';
@ -108,7 +110,9 @@ export const onRendererLoad = ({
ipc.on('downloader-feedback', (feedback: string) => {
if (progress) {
const targetHtml = feedback || t('plugins.downloader.templates.button');
progress.innerHTML = window.trustedTypes?.defaultPolicy ? window.trustedTypes.defaultPolicy.createHTML(targetHtml) : targetHtml;
(progress.innerHTML as string | TrustedHTML) = defaultTrustedTypePolicy
? defaultTrustedTypePolicy.createHTML(targetHtml)
: targetHtml;
} else {
console.warn(
LoggerPrefix,