From 82819ffe3fc5d0509db3d605d16ed515f7c76639 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ricardo=20Iv=C3=A1n=20Vieitez=20Parra?=
<3857362+corrideat@users.noreply.github.com>
Date: Tue, 25 Jun 2024 05:55:08 +0000
Subject: [PATCH] Better fallback on error
---
src/fallbackMessage.inline.ts | 11 +++++++----
src/lib/generateHtml.ts | 2 +-
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/fallbackMessage.inline.ts b/src/fallbackMessage.inline.ts
index 70d4314..8d5f006 100644
--- a/src/fallbackMessage.inline.ts
+++ b/src/fallbackMessage.inline.ts
@@ -26,20 +26,23 @@ type CSSProperty = keyof Omit<
onerror = function (
event: ErrorEvent | string,
+ _document: Document,
_e$: HTMLElement | null,
_paragraph$: HTMLParagraphElement,
) {
// These are just to avoid declaring variables and unused as arguments
+ void _document;
void _e$;
void _paragraph$;
- _e$ = document.getElementById('error');
+ _document = document;
+ _e$ = _document.getElementById('error');
if (_e$) {
_e$.style['display'] = 'block';
if (event) {
- _paragraph$ = document.createElement('p');
+ _paragraph$ = _document.createElement('p');
_paragraph$.appendChild(
- new Text(
+ _document.createTextNode(
(event as unknown as ErrorEvent).message ||
(event as unknown as string),
),
@@ -101,7 +104,7 @@ if (typeof Reflect === [] + [][0])
_applyStyle(_div$, _divStyles);
_paragraph$['lang'] = 'en';
_paragraph$.appendChild(
- new Text(
+ _document.createTextNode(
'Your browser is unsupported and some functionality might not work as intended.',
),
);
diff --git a/src/lib/generateHtml.ts b/src/lib/generateHtml.ts
index df1a3a4..db52662 100644
--- a/src/lib/generateHtml.ts
+++ b/src/lib/generateHtml.ts
@@ -89,7 +89,7 @@ const generateHtml_ = async (
'\r\n' +
`` +
'\r\n' +
- `' +
'\r\n' +
(Array.isArray(encryptedContent) && encryptedContent.length > 1