Skip to content

Commit

Permalink
Perform the check in the right place when used in iframes (#850)
Browse files Browse the repository at this point in the history
  • Loading branch information
dej611 authored and darthtrevino committed Sep 6, 2017
1 parent 312269a commit 05d9800
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/react-dnd-html5-backend/src/HTML5Backend.js
Expand Up @@ -44,6 +44,7 @@ export default class HTML5Backend {
this.endDragIfSourceWasRemovedFromDOM = this.endDragIfSourceWasRemovedFromDOM.bind(this);
this.endDragNativeItem = this.endDragNativeItem.bind(this);
this.asyncEndDragNativeItem = this.asyncEndDragNativeItem.bind(this);
this.isNodeInDocument = this.isNodeInDocument.bind(this);
}

get window() {
Expand Down Expand Up @@ -236,9 +237,16 @@ export default class HTML5Backend {
this.currentNativeSource = null;
}

isNodeInDocument(node) {
// Check the node either in the main document or in the current context
return document.body.contains(node) || this.window
? this.window.document.body.contains(node)
: false;
}

endDragIfSourceWasRemovedFromDOM() {
const node = this.currentDragSourceNode;
if (document.body.contains(node)) {
if (this.isNodeInDocument(node)) {
return;
}

Expand Down

0 comments on commit 05d9800

Please sign in to comment.