commit 59dae2d8f841a981c0b6958387568825c963d545
parent a3f32e775922b28e34a35e2d52a18cd881e6605c
Author: Hunter
Date: Thu, 18 Jun 2026 20:15:49 -0400
fix preview chrome leaking as text on unclosed tags
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/resources/js/main.js b/resources/js/main.js
@@ -222,8 +222,10 @@ function updatePreview() {
// Use srcdoc to create a completely fresh document context
// Expand <images> tag and rewrite bare stock image filenames
+ // Inject previewChrome via DOM after load (not string concat) so unclosed
+ // user tags like "<a" can't swallow the chrome and dump its CSS as text
const processedCode = expandImagesTag(rewriteBareImageSrcs(code.trim())) || '<!DOCTYPE html><html><head></head><body></body></html>';
- preview.srcdoc = processedCode + previewChrome;
+ preview.srcdoc = processedCode;
// Add our functionality after the iframe loads
const onLoad = () => {
@@ -231,6 +233,8 @@ function updatePreview() {
const doc = preview.contentDocument;
if (!doc) return;
+ (doc.body || doc.documentElement).insertAdjacentHTML('beforeend', previewChrome);
+
// Add click handlers for stock image table rows
const stockImageRows = doc.querySelectorAll('.stock-image-row');
stockImageRows.forEach(row => {