Skip to content

quality-debt: assets/js/template-previewer.js — PR #1222 review feedback (high) #1240

@superdav42

Description

@superdav42

Unactioned Review Feedback

Source PR: #1222
File: assets/js/template-previewer.js
Reviewers: coderabbit
Findings: 1
Max severity: high


HIGH: coderabbit (coderabbitai[bot])

File: assets/js/template-previewer.js:80
⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix iframe body lookup for iOS adjustments.

The current lookup targets the <iframe> element tree, not the iframe document, so the body class/style patch can fail and skip the iOS preview fix.

Suggested fix
-				const body = (_a2 = document.getElementById("iframe")) == null ? void 0 : _a2.getElementsByTagName("body")[ 0 ];
+				const iframeEl = document.getElementById("iframe");
+				const body = iframeEl && iframeEl.contentDocument ? iframeEl.contentDocument.body : null;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

			if (isIOS()) {
				const iframeEl = document.getElementById("iframe");
				const body = iframeEl && iframeEl.contentDocument ? iframeEl.contentDocument.body : null;
				body == null ? void 0 : body.classList.add("wu-fix-safari-preview");
				(body == null ? void 0 : body.style) && Object.assign(body.style, {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@assets/js/template-previewer.js` around lines 77 - 80, The iOS-specific patch
is looking up body on the iframe element subtree instead of the iframe's
document, so in isIOS() branch locate the iframe element (e.g., const iframeEl =
document.getElementById("iframe")), obtain its document via
iframeEl.contentDocument || iframeEl.contentWindow?.document, then get doc.body
and apply the class "wu-fix-safari-preview" and style adjustments to that body;
ensure you null-check iframeEl and the retrieved document before mutating to
avoid runtime errors.

View comment



Auto-generated by quality-feedback-helper.sh scan-merged. Review each finding and either fix the code or dismiss with a reason.


aidevops.sh v3.17.14 automated scan.

Metadata

Metadata

Assignees

Labels

origin:workerAuto-created by pulse labelless backfill (t2112)priority:highHigh severity — significant quality issuequality-debtUnactioned review feedback from merged PRssolved:workerTask was solved by a headless workersource:review-feedbackAuto-created by quality-feedback-helper.shstatus:in-reviewPR open, awaiting review/merge

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions