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