-
Notifications
You must be signed in to change notification settings - Fork 1k
Make window & document references iframe-aware #177
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
Conversation
Interesting - thanks for this PR! Could you please remove the built files? I prefer PRs to be source-only, then I will rebuild and release in the same commit as the tag. Regarding the |
Yeah, that’s what I alluded to in the PR comment. I’ll make that change, squash, and force update with that change. Also, I’ll remove the built files. |
Quick question: what kind of browser support do you aim for? var doc = el.ownerDocument;
var win = 'defaultView' in doc ? doc.defaultView : doc.parentWindow; |
I don't care for IE8 at this point. Some Babel transforms are beginning to break IE8 as well. I don't see the need. |
React 15.2.0 changed propType validation warning text: https://github.com./facebook/react/blob/master/CHANGELOG.md#1520-july-1-2 016
Use the ownerDocument and window of the DOM element being manipulated rather than the global window and document objects. This makes react-draggable work with a tool like https://github.com./ryanseddon/react-frame-component
Ok, so I removed the built files and updated the By the way, in our use case, we are also running into #170. But I noticed that #173, which attempts to resolve that issue, relies on the global |
Do you want me to have a go at writing a few tests for this behavior? It should be trivial to pull in the |
Also, I’ll rebase. |
Actually wait a bit - I was actually going to push a few updates to this in just a moment. |
Sure thing. And thanks! |
Closed in #180 - thought it was easier to do so now with all the changes going through. Would love a working test though - could you make a new PR for that based off Thanks for the help. |
Definitely. How do you feel about adding the devDependency on react-frame-component? I’d peg it to |
Yeah that's fine as a devDep. |
This PR uses the DOM element’s
ownerDocument
rather than the globaldocument
orwindow
to makereact-draggable
work across iframes. In our use case, we have an app being rendered into an iframe with React Frame Component, so the DOM elements are in a separate document from the document where the React elements are being executed.I chose to replace the
instanceOf Node
check with a simple duck-typing check (https://github.com./mzabriskie/react-draggable/compare/master...Brandcast:iframe?expand=1#diff-9f4a38358e68eff5cf48eda850801a7aL190), which could be adapted to whatever type of conditional. It would even do the same check, but to work across iframes, it would need to first find thewindow
object relative toe.target
. Let me know if you want me to change or update that.