Skip to content

Commit

Permalink
Better fallback on error
Browse files Browse the repository at this point in the history
  • Loading branch information
corrideat committed Jun 25, 2024
1 parent e4d0015 commit 82819ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/fallbackMessage.inline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
Expand Down Expand Up @@ -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.',
),
);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/generateHtml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const generateHtml_ = async (
'\r\n' +
`<link rel="stylesheet" href="data:text/css;base64,${xmlEscapeAttr(bbtoa(cssText))}" crossorigin="anonymous" integrity="${xmlEscapeAttr(cssTextSriDigest)}" id="${xmlEscapeAttr(MAIN_STYLESHEET_ELEMENT_ID_)}"/>` +
'\r\n' +
`<script src="data:text/javascript;base64,${xmlEscapeAttr(loader.contentBase64)}" integrity="${xmlEscapeAttr(loader.sri)}" crossorigin="anonymous">` +
`<script src="data:text/javascript;base64,${xmlEscapeAttr(loader.contentBase64)}" defer="defer" integrity="${xmlEscapeAttr(loader.sri)}" crossorigin="anonymous">` +
'</script>' +
'\r\n' +
(Array.isArray(encryptedContent) && encryptedContent.length > 1
Expand Down

0 comments on commit 82819ff

Please sign in to comment.