Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
jayelkaake wants to merge1 commit intoglidejs:master
base:master
Choose a base branch
Loading
fromferacommerce:FixIssue523-CantLoadInIframe

Conversation

@jayelkaake
Copy link

How to recreate the issue

Load glide in an iframe

What I Did

I changed theexist() method to use duck-typing instead of anull 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 usingownerDocument.defaultView. Mostly I'm adding the comment because it seems likeownerDocument anddefaultView 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)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
Copy link
Member

Should be fixed withv3.6.2

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

Reviewers

1 more reviewer

@stokesmanstokesmanstokesman left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@jayelkaake@jedrzejchalubek@stokesman

[8]ページ先頭

©2009-2025 Movatter.jp