Skip to content

Conversation

jayelkaake
Copy link

How to recreate the issue

Load glide in an iframe

What I Did

I changed the exist() method to use duck-typing instead of a null check.

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.

Comment on lines +31 to +32
// 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) {

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 using ownerDocument.defaultView. Mostly I'm adding the comment because it seems like ownerDocument and defaultView are oft overlooked features of the DOM.

Suggested change
// 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) return false
const nodeWindow = node.ownerDocument?.defaultView
if (nodeWindow && node instanceof nodeWindow.HTMLElement) {

I’d also probably just return the test nodeWindow && node instanceof nodeWindow.HTMLElement directly and eliminate the following returns but couldn’t do that in the scope of the suggestion.

@jedrzejchalubek
Copy link
Member

Should be fixed with v3.6.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants