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

Revert "Don't wrap drag events in IE/Edge in dev builds" #6741

Merged
merged 1 commit into from
May 10, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions src/shared/utils/ReactErrorUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

var SyntheticDragEvent = require('SyntheticDragEvent');

var caughtError = null;

/**
Expand Down Expand Up @@ -67,11 +65,6 @@ if (__DEV__) {
typeof document.createEvent === 'function') {
var fakeNode = document.createElement('react');
ReactErrorUtils.invokeGuardedCallback = function(name, func, a, b) {
if (!canWrapEvent(a)) {
invokeGuardedCallback(name, func, a, b);
return;
}

var boundFunc = func.bind(null, a, b);
var evtType = `react-${name}`;
fakeNode.addEventListener(evtType, boundFunc, false);
Expand All @@ -81,41 +74,6 @@ if (__DEV__) {
fakeNode.removeEventListener(evtType, boundFunc, false);
};
}

var cacheCanWrapEvent = null;

/**
* IE and Edge don't allow access to the DataTransfer.dropEffect property when
* it's wrapped in another event. This function detects whether we're in an
* environment that behaves this way.
*
* @param {*} ev Event that is being tested
*/
function canWrapEvent(ev) {
if (!(ev instanceof SyntheticDragEvent)) {
return true;
} else if (cacheCanWrapEvent !== null) {
return cacheCanWrapEvent;
}

var canAccessDropEffect = false;
function handleWrappedEvent() {
try {
ev.dataTransfer.dropEffect; // eslint-disable-line no-unused-expressions
canAccessDropEffect = true;
} catch (e) {}
}

var wrappedEventName = 'react-wrappeddragevent';
var wrappedEvent = document.createEvent('Event');
wrappedEvent.initEvent(wrappedEventName, false, false);
fakeNode.addEventListener(wrappedEventName, handleWrappedEvent, false);
fakeNode.dispatchEvent(wrappedEvent);
fakeNode.removeEventListener(wrappedEventName, handleWrappedEvent, false);

cacheCanWrapEvent = canAccessDropEffect;
return canAccessDropEffect;
}
}

module.exports = ReactErrorUtils;