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