GH#1240: fix: correct iframe body lookup for iOS adjustments#1245
Conversation
Completion Summary
aidevops.sh v3.17.18 plugin for OpenCode v1.15.6 with claude-haiku-4-5 spent 57s and 2,672 tokens on this as a headless worker. |
📝 WalkthroughWalkthroughThe ChangesiOS Safari Preview Iframe Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with 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.
Inline comments:
In `@assets/js/template-previewer.js`:
- Around line 77-78: The iframe body lookup currently only uses
iframeEl.contentDocument and can miss the document on some platforms (e.g. iOS);
update the lookup to fallback to iframeEl.contentWindow?.document and then grab
.body from that document, reusing the existing iframe reference (the previously
created iframe variable) instead of re-querying the DOM; ensure the logic sets
body = (iframeEl.contentDocument || iframeEl.contentWindow?.document)?.body so
the iOS patch runs reliably.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d53dd648-964d-44a0-8e81-c6f0f52ceae6
📒 Files selected for processing (1)
assets/js/template-previewer.js
| const iframeEl = document.getElementById("iframe"); | ||
| const body = iframeEl && iframeEl.contentDocument ? iframeEl.contentDocument.body : null; |
There was a problem hiding this comment.
Add iframe document fallback to avoid silently skipping the iOS patch.
At Line 78, using only contentDocument can still miss the iframe body in some cases. Use contentWindow?.document as fallback (and reuse the existing iframe reference from Line 61).
Suggested patch
- const iframeEl = document.getElementById("iframe");
- const body = iframeEl && iframeEl.contentDocument ? iframeEl.contentDocument.body : null;
+ const iframe_doc = (iframe == null ? void 0 : iframe.contentDocument) || (iframe == null ? void 0 : iframe.contentWindow == null ? void 0 : iframe.contentWindow.document);
+ const body = iframe_doc ? iframe_doc.body : null;🤖 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 - 78, The iframe body lookup
currently only uses iframeEl.contentDocument and can miss the document on some
platforms (e.g. iOS); update the lookup to fallback to
iframeEl.contentWindow?.document and then grab .body from that document, reusing
the existing iframe reference (the previously created iframe variable) instead
of re-querying the DOM; ensure the logic sets body = (iframeEl.contentDocument
|| iframeEl.contentWindow?.document)?.body so the iOS patch runs reliably.
Completion Summary
aidevops.sh v3.17.18 plugin for OpenCode v1.15.6 with claude-haiku-4-5 spent 57s and 2,672 tokens on this as a headless worker. Merged via PR #1245 to main. |
|
Performance Test Results Performance test results for 68cf829 are in 🛎️! Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown. URL:
|
Summary
Implementation for issue #1240.
Files Changed
assets/js/template-previewer.js
Runtime Testing
Resolves #1240
aidevops.sh v3.17.18 plugin for OpenCode v1.15.6 with claude-haiku-4-5 spent 50s and 2,672 tokens on this as a headless worker.
Summary by CodeRabbit