fix preview chrome leaking as text on unclosed tags
Hunter
Thursday, June 18th, 2026 at 8:15 PM
222
223 // Use srcdoc to create a completely fresh document context
224 // Expand <images> tag and rewrite bare stock image filenames
225 + // Inject previewChrome via DOM after load (not string concat) so unclosed
226 + // user tags like "<a" can't swallow the chrome and dump its CSS as text
227 const processedCode = expandImagesTag(rewriteBareImageSrcs(code.trim())) || '<!DOCTYPE html><html><head></head><body></body></html>';
- preview.srcdoc = processedCode + previewChrome;
228 + preview.srcdoc = processedCode;
229
230 // Add our functionality after the iframe loads
231 const onLoad = () => {
233 const doc = preview.contentDocument;
234 if (!doc) return;
235
236 + (doc.body || doc.documentElement).insertAdjacentHTML('beforeend', previewChrome);
237 +
238 // Add click handlers for stock image table rows
239 const stockImageRows = doc.querySelectorAll('.stock-image-row');
240 stockImageRows.forEach(row => {