react-dom 16.8.6 → 16.10.0
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.
- package/build-info.json +5 -5
- package/cjs/react-dom-server.browser.development.js +1192 -527
- package/cjs/react-dom-server.browser.production.min.js +46 -43
- package/cjs/react-dom-server.node.development.js +1188 -536
- package/cjs/react-dom-server.node.production.min.js +47 -45
- package/cjs/react-dom-test-utils.development.js +572 -201
- package/cjs/react-dom-test-utils.production.min.js +25 -23
- package/cjs/react-dom-unstable-fizz.browser.development.js +26 -15
- package/cjs/react-dom-unstable-fizz.browser.production.min.js +2 -2
- package/cjs/react-dom-unstable-fizz.node.development.js +26 -11
- package/cjs/react-dom-unstable-fizz.node.production.min.js +1 -1
- package/cjs/react-dom-unstable-native-dependencies.development.js +224 -136
- package/cjs/react-dom-unstable-native-dependencies.production.min.js +27 -28
- package/cjs/react-dom.development.js +21711 -15060
- package/cjs/react-dom.production.min.js +282 -258
- package/cjs/react-dom.profiling.min.js +288 -267
- package/package.json +2 -2
- package/umd/react-dom-server.browser.development.js +1204 -529
- package/umd/react-dom-server.browser.production.min.js +38 -37
- package/umd/react-dom-test-utils.development.js +592 -202
- package/umd/react-dom-test-utils.production.min.js +23 -22
- package/umd/react-dom-unstable-fizz.browser.development.js +26 -15
- package/umd/react-dom-unstable-fizz.browser.production.min.js +2 -2
- package/umd/react-dom-unstable-native-dependencies.development.js +224 -137
- package/umd/react-dom-unstable-native-dependencies.production.min.js +22 -23
- package/umd/react-dom.development.js +21852 -15190
- package/umd/react-dom.production.min.js +234 -210
- package/umd/react-dom.profiling.min.js +241 -216
- package/cjs/react-dom-unstable-fire.development.js +0 -21287
- package/cjs/react-dom-unstable-fire.production.min.js +0 -269
- package/cjs/react-dom-unstable-fire.profiling.min.js +0 -278
- package/umd/react-dom-unstable-fire.development.js +0 -21422
- package/umd/react-dom-unstable-fire.production.min.js +0 -220
- package/umd/react-dom-unstable-fire.profiling.min.js +0 -226
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v16.
|
|
1
|
+
/** @license React v16.10.0
|
|
2
2
|
* react-dom-unstable-native-dependencies.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -15,6 +15,18 @@
|
|
|
15
15
|
(global.ReactDOMUnstableNativeDependencies = factory(global.ReactDOM,global.React));
|
|
16
16
|
}(this, (function (ReactDOM,React) { 'use strict';
|
|
17
17
|
|
|
18
|
+
// Do not require this module directly! Use normal `invariant` calls with
|
|
19
|
+
// template literal strings. The messages will be converted to ReactError during
|
|
20
|
+
// build, and in production they will be minified.
|
|
21
|
+
|
|
22
|
+
// Do not require this module directly! Use normal `invariant` calls with
|
|
23
|
+
// template literal strings. The messages will be converted to ReactError during
|
|
24
|
+
// build, and in production they will be minified.
|
|
25
|
+
function ReactError(error) {
|
|
26
|
+
error.name = 'Invariant Violation';
|
|
27
|
+
return error;
|
|
28
|
+
}
|
|
29
|
+
|
|
18
30
|
/**
|
|
19
31
|
* Use invariant() to assert state which your program assumes to be true.
|
|
20
32
|
*
|
|
@@ -26,40 +38,6 @@
|
|
|
26
38
|
* will remain to ensure logic does not differ in production.
|
|
27
39
|
*/
|
|
28
40
|
|
|
29
|
-
var validateFormat = function () {};
|
|
30
|
-
|
|
31
|
-
{
|
|
32
|
-
validateFormat = function (format) {
|
|
33
|
-
if (format === undefined) {
|
|
34
|
-
throw new Error('invariant requires an error message argument');
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function invariant(condition, format, a, b, c, d, e, f) {
|
|
40
|
-
validateFormat(format);
|
|
41
|
-
|
|
42
|
-
if (!condition) {
|
|
43
|
-
var error = void 0;
|
|
44
|
-
if (format === undefined) {
|
|
45
|
-
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
|
46
|
-
} else {
|
|
47
|
-
var args = [a, b, c, d, e, f];
|
|
48
|
-
var argIndex = 0;
|
|
49
|
-
error = new Error(format.replace(/%s/g, function () {
|
|
50
|
-
return args[argIndex++];
|
|
51
|
-
}));
|
|
52
|
-
error.name = 'Invariant Violation';
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
error.framesToPop = 1; // we don't care about invariant's own frame
|
|
56
|
-
throw error;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Relying on the `invariant()` implementation lets us
|
|
61
|
-
// preserve the format and params in the www builds.
|
|
62
|
-
|
|
63
41
|
{
|
|
64
42
|
// In DEV mode, we swap out invokeGuardedCallback for a special version
|
|
65
43
|
// that plays more nicely with the browser's DevTools. The idea is to preserve
|
|
@@ -79,7 +57,6 @@ function invariant(condition, format, a, b, c, d, e, f) {
|
|
|
79
57
|
// event loop context, it does not interrupt the normal program flow.
|
|
80
58
|
// Effectively, this gives us try-catch behavior without actually using
|
|
81
59
|
// try-catch. Neat!
|
|
82
|
-
|
|
83
60
|
// Check that the browser supports the APIs we need to implement our special
|
|
84
61
|
// DEV version of invokeGuardedCallback
|
|
85
62
|
if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
|
|
@@ -127,35 +104,37 @@ function invariant(condition, format, a, b, c, d, e, f) {
|
|
|
127
104
|
* paths. Removing the logging code for production environments will keep the
|
|
128
105
|
* same logic and follow the same code paths.
|
|
129
106
|
*/
|
|
130
|
-
|
|
131
107
|
var warningWithoutStack = function () {};
|
|
132
108
|
|
|
133
109
|
{
|
|
134
110
|
warningWithoutStack = function (condition, format) {
|
|
135
|
-
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
111
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
136
112
|
args[_key - 2] = arguments[_key];
|
|
137
113
|
}
|
|
138
114
|
|
|
139
115
|
if (format === undefined) {
|
|
140
116
|
throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
|
|
141
117
|
}
|
|
118
|
+
|
|
142
119
|
if (args.length > 8) {
|
|
143
120
|
// Check before the condition to catch violations early.
|
|
144
121
|
throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
|
|
145
122
|
}
|
|
123
|
+
|
|
146
124
|
if (condition) {
|
|
147
125
|
return;
|
|
148
126
|
}
|
|
127
|
+
|
|
149
128
|
if (typeof console !== 'undefined') {
|
|
150
129
|
var argsWithFormat = args.map(function (item) {
|
|
151
130
|
return '' + item;
|
|
152
131
|
});
|
|
153
|
-
argsWithFormat.unshift('Warning: ' + format);
|
|
154
|
-
|
|
155
|
-
// We intentionally don't use spread (or .apply) directly because it
|
|
132
|
+
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
156
133
|
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
134
|
+
|
|
157
135
|
Function.prototype.apply.call(console.error, console, argsWithFormat);
|
|
158
136
|
}
|
|
137
|
+
|
|
159
138
|
try {
|
|
160
139
|
// --- Welcome to debugging React ---
|
|
161
140
|
// This error was thrown as a convenience so that you can use this stack
|
|
@@ -174,31 +153,36 @@ var warningWithoutStack$1 = warningWithoutStack;
|
|
|
174
153
|
var getFiberCurrentPropsFromNode$1 = null;
|
|
175
154
|
var getInstanceFromNode$1 = null;
|
|
176
155
|
var getNodeFromInstance$1 = null;
|
|
177
|
-
|
|
178
156
|
function setComponentTree(getFiberCurrentPropsFromNodeImpl, getInstanceFromNodeImpl, getNodeFromInstanceImpl) {
|
|
179
157
|
getFiberCurrentPropsFromNode$1 = getFiberCurrentPropsFromNodeImpl;
|
|
180
158
|
getInstanceFromNode$1 = getInstanceFromNodeImpl;
|
|
181
159
|
getNodeFromInstance$1 = getNodeFromInstanceImpl;
|
|
160
|
+
|
|
182
161
|
{
|
|
183
162
|
!(getNodeFromInstance$1 && getInstanceFromNode$1) ? warningWithoutStack$1(false, 'EventPluginUtils.setComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.') : void 0;
|
|
184
163
|
}
|
|
185
164
|
}
|
|
165
|
+
var validateEventDispatches;
|
|
186
166
|
|
|
187
|
-
var validateEventDispatches = void 0;
|
|
188
167
|
{
|
|
189
168
|
validateEventDispatches = function (event) {
|
|
190
169
|
var dispatchListeners = event._dispatchListeners;
|
|
191
170
|
var dispatchInstances = event._dispatchInstances;
|
|
192
|
-
|
|
193
171
|
var listenersIsArr = Array.isArray(dispatchListeners);
|
|
194
172
|
var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0;
|
|
195
|
-
|
|
196
173
|
var instancesIsArr = Array.isArray(dispatchInstances);
|
|
197
174
|
var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0;
|
|
198
|
-
|
|
199
175
|
!(instancesIsArr === listenersIsArr && instancesLen === listenersLen) ? warningWithoutStack$1(false, 'EventPluginUtils: Invalid `event`.') : void 0;
|
|
200
176
|
};
|
|
201
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* Dispatch the event to the listener.
|
|
180
|
+
* @param {SyntheticEvent} event SyntheticEvent to handle
|
|
181
|
+
* @param {function} listener Application-level callback
|
|
182
|
+
* @param {*} inst Internal component instance
|
|
183
|
+
*/
|
|
184
|
+
|
|
185
|
+
|
|
202
186
|
|
|
203
187
|
/**
|
|
204
188
|
* Standard/simple iteration through an event's collected dispatches.
|
|
@@ -212,18 +196,22 @@ var validateEventDispatches = void 0;
|
|
|
212
196
|
* @return {?string} id of the first dispatch execution who's listener returns
|
|
213
197
|
* true, or null if no listener returned true.
|
|
214
198
|
*/
|
|
199
|
+
|
|
215
200
|
function executeDispatchesInOrderStopAtTrueImpl(event) {
|
|
216
201
|
var dispatchListeners = event._dispatchListeners;
|
|
217
202
|
var dispatchInstances = event._dispatchInstances;
|
|
203
|
+
|
|
218
204
|
{
|
|
219
205
|
validateEventDispatches(event);
|
|
220
206
|
}
|
|
207
|
+
|
|
221
208
|
if (Array.isArray(dispatchListeners)) {
|
|
222
209
|
for (var i = 0; i < dispatchListeners.length; i++) {
|
|
223
210
|
if (event.isPropagationStopped()) {
|
|
224
211
|
break;
|
|
225
|
-
}
|
|
226
|
-
|
|
212
|
+
} // Listeners and Instances are two parallel arrays that are always in sync.
|
|
213
|
+
|
|
214
|
+
|
|
227
215
|
if (dispatchListeners[i](event, dispatchInstances[i])) {
|
|
228
216
|
return dispatchInstances[i];
|
|
229
217
|
}
|
|
@@ -233,19 +221,20 @@ function executeDispatchesInOrderStopAtTrueImpl(event) {
|
|
|
233
221
|
return dispatchInstances;
|
|
234
222
|
}
|
|
235
223
|
}
|
|
224
|
+
|
|
236
225
|
return null;
|
|
237
226
|
}
|
|
238
|
-
|
|
239
227
|
/**
|
|
240
228
|
* @see executeDispatchesInOrderStopAtTrueImpl
|
|
241
229
|
*/
|
|
230
|
+
|
|
231
|
+
|
|
242
232
|
function executeDispatchesInOrderStopAtTrue(event) {
|
|
243
233
|
var ret = executeDispatchesInOrderStopAtTrueImpl(event);
|
|
244
234
|
event._dispatchInstances = null;
|
|
245
235
|
event._dispatchListeners = null;
|
|
246
236
|
return ret;
|
|
247
237
|
}
|
|
248
|
-
|
|
249
238
|
/**
|
|
250
239
|
* Execution of a "direct" dispatch - there must be at most one dispatch
|
|
251
240
|
* accumulated on the event or it is considered an error. It doesn't really make
|
|
@@ -255,13 +244,23 @@ function executeDispatchesInOrderStopAtTrue(event) {
|
|
|
255
244
|
*
|
|
256
245
|
* @return {*} The return value of executing the single dispatch.
|
|
257
246
|
*/
|
|
247
|
+
|
|
258
248
|
function executeDirectDispatch(event) {
|
|
259
249
|
{
|
|
260
250
|
validateEventDispatches(event);
|
|
261
251
|
}
|
|
252
|
+
|
|
262
253
|
var dispatchListener = event._dispatchListeners;
|
|
263
254
|
var dispatchInstance = event._dispatchInstances;
|
|
264
|
-
|
|
255
|
+
|
|
256
|
+
(function () {
|
|
257
|
+
if (!!Array.isArray(dispatchListener)) {
|
|
258
|
+
{
|
|
259
|
+
throw ReactError(Error("executeDirectDispatch(...): Invalid `event`."));
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
})();
|
|
263
|
+
|
|
265
264
|
event.currentTarget = dispatchListener ? getNodeFromInstance$1(dispatchInstance) : null;
|
|
266
265
|
var res = dispatchListener ? dispatchListener(event) : null;
|
|
267
266
|
event.currentTarget = null;
|
|
@@ -269,111 +268,127 @@ function executeDirectDispatch(event) {
|
|
|
269
268
|
event._dispatchInstances = null;
|
|
270
269
|
return res;
|
|
271
270
|
}
|
|
272
|
-
|
|
273
271
|
/**
|
|
274
272
|
* @param {SyntheticEvent} event
|
|
275
273
|
* @return {boolean} True iff number of dispatches accumulated is greater than 0.
|
|
276
274
|
*/
|
|
275
|
+
|
|
277
276
|
function hasDispatches(event) {
|
|
278
277
|
return !!event._dispatchListeners;
|
|
279
278
|
}
|
|
280
279
|
|
|
281
280
|
// Before we know whether it is function or class
|
|
281
|
+
|
|
282
282
|
// Root of a host tree. Could be nested inside another node.
|
|
283
|
+
|
|
283
284
|
// A subtree. Could be an entry point to a different renderer.
|
|
285
|
+
|
|
284
286
|
var HostComponent = 5;
|
|
285
287
|
|
|
286
288
|
function getParent(inst) {
|
|
287
289
|
do {
|
|
288
|
-
inst = inst.return;
|
|
289
|
-
// TODO: If this is a HostRoot we might want to bail out.
|
|
290
|
+
inst = inst.return; // TODO: If this is a HostRoot we might want to bail out.
|
|
290
291
|
// That is depending on if we want nested subtrees (layers) to bubble
|
|
291
292
|
// events to their parent. We could also go through parentNode on the
|
|
292
293
|
// host node but that wouldn't work for React Native and doesn't let us
|
|
293
294
|
// do the portal feature.
|
|
294
295
|
} while (inst && inst.tag !== HostComponent);
|
|
296
|
+
|
|
295
297
|
if (inst) {
|
|
296
298
|
return inst;
|
|
297
299
|
}
|
|
300
|
+
|
|
298
301
|
return null;
|
|
299
302
|
}
|
|
300
|
-
|
|
301
303
|
/**
|
|
302
304
|
* Return the lowest common ancestor of A and B, or null if they are in
|
|
303
305
|
* different trees.
|
|
304
306
|
*/
|
|
307
|
+
|
|
308
|
+
|
|
305
309
|
function getLowestCommonAncestor(instA, instB) {
|
|
306
310
|
var depthA = 0;
|
|
311
|
+
|
|
307
312
|
for (var tempA = instA; tempA; tempA = getParent(tempA)) {
|
|
308
313
|
depthA++;
|
|
309
314
|
}
|
|
315
|
+
|
|
310
316
|
var depthB = 0;
|
|
317
|
+
|
|
311
318
|
for (var tempB = instB; tempB; tempB = getParent(tempB)) {
|
|
312
319
|
depthB++;
|
|
313
|
-
}
|
|
320
|
+
} // If A is deeper, crawl up.
|
|
321
|
+
|
|
314
322
|
|
|
315
|
-
// If A is deeper, crawl up.
|
|
316
323
|
while (depthA - depthB > 0) {
|
|
317
324
|
instA = getParent(instA);
|
|
318
325
|
depthA--;
|
|
319
|
-
}
|
|
326
|
+
} // If B is deeper, crawl up.
|
|
327
|
+
|
|
320
328
|
|
|
321
|
-
// If B is deeper, crawl up.
|
|
322
329
|
while (depthB - depthA > 0) {
|
|
323
330
|
instB = getParent(instB);
|
|
324
331
|
depthB--;
|
|
325
|
-
}
|
|
332
|
+
} // Walk in lockstep until we find a match.
|
|
333
|
+
|
|
326
334
|
|
|
327
|
-
// Walk in lockstep until we find a match.
|
|
328
335
|
var depth = depthA;
|
|
336
|
+
|
|
329
337
|
while (depth--) {
|
|
330
338
|
if (instA === instB || instA === instB.alternate) {
|
|
331
339
|
return instA;
|
|
332
340
|
}
|
|
341
|
+
|
|
333
342
|
instA = getParent(instA);
|
|
334
343
|
instB = getParent(instB);
|
|
335
344
|
}
|
|
345
|
+
|
|
336
346
|
return null;
|
|
337
347
|
}
|
|
338
|
-
|
|
339
348
|
/**
|
|
340
349
|
* Return if A is an ancestor of B.
|
|
341
350
|
*/
|
|
351
|
+
|
|
342
352
|
function isAncestor(instA, instB) {
|
|
343
353
|
while (instB) {
|
|
344
354
|
if (instA === instB || instA === instB.alternate) {
|
|
345
355
|
return true;
|
|
346
356
|
}
|
|
357
|
+
|
|
347
358
|
instB = getParent(instB);
|
|
348
359
|
}
|
|
360
|
+
|
|
349
361
|
return false;
|
|
350
362
|
}
|
|
351
|
-
|
|
352
363
|
/**
|
|
353
364
|
* Return the parent instance of the passed-in instance.
|
|
354
365
|
*/
|
|
366
|
+
|
|
355
367
|
function getParentInstance(inst) {
|
|
356
368
|
return getParent(inst);
|
|
357
369
|
}
|
|
358
|
-
|
|
359
370
|
/**
|
|
360
371
|
* Simulates the traversal of a two-phase, capture/bubble event dispatch.
|
|
361
372
|
*/
|
|
373
|
+
|
|
362
374
|
function traverseTwoPhase(inst, fn, arg) {
|
|
363
375
|
var path = [];
|
|
376
|
+
|
|
364
377
|
while (inst) {
|
|
365
378
|
path.push(inst);
|
|
366
379
|
inst = getParent(inst);
|
|
367
380
|
}
|
|
368
|
-
|
|
381
|
+
|
|
382
|
+
var i;
|
|
383
|
+
|
|
369
384
|
for (i = path.length; i-- > 0;) {
|
|
370
385
|
fn(path[i], 'captured', arg);
|
|
371
386
|
}
|
|
387
|
+
|
|
372
388
|
for (i = 0; i < path.length; i++) {
|
|
373
389
|
fn(path[i], 'bubbled', arg);
|
|
374
390
|
}
|
|
375
391
|
}
|
|
376
|
-
|
|
377
392
|
/**
|
|
378
393
|
* Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
|
|
379
394
|
* should would receive a `mouseEnter` or `mouseLeave` event.
|
|
@@ -393,6 +408,7 @@ function traverseTwoPhase(inst, fn, arg) {
|
|
|
393
408
|
*/
|
|
394
409
|
|
|
395
410
|
|
|
411
|
+
|
|
396
412
|
/**
|
|
397
413
|
* Mapping from event name to dispatch config
|
|
398
414
|
*/
|
|
@@ -415,7 +431,7 @@ function traverseTwoPhase(inst, fn, arg) {
|
|
|
415
431
|
* @type {Object}
|
|
416
432
|
*/
|
|
417
433
|
|
|
418
|
-
// Trust the developer to only use possibleRegistrationNames in true
|
|
434
|
+
// Trust the developer to only use possibleRegistrationNames in true
|
|
419
435
|
|
|
420
436
|
/**
|
|
421
437
|
* Injects an ordering of plugins (by plugin name). This allows the ordering
|
|
@@ -453,19 +469,26 @@ function traverseTwoPhase(inst, fn, arg) {
|
|
|
453
469
|
*/
|
|
454
470
|
|
|
455
471
|
function accumulateInto(current, next) {
|
|
456
|
-
|
|
472
|
+
(function () {
|
|
473
|
+
if (!(next != null)) {
|
|
474
|
+
{
|
|
475
|
+
throw ReactError(Error("accumulateInto(...): Accumulated items must not be null or undefined."));
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
})();
|
|
457
479
|
|
|
458
480
|
if (current == null) {
|
|
459
481
|
return next;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
// Both are not empty. Warning: Never call x.concat(y) when you are not
|
|
482
|
+
} // Both are not empty. Warning: Never call x.concat(y) when you are not
|
|
463
483
|
// certain that x is an Array (x could be a string with concat method).
|
|
484
|
+
|
|
485
|
+
|
|
464
486
|
if (Array.isArray(current)) {
|
|
465
487
|
if (Array.isArray(next)) {
|
|
466
488
|
current.push.apply(current, next);
|
|
467
489
|
return current;
|
|
468
490
|
}
|
|
491
|
+
|
|
469
492
|
current.push(next);
|
|
470
493
|
return current;
|
|
471
494
|
}
|
|
@@ -512,11 +535,11 @@ function shouldPreventMouseEvent(name, type, props) {
|
|
|
512
535
|
case 'onMouseUp':
|
|
513
536
|
case 'onMouseUpCapture':
|
|
514
537
|
return !!(props.disabled && isInteractive(type));
|
|
538
|
+
|
|
515
539
|
default:
|
|
516
540
|
return false;
|
|
517
541
|
}
|
|
518
542
|
}
|
|
519
|
-
|
|
520
543
|
/**
|
|
521
544
|
* This is a unified interface for event plugins to be installed and configured.
|
|
522
545
|
*
|
|
@@ -545,31 +568,45 @@ function shouldPreventMouseEvent(name, type, props) {
|
|
|
545
568
|
*/
|
|
546
569
|
|
|
547
570
|
|
|
571
|
+
|
|
548
572
|
/**
|
|
549
573
|
* @param {object} inst The instance, which is the source of events.
|
|
550
574
|
* @param {string} registrationName Name of listener (e.g. `onClick`).
|
|
551
575
|
* @return {?function} The stored callback.
|
|
552
576
|
*/
|
|
553
|
-
function getListener(inst, registrationName) {
|
|
554
|
-
var listener = void 0;
|
|
555
577
|
|
|
556
|
-
|
|
578
|
+
function getListener(inst, registrationName) {
|
|
579
|
+
var listener; // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not
|
|
557
580
|
// live here; needs to be moved to a better place soon
|
|
581
|
+
|
|
558
582
|
var stateNode = inst.stateNode;
|
|
583
|
+
|
|
559
584
|
if (!stateNode) {
|
|
560
585
|
// Work in progress (ex: onload events in incremental mode).
|
|
561
586
|
return null;
|
|
562
587
|
}
|
|
588
|
+
|
|
563
589
|
var props = getFiberCurrentPropsFromNode$1(stateNode);
|
|
590
|
+
|
|
564
591
|
if (!props) {
|
|
565
592
|
// Work in progress.
|
|
566
593
|
return null;
|
|
567
594
|
}
|
|
595
|
+
|
|
568
596
|
listener = props[registrationName];
|
|
597
|
+
|
|
569
598
|
if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
|
|
570
599
|
return null;
|
|
571
600
|
}
|
|
572
|
-
|
|
601
|
+
|
|
602
|
+
(function () {
|
|
603
|
+
if (!(!listener || typeof listener === 'function')) {
|
|
604
|
+
{
|
|
605
|
+
throw ReactError(Error("Expected `" + registrationName + "` listener to be a function, instead got a value of `" + typeof listener + "` type."));
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
})();
|
|
609
|
+
|
|
573
610
|
return listener;
|
|
574
611
|
}
|
|
575
612
|
|
|
@@ -581,7 +618,6 @@ function listenerAtPhase(inst, event, propagationPhase) {
|
|
|
581
618
|
var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase];
|
|
582
619
|
return getListener(inst, registrationName);
|
|
583
620
|
}
|
|
584
|
-
|
|
585
621
|
/**
|
|
586
622
|
* A small set of propagation patterns, each of which will accept a small amount
|
|
587
623
|
* of information, and generate a set of "dispatch ready event objects" - which
|
|
@@ -598,17 +634,20 @@ function listenerAtPhase(inst, event, propagationPhase) {
|
|
|
598
634
|
* Mutating the event's members allows us to not have to create a wrapping
|
|
599
635
|
* "dispatch" object that pairs the event with the listener.
|
|
600
636
|
*/
|
|
637
|
+
|
|
638
|
+
|
|
601
639
|
function accumulateDirectionalDispatches(inst, phase, event) {
|
|
602
640
|
{
|
|
603
641
|
!inst ? warningWithoutStack$1(false, 'Dispatching inst must not be null') : void 0;
|
|
604
642
|
}
|
|
643
|
+
|
|
605
644
|
var listener = listenerAtPhase(inst, event, phase);
|
|
645
|
+
|
|
606
646
|
if (listener) {
|
|
607
647
|
event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
|
|
608
648
|
event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
|
|
609
649
|
}
|
|
610
650
|
}
|
|
611
|
-
|
|
612
651
|
/**
|
|
613
652
|
* Collect dispatches (must be entirely collected before dispatching - see unit
|
|
614
653
|
* tests). Lazily allocate the array to conserve memory. We must loop through
|
|
@@ -616,15 +655,18 @@ function accumulateDirectionalDispatches(inst, phase, event) {
|
|
|
616
655
|
* single traversal for the entire collection of events because each event may
|
|
617
656
|
* have a different target.
|
|
618
657
|
*/
|
|
658
|
+
|
|
659
|
+
|
|
619
660
|
function accumulateTwoPhaseDispatchesSingle(event) {
|
|
620
661
|
if (event && event.dispatchConfig.phasedRegistrationNames) {
|
|
621
662
|
traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
|
|
622
663
|
}
|
|
623
664
|
}
|
|
624
|
-
|
|
625
665
|
/**
|
|
626
666
|
* Same as `accumulateTwoPhaseDispatchesSingle`, but skips over the targetID.
|
|
627
667
|
*/
|
|
668
|
+
|
|
669
|
+
|
|
628
670
|
function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
|
|
629
671
|
if (event && event.dispatchConfig.phasedRegistrationNames) {
|
|
630
672
|
var targetInst = event._targetInst;
|
|
@@ -632,28 +674,31 @@ function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
|
|
|
632
674
|
traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event);
|
|
633
675
|
}
|
|
634
676
|
}
|
|
635
|
-
|
|
636
677
|
/**
|
|
637
678
|
* Accumulates without regard to direction, does not look for phased
|
|
638
679
|
* registration names. Same as `accumulateDirectDispatchesSingle` but without
|
|
639
680
|
* requiring that the `dispatchMarker` be the same as the dispatched ID.
|
|
640
681
|
*/
|
|
682
|
+
|
|
683
|
+
|
|
641
684
|
function accumulateDispatches(inst, ignoredDirection, event) {
|
|
642
685
|
if (inst && event && event.dispatchConfig.registrationName) {
|
|
643
686
|
var registrationName = event.dispatchConfig.registrationName;
|
|
644
687
|
var listener = getListener(inst, registrationName);
|
|
688
|
+
|
|
645
689
|
if (listener) {
|
|
646
690
|
event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
|
|
647
691
|
event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
|
|
648
692
|
}
|
|
649
693
|
}
|
|
650
694
|
}
|
|
651
|
-
|
|
652
695
|
/**
|
|
653
696
|
* Accumulates dispatches on an `SyntheticEvent`, but only for the
|
|
654
697
|
* `dispatchMarker`.
|
|
655
698
|
* @param {SyntheticEvent} event
|
|
656
699
|
*/
|
|
700
|
+
|
|
701
|
+
|
|
657
702
|
function accumulateDirectDispatchesSingle(event) {
|
|
658
703
|
if (event && event.dispatchConfig.registrationName) {
|
|
659
704
|
accumulateDispatches(event._targetInst, null, event);
|
|
@@ -663,29 +708,24 @@ function accumulateDirectDispatchesSingle(event) {
|
|
|
663
708
|
function accumulateTwoPhaseDispatches(events) {
|
|
664
709
|
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
|
|
665
710
|
}
|
|
666
|
-
|
|
667
711
|
function accumulateTwoPhaseDispatchesSkipTarget(events) {
|
|
668
712
|
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget);
|
|
669
713
|
}
|
|
670
714
|
|
|
671
|
-
|
|
672
|
-
|
|
673
715
|
function accumulateDirectDispatches(events) {
|
|
674
716
|
forEachAccumulated(events, accumulateDirectDispatchesSingle);
|
|
675
717
|
}
|
|
676
718
|
|
|
677
719
|
var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
678
|
-
|
|
679
720
|
var _assign = ReactInternals.assign;
|
|
680
721
|
|
|
681
722
|
/* eslint valid-typeof: 0 */
|
|
682
|
-
|
|
683
723
|
var EVENT_POOL_SIZE = 10;
|
|
684
|
-
|
|
685
724
|
/**
|
|
686
725
|
* @interface Event
|
|
687
726
|
* @see http://www.w3.org/TR/DOM-Level-3-Events/
|
|
688
727
|
*/
|
|
728
|
+
|
|
689
729
|
var EventInterface = {
|
|
690
730
|
type: null,
|
|
691
731
|
target: null,
|
|
@@ -710,7 +750,6 @@ function functionThatReturnsTrue() {
|
|
|
710
750
|
function functionThatReturnsFalse() {
|
|
711
751
|
return false;
|
|
712
752
|
}
|
|
713
|
-
|
|
714
753
|
/**
|
|
715
754
|
* Synthetic events are dispatched by event plugins, typically in response to a
|
|
716
755
|
* top-level event delegation handler.
|
|
@@ -729,6 +768,8 @@ function functionThatReturnsFalse() {
|
|
|
729
768
|
* @param {object} nativeEvent Native browser event.
|
|
730
769
|
* @param {DOMEventTarget} nativeEventTarget Target node.
|
|
731
770
|
*/
|
|
771
|
+
|
|
772
|
+
|
|
732
773
|
function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) {
|
|
733
774
|
{
|
|
734
775
|
// these have a getter/setter for warnings
|
|
@@ -742,16 +783,19 @@ function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarg
|
|
|
742
783
|
this.dispatchConfig = dispatchConfig;
|
|
743
784
|
this._targetInst = targetInst;
|
|
744
785
|
this.nativeEvent = nativeEvent;
|
|
745
|
-
|
|
746
786
|
var Interface = this.constructor.Interface;
|
|
787
|
+
|
|
747
788
|
for (var propName in Interface) {
|
|
748
789
|
if (!Interface.hasOwnProperty(propName)) {
|
|
749
790
|
continue;
|
|
750
791
|
}
|
|
792
|
+
|
|
751
793
|
{
|
|
752
794
|
delete this[propName]; // this has a getter/setter for warnings
|
|
753
795
|
}
|
|
796
|
+
|
|
754
797
|
var normalize = Interface[propName];
|
|
798
|
+
|
|
755
799
|
if (normalize) {
|
|
756
800
|
this[propName] = normalize(nativeEvent);
|
|
757
801
|
} else {
|
|
@@ -764,11 +808,13 @@ function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarg
|
|
|
764
808
|
}
|
|
765
809
|
|
|
766
810
|
var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
|
|
811
|
+
|
|
767
812
|
if (defaultPrevented) {
|
|
768
813
|
this.isDefaultPrevented = functionThatReturnsTrue;
|
|
769
814
|
} else {
|
|
770
815
|
this.isDefaultPrevented = functionThatReturnsFalse;
|
|
771
816
|
}
|
|
817
|
+
|
|
772
818
|
this.isPropagationStopped = functionThatReturnsFalse;
|
|
773
819
|
return this;
|
|
774
820
|
}
|
|
@@ -777,6 +823,7 @@ _assign(SyntheticEvent.prototype, {
|
|
|
777
823
|
preventDefault: function () {
|
|
778
824
|
this.defaultPrevented = true;
|
|
779
825
|
var event = this.nativeEvent;
|
|
826
|
+
|
|
780
827
|
if (!event) {
|
|
781
828
|
return;
|
|
782
829
|
}
|
|
@@ -786,11 +833,12 @@ _assign(SyntheticEvent.prototype, {
|
|
|
786
833
|
} else if (typeof event.returnValue !== 'unknown') {
|
|
787
834
|
event.returnValue = false;
|
|
788
835
|
}
|
|
836
|
+
|
|
789
837
|
this.isDefaultPrevented = functionThatReturnsTrue;
|
|
790
838
|
},
|
|
791
|
-
|
|
792
839
|
stopPropagation: function () {
|
|
793
840
|
var event = this.nativeEvent;
|
|
841
|
+
|
|
794
842
|
if (!event) {
|
|
795
843
|
return;
|
|
796
844
|
}
|
|
@@ -830,11 +878,13 @@ _assign(SyntheticEvent.prototype, {
|
|
|
830
878
|
*/
|
|
831
879
|
destructor: function () {
|
|
832
880
|
var Interface = this.constructor.Interface;
|
|
881
|
+
|
|
833
882
|
for (var propName in Interface) {
|
|
834
883
|
{
|
|
835
884
|
Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName]));
|
|
836
885
|
}
|
|
837
886
|
}
|
|
887
|
+
|
|
838
888
|
this.dispatchConfig = null;
|
|
839
889
|
this._targetInst = null;
|
|
840
890
|
this.nativeEvent = null;
|
|
@@ -842,6 +892,7 @@ _assign(SyntheticEvent.prototype, {
|
|
|
842
892
|
this.isPropagationStopped = functionThatReturnsFalse;
|
|
843
893
|
this._dispatchListeners = null;
|
|
844
894
|
this._dispatchInstances = null;
|
|
895
|
+
|
|
845
896
|
{
|
|
846
897
|
Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
|
|
847
898
|
Object.defineProperty(this, 'isDefaultPrevented', getPooledWarningPropertyDefinition('isDefaultPrevented', functionThatReturnsFalse));
|
|
@@ -853,33 +904,33 @@ _assign(SyntheticEvent.prototype, {
|
|
|
853
904
|
});
|
|
854
905
|
|
|
855
906
|
SyntheticEvent.Interface = EventInterface;
|
|
856
|
-
|
|
857
907
|
/**
|
|
858
908
|
* Helper to reduce boilerplate when creating subclasses.
|
|
859
909
|
*/
|
|
910
|
+
|
|
860
911
|
SyntheticEvent.extend = function (Interface) {
|
|
861
912
|
var Super = this;
|
|
862
913
|
|
|
863
914
|
var E = function () {};
|
|
915
|
+
|
|
864
916
|
E.prototype = Super.prototype;
|
|
865
917
|
var prototype = new E();
|
|
866
918
|
|
|
867
919
|
function Class() {
|
|
868
920
|
return Super.apply(this, arguments);
|
|
869
921
|
}
|
|
922
|
+
|
|
870
923
|
_assign(prototype, Class.prototype);
|
|
924
|
+
|
|
871
925
|
Class.prototype = prototype;
|
|
872
926
|
Class.prototype.constructor = Class;
|
|
873
|
-
|
|
874
927
|
Class.Interface = _assign({}, Super.Interface, Interface);
|
|
875
928
|
Class.extend = Super.extend;
|
|
876
929
|
addEventPoolingTo(Class);
|
|
877
|
-
|
|
878
930
|
return Class;
|
|
879
931
|
};
|
|
880
932
|
|
|
881
933
|
addEventPoolingTo(SyntheticEvent);
|
|
882
|
-
|
|
883
934
|
/**
|
|
884
935
|
* Helper to nullify syntheticEvent instance properties when destructing
|
|
885
936
|
*
|
|
@@ -887,6 +938,7 @@ addEventPoolingTo(SyntheticEvent);
|
|
|
887
938
|
* @param {?object} getVal
|
|
888
939
|
* @return {object} defineProperty object
|
|
889
940
|
*/
|
|
941
|
+
|
|
890
942
|
function getPooledWarningPropertyDefinition(propName, getVal) {
|
|
891
943
|
var isFunction = typeof getVal === 'function';
|
|
892
944
|
return {
|
|
@@ -916,18 +968,29 @@ function getPooledWarningPropertyDefinition(propName, getVal) {
|
|
|
916
968
|
|
|
917
969
|
function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
|
|
918
970
|
var EventConstructor = this;
|
|
971
|
+
|
|
919
972
|
if (EventConstructor.eventPool.length) {
|
|
920
973
|
var instance = EventConstructor.eventPool.pop();
|
|
921
974
|
EventConstructor.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst);
|
|
922
975
|
return instance;
|
|
923
976
|
}
|
|
977
|
+
|
|
924
978
|
return new EventConstructor(dispatchConfig, targetInst, nativeEvent, nativeInst);
|
|
925
979
|
}
|
|
926
980
|
|
|
927
981
|
function releasePooledEvent(event) {
|
|
928
982
|
var EventConstructor = this;
|
|
929
|
-
|
|
983
|
+
|
|
984
|
+
(function () {
|
|
985
|
+
if (!(event instanceof EventConstructor)) {
|
|
986
|
+
{
|
|
987
|
+
throw ReactError(Error("Trying to release an event instance into a pool of a different type."));
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
})();
|
|
991
|
+
|
|
930
992
|
event.destructor();
|
|
993
|
+
|
|
931
994
|
if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) {
|
|
932
995
|
EventConstructor.eventPool.push(event);
|
|
933
996
|
}
|
|
@@ -944,6 +1007,7 @@ function addEventPoolingTo(EventConstructor) {
|
|
|
944
1007
|
* interface will ensure that it is cleaned up when pooled/destroyed. The
|
|
945
1008
|
* `ResponderEventPlugin` will populate it appropriately.
|
|
946
1009
|
*/
|
|
1010
|
+
|
|
947
1011
|
var ResponderSyntheticEvent = SyntheticEvent.extend({
|
|
948
1012
|
touchHistory: function (nativeEvent) {
|
|
949
1013
|
return null; // Actually doesn't even look at the native event.
|
|
@@ -952,7 +1016,6 @@ var ResponderSyntheticEvent = SyntheticEvent.extend({
|
|
|
952
1016
|
|
|
953
1017
|
// Note: ideally these would be imported from DOMTopLevelEventTypes,
|
|
954
1018
|
// but our build system currently doesn't let us do that from a fork.
|
|
955
|
-
|
|
956
1019
|
var TOP_TOUCH_START = 'touchstart';
|
|
957
1020
|
var TOP_TOUCH_MOVE = 'touchmove';
|
|
958
1021
|
var TOP_TOUCH_END = 'touchend';
|
|
@@ -962,19 +1025,15 @@ var TOP_SELECTION_CHANGE = 'selectionchange';
|
|
|
962
1025
|
var TOP_MOUSE_DOWN = 'mousedown';
|
|
963
1026
|
var TOP_MOUSE_MOVE = 'mousemove';
|
|
964
1027
|
var TOP_MOUSE_UP = 'mouseup';
|
|
965
|
-
|
|
966
1028
|
function isStartish(topLevelType) {
|
|
967
1029
|
return topLevelType === TOP_TOUCH_START || topLevelType === TOP_MOUSE_DOWN;
|
|
968
1030
|
}
|
|
969
|
-
|
|
970
1031
|
function isMoveish(topLevelType) {
|
|
971
1032
|
return topLevelType === TOP_TOUCH_MOVE || topLevelType === TOP_MOUSE_MOVE;
|
|
972
1033
|
}
|
|
973
|
-
|
|
974
1034
|
function isEndish(topLevelType) {
|
|
975
1035
|
return topLevelType === TOP_TOUCH_END || topLevelType === TOP_TOUCH_CANCEL || topLevelType === TOP_MOUSE_UP;
|
|
976
1036
|
}
|
|
977
|
-
|
|
978
1037
|
var startDependencies = [TOP_TOUCH_START, TOP_MOUSE_DOWN];
|
|
979
1038
|
var moveDependencies = [TOP_TOUCH_MOVE, TOP_MOUSE_MOVE];
|
|
980
1039
|
var endDependencies = [TOP_TOUCH_CANCEL, TOP_TOUCH_END, TOP_MOUSE_UP];
|
|
@@ -985,7 +1044,6 @@ var endDependencies = [TOP_TOUCH_CANCEL, TOP_TOUCH_END, TOP_MOUSE_UP];
|
|
|
985
1044
|
* when touches end and start again.
|
|
986
1045
|
*/
|
|
987
1046
|
|
|
988
|
-
|
|
989
1047
|
var MAX_TOUCH_BANK = 20;
|
|
990
1048
|
var touchBank = [];
|
|
991
1049
|
var touchHistory = {
|
|
@@ -1004,11 +1062,12 @@ function timestampForTouch(touch) {
|
|
|
1004
1062
|
// TODO (evv): rename timeStamp to timestamp in internal code
|
|
1005
1063
|
return touch.timeStamp || touch.timestamp;
|
|
1006
1064
|
}
|
|
1007
|
-
|
|
1008
1065
|
/**
|
|
1009
1066
|
* TODO: Instead of making gestures recompute filtered velocity, we could
|
|
1010
1067
|
* include a built in velocity computation that can be reused globally.
|
|
1011
1068
|
*/
|
|
1069
|
+
|
|
1070
|
+
|
|
1012
1071
|
function createTouchRecord(touch) {
|
|
1013
1072
|
return {
|
|
1014
1073
|
touchActive: true,
|
|
@@ -1040,26 +1099,37 @@ function resetTouchRecord(touchRecord, touch) {
|
|
|
1040
1099
|
function getTouchIdentifier(_ref) {
|
|
1041
1100
|
var identifier = _ref.identifier;
|
|
1042
1101
|
|
|
1043
|
-
|
|
1102
|
+
(function () {
|
|
1103
|
+
if (!(identifier != null)) {
|
|
1104
|
+
{
|
|
1105
|
+
throw ReactError(Error("Touch object is missing identifier."));
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
})();
|
|
1109
|
+
|
|
1044
1110
|
{
|
|
1045
1111
|
!(identifier <= MAX_TOUCH_BANK) ? warningWithoutStack$1(false, 'Touch identifier %s is greater than maximum supported %s which causes ' + 'performance issues backfilling array locations for all of the indices.', identifier, MAX_TOUCH_BANK) : void 0;
|
|
1046
1112
|
}
|
|
1113
|
+
|
|
1047
1114
|
return identifier;
|
|
1048
1115
|
}
|
|
1049
1116
|
|
|
1050
1117
|
function recordTouchStart(touch) {
|
|
1051
1118
|
var identifier = getTouchIdentifier(touch);
|
|
1052
1119
|
var touchRecord = touchBank[identifier];
|
|
1120
|
+
|
|
1053
1121
|
if (touchRecord) {
|
|
1054
1122
|
resetTouchRecord(touchRecord, touch);
|
|
1055
1123
|
} else {
|
|
1056
1124
|
touchBank[identifier] = createTouchRecord(touch);
|
|
1057
1125
|
}
|
|
1126
|
+
|
|
1058
1127
|
touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
|
1059
1128
|
}
|
|
1060
1129
|
|
|
1061
1130
|
function recordTouchMove(touch) {
|
|
1062
1131
|
var touchRecord = touchBank[getTouchIdentifier(touch)];
|
|
1132
|
+
|
|
1063
1133
|
if (touchRecord) {
|
|
1064
1134
|
touchRecord.touchActive = true;
|
|
1065
1135
|
touchRecord.previousPageX = touchRecord.currentPageX;
|
|
@@ -1070,12 +1140,13 @@ function recordTouchMove(touch) {
|
|
|
1070
1140
|
touchRecord.currentTimeStamp = timestampForTouch(touch);
|
|
1071
1141
|
touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
|
1072
1142
|
} else {
|
|
1073
|
-
console.
|
|
1143
|
+
console.warn('Cannot record touch move without a touch start.\n' + 'Touch Move: %s\n', 'Touch Bank: %s', printTouch(touch), printTouchBank());
|
|
1074
1144
|
}
|
|
1075
1145
|
}
|
|
1076
1146
|
|
|
1077
1147
|
function recordTouchEnd(touch) {
|
|
1078
1148
|
var touchRecord = touchBank[getTouchIdentifier(touch)];
|
|
1149
|
+
|
|
1079
1150
|
if (touchRecord) {
|
|
1080
1151
|
touchRecord.touchActive = false;
|
|
1081
1152
|
touchRecord.previousPageX = touchRecord.currentPageX;
|
|
@@ -1086,7 +1157,7 @@ function recordTouchEnd(touch) {
|
|
|
1086
1157
|
touchRecord.currentTimeStamp = timestampForTouch(touch);
|
|
1087
1158
|
touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
|
1088
1159
|
} else {
|
|
1089
|
-
console.
|
|
1160
|
+
console.warn('Cannot record touch end without a touch start.\n' + 'Touch End: %s\n', 'Touch Bank: %s', printTouch(touch), printTouchBank());
|
|
1090
1161
|
}
|
|
1091
1162
|
}
|
|
1092
1163
|
|
|
@@ -1101,9 +1172,11 @@ function printTouch(touch) {
|
|
|
1101
1172
|
|
|
1102
1173
|
function printTouchBank() {
|
|
1103
1174
|
var printed = JSON.stringify(touchBank.slice(0, MAX_TOUCH_BANK));
|
|
1175
|
+
|
|
1104
1176
|
if (touchBank.length > MAX_TOUCH_BANK) {
|
|
1105
1177
|
printed += ' (original size: ' + touchBank.length + ')';
|
|
1106
1178
|
}
|
|
1179
|
+
|
|
1107
1180
|
return printed;
|
|
1108
1181
|
}
|
|
1109
1182
|
|
|
@@ -1114,20 +1187,24 @@ var ResponderTouchHistoryStore = {
|
|
|
1114
1187
|
} else if (isStartish(topLevelType)) {
|
|
1115
1188
|
nativeEvent.changedTouches.forEach(recordTouchStart);
|
|
1116
1189
|
touchHistory.numberActiveTouches = nativeEvent.touches.length;
|
|
1190
|
+
|
|
1117
1191
|
if (touchHistory.numberActiveTouches === 1) {
|
|
1118
1192
|
touchHistory.indexOfSingleActiveTouch = nativeEvent.touches[0].identifier;
|
|
1119
1193
|
}
|
|
1120
1194
|
} else if (isEndish(topLevelType)) {
|
|
1121
1195
|
nativeEvent.changedTouches.forEach(recordTouchEnd);
|
|
1122
1196
|
touchHistory.numberActiveTouches = nativeEvent.touches.length;
|
|
1197
|
+
|
|
1123
1198
|
if (touchHistory.numberActiveTouches === 1) {
|
|
1124
1199
|
for (var i = 0; i < touchBank.length; i++) {
|
|
1125
1200
|
var touchTrackToCheck = touchBank[i];
|
|
1201
|
+
|
|
1126
1202
|
if (touchTrackToCheck != null && touchTrackToCheck.touchActive) {
|
|
1127
1203
|
touchHistory.indexOfSingleActiveTouch = i;
|
|
1128
1204
|
break;
|
|
1129
1205
|
}
|
|
1130
1206
|
}
|
|
1207
|
+
|
|
1131
1208
|
{
|
|
1132
1209
|
var activeRecord = touchBank[touchHistory.indexOfSingleActiveTouch];
|
|
1133
1210
|
!(activeRecord != null && activeRecord.touchActive) ? warningWithoutStack$1(false, 'Cannot find single active touch.') : void 0;
|
|
@@ -1135,8 +1212,6 @@ var ResponderTouchHistoryStore = {
|
|
|
1135
1212
|
}
|
|
1136
1213
|
}
|
|
1137
1214
|
},
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
1215
|
touchHistory: touchHistory
|
|
1141
1216
|
};
|
|
1142
1217
|
|
|
@@ -1147,15 +1222,22 @@ var ResponderTouchHistoryStore = {
|
|
|
1147
1222
|
*
|
|
1148
1223
|
* @return {*|array<*>} An accumulation of items.
|
|
1149
1224
|
*/
|
|
1225
|
+
|
|
1150
1226
|
function accumulate(current, next) {
|
|
1151
|
-
|
|
1227
|
+
(function () {
|
|
1228
|
+
if (!(next != null)) {
|
|
1229
|
+
{
|
|
1230
|
+
throw ReactError(Error("accumulate(...): Accumulated items must not be null or undefined."));
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
})();
|
|
1152
1234
|
|
|
1153
1235
|
if (current == null) {
|
|
1154
1236
|
return next;
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
|
-
// Both are not empty. Warning: Never call x.concat(y) when you are not
|
|
1237
|
+
} // Both are not empty. Warning: Never call x.concat(y) when you are not
|
|
1158
1238
|
// certain that x is an Array (x could be a string with concat method).
|
|
1239
|
+
|
|
1240
|
+
|
|
1159
1241
|
if (Array.isArray(current)) {
|
|
1160
1242
|
return current.concat(next);
|
|
1161
1243
|
}
|
|
@@ -1171,17 +1253,19 @@ function accumulate(current, next) {
|
|
|
1171
1253
|
* Instance of element that should respond to touch/move types of interactions,
|
|
1172
1254
|
* as indicated explicitly by relevant callbacks.
|
|
1173
1255
|
*/
|
|
1174
|
-
var responderInst = null;
|
|
1175
1256
|
|
|
1257
|
+
var responderInst = null;
|
|
1176
1258
|
/**
|
|
1177
1259
|
* Count of current touches. A textInput should become responder iff the
|
|
1178
1260
|
* selection changes while there is a touch on the screen.
|
|
1179
1261
|
*/
|
|
1262
|
+
|
|
1180
1263
|
var trackedTouchCount = 0;
|
|
1181
1264
|
|
|
1182
1265
|
var changeResponder = function (nextResponderInst, blockHostResponder) {
|
|
1183
1266
|
var oldResponderInst = responderInst;
|
|
1184
1267
|
responderInst = nextResponderInst;
|
|
1268
|
+
|
|
1185
1269
|
if (ResponderEventPlugin.GlobalResponderHandler !== null) {
|
|
1186
1270
|
ResponderEventPlugin.GlobalResponderHandler.onChange(oldResponderInst, nextResponderInst, blockHostResponder);
|
|
1187
1271
|
}
|
|
@@ -1280,7 +1364,6 @@ var eventTypes = {
|
|
|
1280
1364
|
dependencies: []
|
|
1281
1365
|
}
|
|
1282
1366
|
};
|
|
1283
|
-
|
|
1284
1367
|
/**
|
|
1285
1368
|
*
|
|
1286
1369
|
* Responder System:
|
|
@@ -1472,24 +1555,25 @@ to return true:wantsResponderID| |
|
|
|
1472
1555
|
*/
|
|
1473
1556
|
|
|
1474
1557
|
function setResponderAndExtractTransfer(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
|
|
1475
|
-
var shouldSetEventType = isStartish(topLevelType) ? eventTypes.startShouldSetResponder : isMoveish(topLevelType) ? eventTypes.moveShouldSetResponder : topLevelType === TOP_SELECTION_CHANGE ? eventTypes.selectionChangeShouldSetResponder : eventTypes.scrollShouldSetResponder;
|
|
1476
|
-
|
|
1477
|
-
// TODO: stop one short of the current responder.
|
|
1478
|
-
var bubbleShouldSetFrom = !responderInst ? targetInst : getLowestCommonAncestor(responderInst, targetInst);
|
|
1558
|
+
var shouldSetEventType = isStartish(topLevelType) ? eventTypes.startShouldSetResponder : isMoveish(topLevelType) ? eventTypes.moveShouldSetResponder : topLevelType === TOP_SELECTION_CHANGE ? eventTypes.selectionChangeShouldSetResponder : eventTypes.scrollShouldSetResponder; // TODO: stop one short of the current responder.
|
|
1479
1559
|
|
|
1480
|
-
// When capturing/bubbling the "shouldSet" event, we want to skip the target
|
|
1560
|
+
var bubbleShouldSetFrom = !responderInst ? targetInst : getLowestCommonAncestor(responderInst, targetInst); // When capturing/bubbling the "shouldSet" event, we want to skip the target
|
|
1481
1561
|
// (deepest ID) if it happens to be the current responder. The reasoning:
|
|
1482
1562
|
// It's strange to get an `onMoveShouldSetResponder` when you're *already*
|
|
1483
1563
|
// the responder.
|
|
1564
|
+
|
|
1484
1565
|
var skipOverBubbleShouldSetFrom = bubbleShouldSetFrom === responderInst;
|
|
1485
1566
|
var shouldSetEvent = ResponderSyntheticEvent.getPooled(shouldSetEventType, bubbleShouldSetFrom, nativeEvent, nativeEventTarget);
|
|
1486
1567
|
shouldSetEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
|
1568
|
+
|
|
1487
1569
|
if (skipOverBubbleShouldSetFrom) {
|
|
1488
1570
|
accumulateTwoPhaseDispatchesSkipTarget(shouldSetEvent);
|
|
1489
1571
|
} else {
|
|
1490
1572
|
accumulateTwoPhaseDispatches(shouldSetEvent);
|
|
1491
1573
|
}
|
|
1574
|
+
|
|
1492
1575
|
var wantsResponderInst = executeDispatchesInOrderStopAtTrue(shouldSetEvent);
|
|
1576
|
+
|
|
1493
1577
|
if (!shouldSetEvent.isPersistent()) {
|
|
1494
1578
|
shouldSetEvent.constructor.release(shouldSetEvent);
|
|
1495
1579
|
}
|
|
@@ -1497,17 +1581,19 @@ function setResponderAndExtractTransfer(topLevelType, targetInst, nativeEvent, n
|
|
|
1497
1581
|
if (!wantsResponderInst || wantsResponderInst === responderInst) {
|
|
1498
1582
|
return null;
|
|
1499
1583
|
}
|
|
1500
|
-
|
|
1584
|
+
|
|
1585
|
+
var extracted;
|
|
1501
1586
|
var grantEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderGrant, wantsResponderInst, nativeEvent, nativeEventTarget);
|
|
1502
1587
|
grantEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
|
1503
|
-
|
|
1504
1588
|
accumulateDirectDispatches(grantEvent);
|
|
1505
1589
|
var blockHostResponder = executeDirectDispatch(grantEvent) === true;
|
|
1590
|
+
|
|
1506
1591
|
if (responderInst) {
|
|
1507
1592
|
var terminationRequestEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderTerminationRequest, responderInst, nativeEvent, nativeEventTarget);
|
|
1508
1593
|
terminationRequestEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
|
1509
1594
|
accumulateDirectDispatches(terminationRequestEvent);
|
|
1510
1595
|
var shouldSwitch = !hasDispatches(terminationRequestEvent) || executeDirectDispatch(terminationRequestEvent);
|
|
1596
|
+
|
|
1511
1597
|
if (!terminationRequestEvent.isPersistent()) {
|
|
1512
1598
|
terminationRequestEvent.constructor.release(terminationRequestEvent);
|
|
1513
1599
|
}
|
|
@@ -1528,9 +1614,9 @@ function setResponderAndExtractTransfer(topLevelType, targetInst, nativeEvent, n
|
|
|
1528
1614
|
extracted = accumulate(extracted, grantEvent);
|
|
1529
1615
|
changeResponder(wantsResponderInst, blockHostResponder);
|
|
1530
1616
|
}
|
|
1617
|
+
|
|
1531
1618
|
return extracted;
|
|
1532
1619
|
}
|
|
1533
|
-
|
|
1534
1620
|
/**
|
|
1535
1621
|
* A transfer is a negotiation between a currently set responder and the next
|
|
1536
1622
|
* element to claim responder status. Any start event could trigger a transfer
|
|
@@ -1539,14 +1625,14 @@ function setResponderAndExtractTransfer(topLevelType, targetInst, nativeEvent, n
|
|
|
1539
1625
|
* @param {string} topLevelType Record from `BrowserEventConstants`.
|
|
1540
1626
|
* @return {boolean} True if a transfer of responder could possibly occur.
|
|
1541
1627
|
*/
|
|
1628
|
+
|
|
1629
|
+
|
|
1542
1630
|
function canTriggerTransfer(topLevelType, topLevelInst, nativeEvent) {
|
|
1543
|
-
return topLevelInst && (
|
|
1544
|
-
// responderIgnoreScroll: We are trying to migrate away from specifically
|
|
1631
|
+
return topLevelInst && ( // responderIgnoreScroll: We are trying to migrate away from specifically
|
|
1545
1632
|
// tracking native scroll events here and responderIgnoreScroll indicates we
|
|
1546
1633
|
// will send topTouchCancel to handle canceling touch events instead
|
|
1547
1634
|
topLevelType === TOP_SCROLL && !nativeEvent.responderIgnoreScroll || trackedTouchCount > 0 && topLevelType === TOP_SELECTION_CHANGE || isStartish(topLevelType) || isMoveish(topLevelType));
|
|
1548
1635
|
}
|
|
1549
|
-
|
|
1550
1636
|
/**
|
|
1551
1637
|
* Returns whether or not this touch end event makes it such that there are no
|
|
1552
1638
|
* longer any touches that started inside of the current `responderInst`.
|
|
@@ -1554,22 +1640,29 @@ function canTriggerTransfer(topLevelType, topLevelInst, nativeEvent) {
|
|
|
1554
1640
|
* @param {NativeEvent} nativeEvent Native touch end event.
|
|
1555
1641
|
* @return {boolean} Whether or not this touch end event ends the responder.
|
|
1556
1642
|
*/
|
|
1643
|
+
|
|
1644
|
+
|
|
1557
1645
|
function noResponderTouches(nativeEvent) {
|
|
1558
1646
|
var touches = nativeEvent.touches;
|
|
1647
|
+
|
|
1559
1648
|
if (!touches || touches.length === 0) {
|
|
1560
1649
|
return true;
|
|
1561
1650
|
}
|
|
1651
|
+
|
|
1562
1652
|
for (var i = 0; i < touches.length; i++) {
|
|
1563
1653
|
var activeTouch = touches[i];
|
|
1564
1654
|
var target = activeTouch.target;
|
|
1655
|
+
|
|
1565
1656
|
if (target !== null && target !== undefined && target !== 0) {
|
|
1566
1657
|
// Is the original touch location inside of the current responder?
|
|
1567
1658
|
var targetInst = getInstanceFromNode$1(target);
|
|
1659
|
+
|
|
1568
1660
|
if (isAncestor(responderInst, targetInst)) {
|
|
1569
1661
|
return false;
|
|
1570
1662
|
}
|
|
1571
1663
|
}
|
|
1572
1664
|
}
|
|
1665
|
+
|
|
1573
1666
|
return true;
|
|
1574
1667
|
}
|
|
1575
1668
|
|
|
@@ -1578,7 +1671,6 @@ var ResponderEventPlugin = {
|
|
|
1578
1671
|
_getResponder: function () {
|
|
1579
1672
|
return responderInst;
|
|
1580
1673
|
},
|
|
1581
|
-
|
|
1582
1674
|
eventTypes: eventTypes,
|
|
1583
1675
|
|
|
1584
1676
|
/**
|
|
@@ -1586,22 +1678,20 @@ var ResponderEventPlugin = {
|
|
|
1586
1678
|
* `touchEnd`. On certain platforms, this means that a native scroll has
|
|
1587
1679
|
* assumed control and the original touch targets are destroyed.
|
|
1588
1680
|
*/
|
|
1589
|
-
extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
|
|
1681
|
+
extractEvents: function (topLevelType, eventSystemFlags, targetInst, nativeEvent, nativeEventTarget) {
|
|
1590
1682
|
if (isStartish(topLevelType)) {
|
|
1591
1683
|
trackedTouchCount += 1;
|
|
1592
1684
|
} else if (isEndish(topLevelType)) {
|
|
1593
1685
|
if (trackedTouchCount >= 0) {
|
|
1594
1686
|
trackedTouchCount -= 1;
|
|
1595
1687
|
} else {
|
|
1596
|
-
console.
|
|
1688
|
+
console.warn('Ended a touch event which was not counted in `trackedTouchCount`.');
|
|
1597
1689
|
return null;
|
|
1598
1690
|
}
|
|
1599
1691
|
}
|
|
1600
1692
|
|
|
1601
1693
|
ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent);
|
|
1602
|
-
|
|
1603
|
-
var extracted = canTriggerTransfer(topLevelType, targetInst, nativeEvent) ? setResponderAndExtractTransfer(topLevelType, targetInst, nativeEvent, nativeEventTarget) : null;
|
|
1604
|
-
// Responder may or may not have transferred on a new touch start/move.
|
|
1694
|
+
var extracted = canTriggerTransfer(topLevelType, targetInst, nativeEvent) ? setResponderAndExtractTransfer(topLevelType, targetInst, nativeEvent, nativeEventTarget) : null; // Responder may or may not have transferred on a new touch start/move.
|
|
1605
1695
|
// Regardless, whoever is the responder after any potential transfer, we
|
|
1606
1696
|
// direct all touch start/move/ends to them in the form of
|
|
1607
1697
|
// `onResponderMove/Start/End`. These will be called for *every* additional
|
|
@@ -1611,6 +1701,7 @@ var ResponderEventPlugin = {
|
|
|
1611
1701
|
// These multiple individual change touch events are are always bookended
|
|
1612
1702
|
// by `onResponderGrant`, and one of
|
|
1613
1703
|
// (`onResponderRelease/onResponderTerminate`).
|
|
1704
|
+
|
|
1614
1705
|
var isResponderTouchStart = responderInst && isStartish(topLevelType);
|
|
1615
1706
|
var isResponderTouchMove = responderInst && isMoveish(topLevelType);
|
|
1616
1707
|
var isResponderTouchEnd = responderInst && isEndish(topLevelType);
|
|
@@ -1626,6 +1717,7 @@ var ResponderEventPlugin = {
|
|
|
1626
1717
|
var isResponderTerminate = responderInst && topLevelType === TOP_TOUCH_CANCEL;
|
|
1627
1718
|
var isResponderRelease = responderInst && !isResponderTerminate && isEndish(topLevelType) && noResponderTouches(nativeEvent);
|
|
1628
1719
|
var finalTouch = isResponderTerminate ? eventTypes.responderTerminate : isResponderRelease ? eventTypes.responderRelease : null;
|
|
1720
|
+
|
|
1629
1721
|
if (finalTouch) {
|
|
1630
1722
|
var finalEvent = ResponderSyntheticEvent.getPooled(finalTouch, responderInst, nativeEvent, nativeEventTarget);
|
|
1631
1723
|
finalEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
|
@@ -1636,9 +1728,7 @@ var ResponderEventPlugin = {
|
|
|
1636
1728
|
|
|
1637
1729
|
return extracted;
|
|
1638
1730
|
},
|
|
1639
|
-
|
|
1640
1731
|
GlobalResponderHandler: null,
|
|
1641
|
-
|
|
1642
1732
|
injection: {
|
|
1643
1733
|
/**
|
|
1644
1734
|
* @param {{onChange: (ReactID, ReactID) => void} GlobalResponderHandler
|
|
@@ -1651,19 +1741,16 @@ var ResponderEventPlugin = {
|
|
|
1651
1741
|
}
|
|
1652
1742
|
};
|
|
1653
1743
|
|
|
1654
|
-
//
|
|
1655
|
-
|
|
1744
|
+
// Keep in sync with ReactDOM.js, ReactTestUtils.js, and ReactTestUtilsAct.js:
|
|
1745
|
+
|
|
1656
1746
|
var _ReactDOM$__SECRET_IN = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;
|
|
1657
1747
|
var getInstanceFromNode = _ReactDOM$__SECRET_IN[0];
|
|
1658
1748
|
var getNodeFromInstance = _ReactDOM$__SECRET_IN[1];
|
|
1659
1749
|
var getFiberCurrentPropsFromNode = _ReactDOM$__SECRET_IN[2];
|
|
1660
1750
|
var injectEventPluginsByName = _ReactDOM$__SECRET_IN[3];
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
1751
|
setComponentTree(getFiberCurrentPropsFromNode, getInstanceFromNode, getNodeFromInstance);
|
|
1664
1752
|
|
|
1665
1753
|
|
|
1666
|
-
|
|
1667
1754
|
var ReactDOMUnstableNativeDependencies = Object.freeze({
|
|
1668
1755
|
ResponderEventPlugin: ResponderEventPlugin,
|
|
1669
1756
|
ResponderTouchHistoryStore: ResponderTouchHistoryStore,
|