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