question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

🚀 Feature request

Motivation

Hello there, I am evaluating Reakit to figure out if we can use it at work and one constraint we have is that we render our React application inside of an iframe and that when app code uses globals like document, these should be the iframe’s.

Example

This is one of the many examples:

https://github.com/reakit/reakit/blob/5f51e395835ae1d1c26fc97699d02197db6ba3eb/packages/reakit-utils/src/hasFocusWithin.ts#L1-L4

Here you are referencing the global document. The fix here is easy enough:

export function hasFocusWithin(element: Element) {
  const activeElement = element.ownerDocument.activeElement
  if (!activeElement) return false;
  return element.contains(activeElement);
}

Possible implementations

Basically every time you reference document or window etc you’d need it to get it from an element (ref?) within the frame. Probably another option is to provide those globals via context.

Thanks in advance for your time, and thank you for the library it looks promising!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
diegohazcommented, Apr 10, 2020

Only Portal left now! I’m not sure what to do with that as document is assigned at the module’s top-level scope.

Maybe just let people use PortalContext.Provider and pass their own container element.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"iframe" | Can I use... Support tables for HTML5, CSS3, etc
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
Read more >
<iframe>: The Inline Frame element - HTML - MDN Web Docs
The <iframe> HTML element represents a nested browsing context, embedding another ... If a browser does not support the srcdoc attribute, ...
Read more >
HTML iframe tag - W3Schools
The <iframe> tag specifies an inline frame. An inline frame is used to embed another document within the current HTML document.
Read more >
5 Best Browsers that Support iFrame [Ranked by Consistency]
What are the best browsers that support iFrame? · Opera – Comes with built-in VPN · Opera · Google Chrome – Popular choice...
Read more >
The ultimate guide to iframes - LogRocket Blog
Not a fan of iframes? This post provides an overview of the tag's best features, shows you how to use them, and how...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found