File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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>` ; } )
You can’t perform that action at this time.
0 commit comments