Conversation
- The widget is now not displayed inside iframes if the iframe is displayed on the same origin as the main window. This prevents the widget from being displayed multiple times. - The widget will wait for the `DOMContentLoaded` event to occur if `document.body` does not yet exist.
WalkthroughThe changes update the widget initialization logic to prevent it from running in same-origin iframes and to defer setup until the DOM is ready if Changes
Sequence Diagram(s)sequenceDiagram
participant Browser
participant CookieConsentWrapperFactory
participant CookieConsentWrapper
Browser->>CookieConsentWrapperFactory: Load script
CookieConsentWrapperFactory->>CookieConsentWrapperFactory: #shouldInit()
alt Should initialize
CookieConsentWrapperFactory->>CookieConsentWrapper: init(window, document)
CookieConsentWrapper->>CookieConsentWrapper: Check config & document.body
alt document.body exists
CookieConsentWrapper->>CookieConsentWrapper: doInitCookieConsent()
else document.body missing
CookieConsentWrapper->>Browser: Wait for DOMContentLoaded
Browser->>CookieConsentWrapper: DOMContentLoaded event
CookieConsentWrapper->>CookieConsentWrapper: doInitCookieConsent()
end
else Should NOT initialize
CookieConsentWrapperFactory-->>Browser: Skip initialization
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🧰 Additional context used🧠 Learnings (2)📚 Learning: the cookie-consent plugin is designed to run in the main window only, so cross-realm javascript conc...Applied to files:
📚 Learning: in the cookie-consent project, the checkvisibility utility function intentionally only checks for di...Applied to files:
🔇 Additional comments (4)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Summary by CodeRabbit