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