Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix donutty.js #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

TemporaryTetra
Copy link

Check for HTMLElement does not work correctly if el is in an iframe. Since iframe creates a new space.

Therefore, in this case, it will be better to check if el exists in the document.

@simeydotme
Copy link
Owner

simeydotme commented Jan 15, 2021

Hi @TemporaryTetra I kind of get what the problem is, as window.HTMLElement is bound to the top window, and not the iFrame ... but your solution is totally missing the point in that the input parameter can be either;

  1. A string ( .myClass ); whereby doc.querySelectorAll() finds the parent
  2. An element ( HTMLElement ); whereby the element is used as-is for the parent
  3. Or empty; whereby the body element is used

By your code, the ability to pass in a HTMLElement reference would be broken altogether.

Copy link
Owner

@simeydotme simeydotme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make the change suggested and I can build and test

@@ -22,7 +22,7 @@

this.$wrapper = doc.querySelectorAll( el )[0];

} else if ( el instanceof window.HTMLElement ) {
} else if ( doc.querySelector( `.${el.className}` ) ) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be;

} else if (  el instanceof HTMLIFrameElement || el instanceof HTMLElement ) {

@TemporaryTetra
Copy link
Author

TemporaryTetra commented Jan 15, 2021 via email

@TemporaryTetra
Copy link
Author

TemporaryTetra commented Jan 15, 2021 via email

@simeydotme
Copy link
Owner

Sorry, I totally don't understand what that means, are you able to show me a reduced test case in CodeSandbox or something?

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.

None yet

2 participants