Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork772
Fix issue #523 - "Slider cannot be initialized in iframe"#675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| // We are usine duck-typing here because we can't use `instanceof` since if we're in an iframe the class instance will be different. | ||
| if(node&&node.appendChild&&node.isConnected){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I agree that this seems like a better fix. However, I think it would be possible to avoid duck-typing by usingownerDocument.defaultView. Mostly I'm adding the comment because it seems likeownerDocument anddefaultView are oft overlooked features of the DOM.
| // We are usine duck-typing here because we can't use `instanceof` since if we're in an iframe the class instance will be different. | |
| if(node&&node.appendChild&&node.isConnected){ | |
| if(!node)returnfalse | |
| constnodeWindow=node.ownerDocument?.defaultView | |
| if(nodeWindow&&nodeinstanceofnodeWindow.HTMLElement){ |
I’d also probably just return the testnodeWindow && node instanceof nodeWindow.HTMLElement directly and eliminate the following returns but couldn’t do that in the scope of the suggestion.
jedrzejchalubek commentedJul 4, 2024
Should be fixed withv3.6.2 |
How to recreate the issue
Load glide in an iframe
What I Did
I changed the
exist()method to use duck-typing instead of anullcheck.The work that@ericmorand did in pull request#669 did not fully solve the problem, and also sort of makes it possible to pass invalid objects, so was not a preferred solution. Thanks for leading me in the right direction though@ericmorand!
How was it tested
Loaded in iframe and out of iframe.