react 15.0.3-alpha.2 → 15.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/react-with-addons.js +1494 -928
  2. package/dist/react-with-addons.min.js +6 -6
  3. package/dist/react.js +1463 -1344
  4. package/dist/react.min.js +6 -6
  5. package/lib/CSSPropertyOperations.js +5 -5
  6. package/lib/DOMChildrenOperations.js +34 -6
  7. package/lib/DOMLazyTree.js +6 -1
  8. package/lib/DOMPropertyOperations.js +22 -13
  9. package/lib/LinkedStateMixin.js +1 -0
  10. package/lib/ReactCSSTransitionGroup.js +5 -0
  11. package/lib/ReactChildren.js +9 -1
  12. package/lib/ReactClass.js +1 -0
  13. package/lib/ReactComponentBrowserEnvironment.js +0 -5
  14. package/lib/ReactComponentTreeDevtool.js +140 -0
  15. package/lib/ReactComponentWithPureRenderMixin.js +2 -0
  16. package/lib/ReactCompositeComponent.js +147 -18
  17. package/lib/ReactDOM.js +1 -4
  18. package/lib/ReactDOMComponent.js +46 -6
  19. package/lib/ReactDOMIDOperations.js +0 -5
  20. package/lib/ReactDOMInput.js +4 -2
  21. package/lib/ReactDOMTextComponent.js +7 -6
  22. package/lib/ReactDebugTool.js +162 -10
  23. package/lib/ReactDefaultInjection.js +0 -9
  24. package/lib/ReactElement.js +26 -0
  25. package/lib/ReactErrorUtils.js +65 -15
  26. package/lib/ReactFragment.js +5 -2
  27. package/lib/ReactInjection.js +0 -2
  28. package/lib/ReactLink.js +3 -0
  29. package/lib/ReactMount.js +19 -7
  30. package/lib/ReactMultiChild.js +21 -0
  31. package/lib/ReactNativeDOMIDOperations.js +3 -6
  32. package/lib/ReactNativeMount.js +18 -7
  33. package/lib/ReactNativeOperationHistoryDevtool.js +32 -0
  34. package/lib/ReactNativeTextComponent.js +8 -0
  35. package/lib/ReactPerf.js +397 -75
  36. package/lib/ReactReconciler.js +46 -5
  37. package/lib/ReactServerRendering.js +16 -1
  38. package/lib/ReactTestUtils.js +4 -0
  39. package/lib/ReactTransitionGroup.js +5 -0
  40. package/lib/ReactUpdates.js +21 -3
  41. package/lib/ReactVersion.js +1 -1
  42. package/lib/ReactWithAddons.js +1 -1
  43. package/lib/findDOMNode.js +2 -0
  44. package/lib/instantiateReactComponent.js +32 -1
  45. package/lib/onlyChild.js +7 -4
  46. package/lib/shallowCompare.js +1 -0
  47. package/lib/update.js +4 -0
  48. package/package.json +1 -1
  49. package/lib/ReactDebugInstanceMap.js +0 -102
  50. package/lib/ReactDefaultPerf.js +0 -316
  51. package/lib/ReactDefaultPerfAnalysis.js +0 -210
@@ -13,7 +13,6 @@
13
13
 
14
14
  var DOMChildrenOperations = require('./DOMChildrenOperations');
15
15
  var ReactDOMComponentTree = require('./ReactDOMComponentTree');
16
- var ReactPerf = require('./ReactPerf');
17
16
 
18
17
  /**
19
18
  * Operations used to process updates to DOM nodes.
@@ -32,8 +31,4 @@ var ReactDOMIDOperations = {
32
31
  }
33
32
  };
34
33
 
35
- ReactPerf.measureMethods(ReactDOMIDOperations, 'ReactDOMIDOperations', {
36
- dangerouslyProcessChildrenUpdates: 'dangerouslyProcessChildrenUpdates'
37
- });
38
-
39
34
  module.exports = ReactDOMIDOperations;
@@ -85,6 +85,8 @@ var ReactDOMInput = {
85
85
  if (process.env.NODE_ENV !== 'production') {
86
86
  LinkedValueUtils.checkPropTypes('input', props, inst._currentElement._owner);
87
87
 
88
+ var owner = inst._currentElement._owner;
89
+
88
90
  if (props.valueLink !== undefined && !didWarnValueLink) {
89
91
  process.env.NODE_ENV !== 'production' ? warning(false, '`valueLink` prop on `input` is deprecated; set `value` and `onChange` instead.') : void 0;
90
92
  didWarnValueLink = true;
@@ -94,11 +96,11 @@ var ReactDOMInput = {
94
96
  didWarnCheckedLink = true;
95
97
  }
96
98
  if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) {
97
- process.env.NODE_ENV !== 'production' ? warning(false, 'Input elements must be either controlled or uncontrolled ' + '(specify either the checked prop, or the defaultChecked prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components') : void 0;
99
+ process.env.NODE_ENV !== 'production' ? warning(false, '%s contains an input of type %s with both checked and defaultChecked props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the checked prop, or the defaultChecked prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', owner && owner.getName() || 'A component', props.type) : void 0;
98
100
  didWarnCheckedDefaultChecked = true;
99
101
  }
100
102
  if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) {
101
- process.env.NODE_ENV !== 'production' ? warning(false, 'Input elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components') : void 0;
103
+ process.env.NODE_ENV !== 'production' ? warning(false, '%s contains an input of type %s with both value and defaultValue props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', owner && owner.getName() || 'A component', props.type) : void 0;
102
104
  didWarnValueDefaultValue = true;
103
105
  }
104
106
  warnIfValueIsNull(props);
@@ -16,7 +16,7 @@ var _assign = require('object-assign');
16
16
  var DOMChildrenOperations = require('./DOMChildrenOperations');
17
17
  var DOMLazyTree = require('./DOMLazyTree');
18
18
  var ReactDOMComponentTree = require('./ReactDOMComponentTree');
19
- var ReactPerf = require('./ReactPerf');
19
+ var ReactInstrumentation = require('./ReactInstrumentation');
20
20
 
21
21
  var escapeTextContentForBrowser = require('./escapeTextContentForBrowser');
22
22
  var invariant = require('fbjs/lib/invariant');
@@ -64,6 +64,8 @@ _assign(ReactDOMTextComponent.prototype, {
64
64
  */
65
65
  mountComponent: function (transaction, nativeParent, nativeContainerInfo, context) {
66
66
  if (process.env.NODE_ENV !== 'production') {
67
+ ReactInstrumentation.debugTool.onSetText(this._debugID, this._stringText);
68
+
67
69
  var parentInfo;
68
70
  if (nativeParent != null) {
69
71
  parentInfo = nativeParent._ancestorInfo;
@@ -127,6 +129,10 @@ _assign(ReactDOMTextComponent.prototype, {
127
129
  this._stringText = nextStringText;
128
130
  var commentNodes = this.getNativeNode();
129
131
  DOMChildrenOperations.replaceDelimitedText(commentNodes[0], commentNodes[1], nextStringText);
132
+
133
+ if (process.env.NODE_ENV !== 'production') {
134
+ ReactInstrumentation.debugTool.onSetText(this._debugID, nextStringText);
135
+ }
130
136
  }
131
137
  }
132
138
  },
@@ -161,9 +167,4 @@ _assign(ReactDOMTextComponent.prototype, {
161
167
 
162
168
  });
163
169
 
164
- ReactPerf.measureMethods(ReactDOMTextComponent.prototype, 'ReactDOMTextComponent', {
165
- mountComponent: 'mountComponent',
166
- receiveComponent: 'receiveComponent'
167
- });
168
-
169
170
  module.exports = ReactDOMTextComponent;
@@ -11,7 +11,9 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ReactInvalidSetStateWarningDevTool = require('./ReactInvalidSetStateWarningDevTool');
14
+ var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
15
+
16
+ var performanceNow = require('fbjs/lib/performanceNow');
15
17
  var warning = require('fbjs/lib/warning');
16
18
 
17
19
  var eventHandlers = [];
@@ -32,6 +34,57 @@ function emitEvent(handlerFunctionName, arg1, arg2, arg3, arg4, arg5) {
32
34
  }
33
35
  }
34
36
 
37
+ var isProfiling = false;
38
+ var flushHistory = [];
39
+ var currentFlushNesting = 0;
40
+ var currentFlushMeasurements = null;
41
+ var currentFlushStartTime = null;
42
+ var currentTimerDebugID = null;
43
+ var currentTimerStartTime = null;
44
+ var currentTimerType = null;
45
+
46
+ function resetMeasurements() {
47
+ if (process.env.NODE_ENV !== 'production') {
48
+ if (!isProfiling || currentFlushNesting === 0) {
49
+ currentFlushStartTime = null;
50
+ currentFlushMeasurements = null;
51
+ return;
52
+ }
53
+
54
+ var previousStartTime = currentFlushStartTime;
55
+ var previousMeasurements = currentFlushMeasurements || [];
56
+ var previousOperations = ReactNativeOperationHistoryDevtool.getHistory();
57
+
58
+ if (previousMeasurements.length || previousOperations.length) {
59
+ var registeredIDs = ReactComponentTreeDevtool.getRegisteredIDs();
60
+ flushHistory.push({
61
+ duration: performanceNow() - previousStartTime,
62
+ measurements: previousMeasurements || [],
63
+ operations: previousOperations || [],
64
+ treeSnapshot: registeredIDs.reduce(function (tree, id) {
65
+ var ownerID = ReactComponentTreeDevtool.getOwnerID(id);
66
+ var parentID = ReactComponentTreeDevtool.getParentID(id);
67
+ tree[id] = {
68
+ displayName: ReactComponentTreeDevtool.getDisplayName(id),
69
+ text: ReactComponentTreeDevtool.getText(id),
70
+ updateCount: ReactComponentTreeDevtool.getUpdateCount(id),
71
+ childIDs: ReactComponentTreeDevtool.getChildIDs(id),
72
+ // Text nodes don't have owners but this is close enough.
73
+ ownerID: ownerID || ReactComponentTreeDevtool.getOwnerID(parentID),
74
+ parentID: parentID
75
+ };
76
+ return tree;
77
+ }, {})
78
+ });
79
+ }
80
+
81
+ currentFlushStartTime = performanceNow();
82
+ currentFlushMeasurements = [];
83
+ ReactComponentTreeDevtool.purgeUnmountedComponents();
84
+ ReactNativeOperationHistoryDevtool.clearHistory();
85
+ }
86
+ }
87
+
35
88
  var ReactDebugTool = {
36
89
  addDevtool: function (devtool) {
37
90
  eventHandlers.push(devtool);
@@ -44,29 +97,128 @@ var ReactDebugTool = {
44
97
  }
45
98
  }
46
99
  },
100
+ beginProfiling: function () {
101
+ if (process.env.NODE_ENV !== 'production') {
102
+ if (isProfiling) {
103
+ return;
104
+ }
105
+
106
+ isProfiling = true;
107
+ flushHistory.length = 0;
108
+ resetMeasurements();
109
+ }
110
+ },
111
+ endProfiling: function () {
112
+ if (process.env.NODE_ENV !== 'production') {
113
+ if (!isProfiling) {
114
+ return;
115
+ }
116
+
117
+ isProfiling = false;
118
+ resetMeasurements();
119
+ }
120
+ },
121
+ getFlushHistory: function () {
122
+ if (process.env.NODE_ENV !== 'production') {
123
+ return flushHistory;
124
+ }
125
+ },
126
+ onBeginFlush: function () {
127
+ if (process.env.NODE_ENV !== 'production') {
128
+ currentFlushNesting++;
129
+ resetMeasurements();
130
+ }
131
+ emitEvent('onBeginFlush');
132
+ },
133
+ onEndFlush: function () {
134
+ if (process.env.NODE_ENV !== 'production') {
135
+ resetMeasurements();
136
+ currentFlushNesting--;
137
+ }
138
+ emitEvent('onEndFlush');
139
+ },
140
+ onBeginLifeCycleTimer: function (debugID, timerType) {
141
+ emitEvent('onBeginLifeCycleTimer', debugID, timerType);
142
+ if (process.env.NODE_ENV !== 'production') {
143
+ if (isProfiling && currentFlushNesting > 0) {
144
+ process.env.NODE_ENV !== 'production' ? warning(!currentTimerType, 'There is an internal error in the React performance measurement code. ' + 'Did not expect %s timer to start while %s timer is still in ' + 'progress for %s instance.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another') : void 0;
145
+ currentTimerStartTime = performanceNow();
146
+ currentTimerDebugID = debugID;
147
+ currentTimerType = timerType;
148
+ }
149
+ }
150
+ },
151
+ onEndLifeCycleTimer: function (debugID, timerType) {
152
+ if (process.env.NODE_ENV !== 'production') {
153
+ if (isProfiling && currentFlushNesting > 0) {
154
+ process.env.NODE_ENV !== 'production' ? warning(currentTimerType === timerType, 'There is an internal error in the React performance measurement code. ' + 'We did not expect %s timer to stop while %s timer is still in ' + 'progress for %s instance. Please report this as a bug in React.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another') : void 0;
155
+ currentFlushMeasurements.push({
156
+ timerType: timerType,
157
+ instanceID: debugID,
158
+ duration: performanceNow() - currentTimerStartTime
159
+ });
160
+ currentTimerStartTime = null;
161
+ currentTimerDebugID = null;
162
+ currentTimerType = null;
163
+ }
164
+ }
165
+ emitEvent('onEndLifeCycleTimer', debugID, timerType);
166
+ },
167
+ onBeginReconcilerTimer: function (debugID, timerType) {
168
+ emitEvent('onBeginReconcilerTimer', debugID, timerType);
169
+ },
170
+ onEndReconcilerTimer: function (debugID, timerType) {
171
+ emitEvent('onEndReconcilerTimer', debugID, timerType);
172
+ },
47
173
  onBeginProcessingChildContext: function () {
48
174
  emitEvent('onBeginProcessingChildContext');
49
175
  },
50
176
  onEndProcessingChildContext: function () {
51
177
  emitEvent('onEndProcessingChildContext');
52
178
  },
179
+ onNativeOperation: function (debugID, type, payload) {
180
+ emitEvent('onNativeOperation', debugID, type, payload);
181
+ },
53
182
  onSetState: function () {
54
183
  emitEvent('onSetState');
55
184
  },
56
- onMountRootComponent: function (internalInstance) {
57
- emitEvent('onMountRootComponent', internalInstance);
185
+ onSetDisplayName: function (debugID, displayName) {
186
+ emitEvent('onSetDisplayName', debugID, displayName);
187
+ },
188
+ onSetChildren: function (debugID, childDebugIDs) {
189
+ emitEvent('onSetChildren', debugID, childDebugIDs);
58
190
  },
59
- onMountComponent: function (internalInstance) {
60
- emitEvent('onMountComponent', internalInstance);
191
+ onSetOwner: function (debugID, ownerDebugID) {
192
+ emitEvent('onSetOwner', debugID, ownerDebugID);
61
193
  },
62
- onUpdateComponent: function (internalInstance) {
63
- emitEvent('onUpdateComponent', internalInstance);
194
+ onSetText: function (debugID, text) {
195
+ emitEvent('onSetText', debugID, text);
64
196
  },
65
- onUnmountComponent: function (internalInstance) {
66
- emitEvent('onUnmountComponent', internalInstance);
197
+ onMountRootComponent: function (debugID) {
198
+ emitEvent('onMountRootComponent', debugID);
199
+ },
200
+ onMountComponent: function (debugID) {
201
+ emitEvent('onMountComponent', debugID);
202
+ },
203
+ onUpdateComponent: function (debugID) {
204
+ emitEvent('onUpdateComponent', debugID);
205
+ },
206
+ onUnmountComponent: function (debugID) {
207
+ emitEvent('onUnmountComponent', debugID);
67
208
  }
68
209
  };
69
210
 
70
- ReactDebugTool.addDevtool(ReactInvalidSetStateWarningDevTool);
211
+ if (process.env.NODE_ENV !== 'production') {
212
+ var ReactInvalidSetStateWarningDevTool = require('./ReactInvalidSetStateWarningDevTool');
213
+ var ReactNativeOperationHistoryDevtool = require('./ReactNativeOperationHistoryDevtool');
214
+ var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
215
+ ReactDebugTool.addDevtool(ReactInvalidSetStateWarningDevTool);
216
+ ReactDebugTool.addDevtool(ReactComponentTreeDevtool);
217
+ ReactDebugTool.addDevtool(ReactNativeOperationHistoryDevtool);
218
+ var url = ExecutionEnvironment.canUseDOM && window.location.href || '';
219
+ if (/[?&]react_perf\b/.test(url)) {
220
+ ReactDebugTool.beginProfiling();
221
+ }
222
+ }
71
223
 
72
224
  module.exports = ReactDebugTool;
@@ -15,7 +15,6 @@ var BeforeInputEventPlugin = require('./BeforeInputEventPlugin');
15
15
  var ChangeEventPlugin = require('./ChangeEventPlugin');
16
16
  var DefaultEventPluginOrder = require('./DefaultEventPluginOrder');
17
17
  var EnterLeaveEventPlugin = require('./EnterLeaveEventPlugin');
18
- var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
19
18
  var HTMLDOMPropertyConfig = require('./HTMLDOMPropertyConfig');
20
19
  var ReactComponentBrowserEnvironment = require('./ReactComponentBrowserEnvironment');
21
20
  var ReactDOMComponent = require('./ReactDOMComponent');
@@ -78,14 +77,6 @@ function inject() {
78
77
  ReactInjection.Updates.injectBatchingStrategy(ReactDefaultBatchingStrategy);
79
78
 
80
79
  ReactInjection.Component.injectEnvironment(ReactComponentBrowserEnvironment);
81
-
82
- if (process.env.NODE_ENV !== 'production') {
83
- var url = ExecutionEnvironment.canUseDOM && window.location.href || '';
84
- if (/[?&]react_perf\b/.test(url)) {
85
- var ReactDefaultPerf = require('./ReactDefaultPerf');
86
- ReactDefaultPerf.start();
87
- }
88
- }
89
80
  }
90
81
 
91
82
  module.exports = {
@@ -113,6 +113,10 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
113
113
  return element;
114
114
  };
115
115
 
116
+ /**
117
+ * Create and return a new ReactElement of the given type.
118
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.createelement
119
+ */
116
120
  ReactElement.createElement = function (type, config, children) {
117
121
  var propName;
118
122
 
@@ -126,6 +130,11 @@ ReactElement.createElement = function (type, config, children) {
126
130
 
127
131
  if (config != null) {
128
132
  if (process.env.NODE_ENV !== 'production') {
133
+ process.env.NODE_ENV !== 'production' ? warning(
134
+ /* eslint-disable no-proto */
135
+ config.__proto__ == null || config.__proto__ === Object.prototype,
136
+ /* eslint-enable no-proto */
137
+ 'React.createElement(...): Expected props argument to be a plain object. ' + 'Properties defined in its prototype chain will be ignored.') : void 0;
129
138
  ref = !config.hasOwnProperty('ref') || Object.getOwnPropertyDescriptor(config, 'ref').get ? null : config.ref;
130
139
  key = !config.hasOwnProperty('key') || Object.getOwnPropertyDescriptor(config, 'key').get ? null : '' + config.key;
131
140
  } else {
@@ -197,6 +206,10 @@ ReactElement.createElement = function (type, config, children) {
197
206
  return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
198
207
  };
199
208
 
209
+ /**
210
+ * Return a function that produces ReactElements of a given type.
211
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.createfactory
212
+ */
200
213
  ReactElement.createFactory = function (type) {
201
214
  var factory = ReactElement.createElement.bind(null, type);
202
215
  // Expose the type on the factory and the prototype so that it can be
@@ -214,6 +227,10 @@ ReactElement.cloneAndReplaceKey = function (oldElement, newKey) {
214
227
  return newElement;
215
228
  };
216
229
 
230
+ /**
231
+ * Clone and return a new ReactElement using element as the starting point.
232
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.cloneelement
233
+ */
217
234
  ReactElement.cloneElement = function (element, config, children) {
218
235
  var propName;
219
236
 
@@ -234,6 +251,13 @@ ReactElement.cloneElement = function (element, config, children) {
234
251
  var owner = element._owner;
235
252
 
236
253
  if (config != null) {
254
+ if (process.env.NODE_ENV !== 'production') {
255
+ process.env.NODE_ENV !== 'production' ? warning(
256
+ /* eslint-disable no-proto */
257
+ config.__proto__ == null || config.__proto__ === Object.prototype,
258
+ /* eslint-enable no-proto */
259
+ 'React.cloneElement(...): Expected props argument to be a plain object. ' + 'Properties defined in its prototype chain will be ignored.') : void 0;
260
+ }
237
261
  if (config.ref !== undefined) {
238
262
  // Silently steal the ref from the parent.
239
263
  ref = config.ref;
@@ -276,6 +300,8 @@ ReactElement.cloneElement = function (element, config, children) {
276
300
  };
277
301
 
278
302
  /**
303
+ * Verifies the object is a ReactElement.
304
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.isvalidelement
279
305
  * @param {?object} object
280
306
  * @return {boolean} True if `object` is a valid component.
281
307
  * @final
@@ -11,6 +11,8 @@
11
11
 
12
12
  'use strict';
13
13
 
14
+ var SyntheticDragEvent = require('./SyntheticDragEvent');
15
+
14
16
  var caughtError = null;
15
17
 
16
18
  /**
@@ -55,22 +57,70 @@ var ReactErrorUtils = {
55
57
  };
56
58
 
57
59
  if (process.env.NODE_ENV !== 'production') {
58
- /**
59
- * To help development we can get better devtools integration by simulating a
60
- * real browser event.
61
- */
62
- if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
63
- var fakeNode = document.createElement('react');
64
- ReactErrorUtils.invokeGuardedCallback = function (name, func, a, b) {
65
- var boundFunc = func.bind(null, a, b);
66
- var evtType = 'react-' + name;
67
- fakeNode.addEventListener(evtType, boundFunc, false);
68
- var evt = document.createEvent('Event');
69
- evt.initEvent(evtType, false, false);
70
- fakeNode.dispatchEvent(evt);
71
- fakeNode.removeEventListener(evtType, boundFunc, false);
60
+ var fakeNode;
61
+ var cacheCanWrapEvent;
62
+
63
+ (function () {
64
+
65
+ /**
66
+ * IE and Edge don't allow access to the DataTransfer.dropEffect property when
67
+ * it's wrapped in another event. This function detects whether we're in an
68
+ * environment that behaves this way.
69
+ *
70
+ * @param {*} ev Event that is being tested
71
+ */
72
+
73
+ var canWrapEvent = function (ev) {
74
+ if (!(ev instanceof SyntheticDragEvent)) {
75
+ return true;
76
+ } else if (cacheCanWrapEvent !== null) {
77
+ return cacheCanWrapEvent;
78
+ }
79
+
80
+ var canAccessDropEffect = false;
81
+ function handleWrappedEvent() {
82
+ try {
83
+ ev.dataTransfer.dropEffect; // eslint-disable-line no-unused-expressions
84
+ canAccessDropEffect = true;
85
+ } catch (e) {}
86
+ }
87
+
88
+ var wrappedEventName = 'react-wrappeddragevent';
89
+ var wrappedEvent = document.createEvent('Event');
90
+ wrappedEvent.initEvent(wrappedEventName, false, false);
91
+ fakeNode.addEventListener(wrappedEventName, handleWrappedEvent, false);
92
+ fakeNode.dispatchEvent(wrappedEvent);
93
+ fakeNode.removeEventListener(wrappedEventName, handleWrappedEvent, false);
94
+
95
+ cacheCanWrapEvent = canAccessDropEffect;
96
+ return canAccessDropEffect;
72
97
  };
73
- }
98
+
99
+ /**
100
+ * To help development we can get better devtools integration by simulating a
101
+ * real browser event.
102
+ */
103
+ if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
104
+ fakeNode = document.createElement('react');
105
+
106
+ ReactErrorUtils.invokeGuardedCallback = function (name, func, a, b) {
107
+ if (!canWrapEvent(a)) {
108
+ invokeGuardedCallback(name, func, a, b);
109
+ return;
110
+ }
111
+
112
+ var boundFunc = func.bind(null, a, b);
113
+ var evtType = 'react-' + name;
114
+ fakeNode.addEventListener(evtType, boundFunc, false);
115
+ var evt = document.createEvent('Event');
116
+ evt.initEvent(evtType, false, false);
117
+ fakeNode.dispatchEvent(evt);
118
+ fakeNode.removeEventListener(evtType, boundFunc, false);
119
+ };
120
+ }
121
+
122
+ cacheCanWrapEvent = null;
123
+ })();
74
124
  }
75
125
 
76
126
  module.exports = ReactErrorUtils;