@@ -106,29 +106,39 @@ export const panelsViewer = {
106106 const e = new XMLHttpRequest ( ) ;
107107 // @todo : look deeper into how we can refactor this particular code block
108108 /* eslint-disable */
109- e . onload = ( function ( i , panels , patternData , iframeRequest ) {
110- return function ( ) {
109+ e . onload = ( function ( i , panels , patternData , iframeRequest ) {
110+ return function ( ) {
111+
112+ // since non-existant files (such as .scss from plugin-tab) still return a 200, we need to instead inspect the contents
113+ // we look for responseText that starts with the doctype
114+ let rText = this . responseText
115+ if ( rText . startsWith ( '<!DOCTYPE html>' ) ) {
116+ rText = ''
117+ }
118+
111119 // use pretty to format HTML
112120 if ( panels [ i ] . name === 'HTML' ) {
113- templateFormatted = pretty ( this . responseText , { ocd : true } ) ;
121+ templateFormatted = pretty ( rText , { ocd : true } ) ;
114122 } else {
115- templateFormatted = this . responseText ;
123+ templateFormatted = rText ;
116124 }
117125
118126 const templateHighlighted = Prism . highlight (
119127 templateFormatted ,
120128 Prism . languages [ panels [ i ] . name . toLowerCase ( ) ] ||
121- Prism . languages [ 'markup' ]
129+ Prism . languages [ 'markup' ]
122130 // Prism.languages[panels[i].name.toLowerCase()],
123131 ) ;
124132
125- const codeTemplate = ( code , language ) =>
126- html `
133+ if ( templateHighlighted . )
134+
135+ const codeTemplate = ( code , language ) =>
136+ html `
127137 < pre
128138 class ="language-markup "
129139 > < code id ="pl-code-fill- ${ language } " class ="language- ${ language } "> ${ unsafeHTML (
130- code
131- ) } </ code > </ pre >
140+ code
141+ ) } </ code > </ pre >
132142 ` ;
133143
134144 const result = document . createDocumentFragment ( ) ;
0 commit comments