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