fix: add null checks for document.documentElement (fixes #1049)#1060
fix: add null checks for document.documentElement (fixes #1049)#1060jibin7jose wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughTheme handling and app-shell bootstrap scripts now guard against missing ChangesDOM access guards
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 |
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 `@src/routes/__root.tsx`:
- Line 47: Update the GA loader inside GOOGLE_ANALYTICS_BOOTSTRAP so loaded is
set to true only after a script is successfully appended to a valid parent. When
document.head is unavailable, avoid consuming the one-shot callback and retry
later or use a safe fallback insertion parent, ensuring analytics eventually
loads.
🪄 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: 8e3cbee5-869d-4a24-b344-b40f4334c5f0
📒 Files selected for processing (2)
src/components/ThemeProvider.tsxsrc/routes/__root.tsx
Closes #1049
Description
This PR resolves an issue where the application would throw a
TypeError: Cannot read properties of null (reading 'className')ordocument.documentElement is null. This typically occurs in environments (like some browser extensions or specific contexts) where the DOM is not yet fully initialized ordocument.documentElementevaluates to null.Changes Made
document.documentElementinsideupdateThemeClassinThemeProvider.tsx.document.documentElementingetHtmlClass(ThemeProvider.tsx).THEME_BOOTSTRAPandGOOGLE_ANALYTICS_BOOTSTRAPscripts in__root.tsxto verifydocument.documentElementanddocument.headexist before trying to read from or write to them.Testing
document.documentElementis null.Summary by CodeRabbit
Summary by CodeRabbit