Skip to content

Commit e31f485

Browse files
Fixed warnings
1 parent 7d9c594 commit e31f485

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

www/file-test.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,14 @@ <h1>File Type Viewer</h1>
305305
filePathDisplay.innerHTML = `<span>${path}</span>`;
306306

307307
if (kind === 'image') {
308-
contentArea.innerHTML = `<img src="${path}" alt="test ${ext}" onerror="this.outerHTML='<span style=color:#555;font-family:monospace;font-size:.8rem>file not found: ${path}</span>'">`;
309-
} else if (kind === 'text') {
308+
const image = document.createElement('img');
309+
image.src = path;
310+
image.alt = `test ${ext}`;
311+
image.onerror = () => {
312+
image.outerHTML = `<span style="color:#4a6080;font-family:monospace;font-size:.8rem">file not found: ${path}</span>`;
313+
};
314+
contentArea.innerHTML = '';
315+
contentArea.appendChild(image); } else if (kind === 'text') {
310316
fetch(path)
311317
.then(response => { if (!response.ok) { throw new Error('not found'); } return response.text(); })
312318
.then(responseText => { contentArea.innerHTML = `<pre>${escapeHtml(responseText)}</pre>`; })

0 commit comments

Comments
 (0)