Skip to content

Fix isNodeInDocument for HTML5Backend when used in iframes#3271

Merged
darthtrevino merged 1 commit into
react-dnd:mainfrom
istateside:fix-is-node-in-document-for-iframes
Aug 6, 2021
Merged

Fix isNodeInDocument for HTML5Backend when used in iframes#3271
darthtrevino merged 1 commit into
react-dnd:mainfrom
istateside:fix-is-node-in-document-for-iframes

Conversation

@istateside

@istateside istateside commented Jul 30, 2021

Copy link
Copy Markdown
Contributor

The isNodeInDocument function is used to check if a node was detached during a drag event. It checks to make sure this.document.body is defined, but then checks if document.body contains the given node.

When this library is used within an iframe, document in the global context may not be the same as this.document. This commit updates the check to use this.document.body, which should correctly check against the current context instead of the global document.

The isNodeInDocument function is used to check if a node was detached
during a drag event. It checks to make sure this `this.document.body` is
defined, but then checks if `document.body` contains the given node.

When used within an iframe, `document` in the global context may not be
the same as `this.document`. This commit updates the check to use
`this.document.body`.
@istateside

Copy link
Copy Markdown
Contributor Author

Hey @darthtrevino , any chance I can get a review on this?

@darthtrevino

Copy link
Copy Markdown
Member

Looks great, I'll merge on Sunday when I'm back from backpacking

@darthtrevino darthtrevino merged commit ce9a390 into react-dnd:main Aug 6, 2021
@istateside

Copy link
Copy Markdown
Contributor Author

@darthtrevino sorry for another ping, but could we cut a new release to get this code up for public use?

darthtrevino pushed a commit that referenced this pull request Feb 3, 2022
The isNodeInDocument function is used to check if a node was detached
during a drag event. It checks to make sure this `this.document.body` is
defined, but then checks if `document.body` contains the given node.

When used within an iframe, `document` in the global context may not be
the same as `this.document`. This commit updates the check to use
`this.document.body`.
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.

2 participants