react-dom 17.0.0-rc.1 → 17.0.1
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 +5 -5
- package/cjs/react-dom-server.browser.production.min.js +2 -2
- package/cjs/react-dom-server.node.development.js +5 -5
- package/cjs/react-dom-server.node.production.min.js +2 -2
- package/cjs/react-dom-test-utils.development.js +271 -138
- package/cjs/react-dom-test-utils.production.min.js +36 -33
- package/cjs/react-dom.development.js +747 -579
- package/cjs/react-dom.production.min.js +230 -231
- package/cjs/react-dom.profiling.min.js +258 -257
- package/package.json +3 -3
- package/umd/react-dom-server.browser.development.js +5 -5
- package/umd/react-dom-server.browser.production.min.js +3 -3
- package/umd/react-dom-test-utils.development.js +271 -138
- package/umd/react-dom-test-utils.production.min.js +27 -25
- package/umd/react-dom.development.js +747 -579
- package/umd/react-dom.production.min.js +232 -232
- package/umd/react-dom.profiling.min.js +241 -243
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React
|
|
1
|
+
/** @license React v17.0.1
|
|
2
2
|
* react-dom-test-utils.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -140,8 +140,8 @@ var HostComponent = 5;
|
|
|
140
140
|
var HostText = 6;
|
|
141
141
|
|
|
142
142
|
// Don't change these two values. They're used by React Dev Tools.
|
|
143
|
-
var
|
|
144
|
-
/*
|
|
143
|
+
var NoFlags =
|
|
144
|
+
/* */
|
|
145
145
|
0;
|
|
146
146
|
|
|
147
147
|
var Placement =
|
|
@@ -164,7 +164,7 @@ function getNearestMountedFiber(fiber) {
|
|
|
164
164
|
do {
|
|
165
165
|
node = nextNode;
|
|
166
166
|
|
|
167
|
-
if ((node.
|
|
167
|
+
if ((node.flags & (Placement | Hydrating)) !== NoFlags) {
|
|
168
168
|
// This is an insertion or in-progress hydration. The nearest possible
|
|
169
169
|
// mounted fiber is the parent but we need to continue to figure out
|
|
170
170
|
// if that one is still mounted.
|
|
@@ -409,136 +409,144 @@ function getEventCharCode(nativeEvent) {
|
|
|
409
409
|
return 0;
|
|
410
410
|
}
|
|
411
411
|
|
|
412
|
-
/**
|
|
413
|
-
* @interface Event
|
|
414
|
-
* @see http://www.w3.org/TR/DOM-Level-3-Events/
|
|
415
|
-
*/
|
|
416
|
-
var EventInterface = {
|
|
417
|
-
eventPhase: 0,
|
|
418
|
-
bubbles: 0,
|
|
419
|
-
cancelable: 0,
|
|
420
|
-
timeStamp: function (event) {
|
|
421
|
-
return event.timeStamp || Date.now();
|
|
422
|
-
},
|
|
423
|
-
defaultPrevented: 0,
|
|
424
|
-
isTrusted: 0
|
|
425
|
-
};
|
|
426
|
-
|
|
427
412
|
function functionThatReturnsTrue() {
|
|
428
413
|
return true;
|
|
429
414
|
}
|
|
430
415
|
|
|
431
416
|
function functionThatReturnsFalse() {
|
|
432
417
|
return false;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
* Synthetic events are dispatched by event plugins, typically in response to a
|
|
436
|
-
* top-level event delegation handler.
|
|
437
|
-
*
|
|
438
|
-
* These systems should generally use pooling to reduce the frequency of garbage
|
|
439
|
-
* collection. The system should check `isPersistent` to determine whether the
|
|
440
|
-
* event should be released into the pool after being dispatched. Users that
|
|
441
|
-
* need a persisted event should invoke `persist`.
|
|
442
|
-
*
|
|
443
|
-
* Synthetic events (and subclasses) implement the DOM Level 3 Events API by
|
|
444
|
-
* normalizing browser quirks. Subclasses do not necessarily have to implement a
|
|
445
|
-
* DOM interface; custom application-specific events can also subclass this.
|
|
446
|
-
*/
|
|
418
|
+
} // This is intentionally a factory so that we have different returned constructors.
|
|
419
|
+
// If we had a single constructor, it would be megamorphic and engines would deopt.
|
|
447
420
|
|
|
448
421
|
|
|
449
|
-
function
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
422
|
+
function createSyntheticEvent(Interface) {
|
|
423
|
+
/**
|
|
424
|
+
* Synthetic events are dispatched by event plugins, typically in response to a
|
|
425
|
+
* top-level event delegation handler.
|
|
426
|
+
*
|
|
427
|
+
* These systems should generally use pooling to reduce the frequency of garbage
|
|
428
|
+
* collection. The system should check `isPersistent` to determine whether the
|
|
429
|
+
* event should be released into the pool after being dispatched. Users that
|
|
430
|
+
* need a persisted event should invoke `persist`.
|
|
431
|
+
*
|
|
432
|
+
* Synthetic events (and subclasses) implement the DOM Level 3 Events API by
|
|
433
|
+
* normalizing browser quirks. Subclasses do not necessarily have to implement a
|
|
434
|
+
* DOM interface; custom application-specific events can also subclass this.
|
|
435
|
+
*/
|
|
436
|
+
function SyntheticBaseEvent(reactName, reactEventType, targetInst, nativeEvent, nativeEventTarget) {
|
|
437
|
+
this._reactName = reactName;
|
|
438
|
+
this._targetInst = targetInst;
|
|
439
|
+
this.type = reactEventType;
|
|
440
|
+
this.nativeEvent = nativeEvent;
|
|
441
|
+
this.target = nativeEventTarget;
|
|
442
|
+
this.currentTarget = null;
|
|
443
|
+
|
|
444
|
+
for (var _propName in Interface) {
|
|
445
|
+
if (!Interface.hasOwnProperty(_propName)) {
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
457
448
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
449
|
+
var normalize = Interface[_propName];
|
|
450
|
+
|
|
451
|
+
if (normalize) {
|
|
452
|
+
this[_propName] = normalize(nativeEvent);
|
|
453
|
+
} else {
|
|
454
|
+
this[_propName] = nativeEvent[_propName];
|
|
455
|
+
}
|
|
461
456
|
}
|
|
462
457
|
|
|
463
|
-
var
|
|
458
|
+
var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
|
|
464
459
|
|
|
465
|
-
if (
|
|
466
|
-
this
|
|
460
|
+
if (defaultPrevented) {
|
|
461
|
+
this.isDefaultPrevented = functionThatReturnsTrue;
|
|
467
462
|
} else {
|
|
468
|
-
this
|
|
463
|
+
this.isDefaultPrevented = functionThatReturnsFalse;
|
|
469
464
|
}
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
|
|
473
465
|
|
|
474
|
-
|
|
475
|
-
this
|
|
476
|
-
} else {
|
|
477
|
-
this.isDefaultPrevented = functionThatReturnsFalse;
|
|
466
|
+
this.isPropagationStopped = functionThatReturnsFalse;
|
|
467
|
+
return this;
|
|
478
468
|
}
|
|
479
469
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
470
|
+
_assign(SyntheticBaseEvent.prototype, {
|
|
471
|
+
preventDefault: function () {
|
|
472
|
+
this.defaultPrevented = true;
|
|
473
|
+
var event = this.nativeEvent;
|
|
483
474
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
var event = this.nativeEvent;
|
|
475
|
+
if (!event) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
488
478
|
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
479
|
+
if (event.preventDefault) {
|
|
480
|
+
event.preventDefault(); // $FlowFixMe - flow is not aware of `unknown` in IE
|
|
481
|
+
} else if (typeof event.returnValue !== 'unknown') {
|
|
482
|
+
event.returnValue = false;
|
|
483
|
+
}
|
|
492
484
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
event
|
|
497
|
-
}
|
|
485
|
+
this.isDefaultPrevented = functionThatReturnsTrue;
|
|
486
|
+
},
|
|
487
|
+
stopPropagation: function () {
|
|
488
|
+
var event = this.nativeEvent;
|
|
498
489
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
var event = this.nativeEvent;
|
|
490
|
+
if (!event) {
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
503
493
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
494
|
+
if (event.stopPropagation) {
|
|
495
|
+
event.stopPropagation(); // $FlowFixMe - flow is not aware of `unknown` in IE
|
|
496
|
+
} else if (typeof event.cancelBubble !== 'unknown') {
|
|
497
|
+
// The ChangeEventPlugin registers a "propertychange" event for
|
|
498
|
+
// IE. This event does not support bubbling or cancelling, and
|
|
499
|
+
// any references to cancelBubble throw "Member not found". A
|
|
500
|
+
// typeof check of "unknown" circumvents this issue (and is also
|
|
501
|
+
// IE specific).
|
|
502
|
+
event.cancelBubble = true;
|
|
503
|
+
}
|
|
507
504
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
}
|
|
505
|
+
this.isPropagationStopped = functionThatReturnsTrue;
|
|
506
|
+
},
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* We release all dispatched `SyntheticEvent`s after each event loop, adding
|
|
510
|
+
* them back into the pool. This allows a way to hold onto a reference that
|
|
511
|
+
* won't be added back into the pool.
|
|
512
|
+
*/
|
|
513
|
+
persist: function () {// Modern event system doesn't use pooling.
|
|
514
|
+
},
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Checks if this event should be released back into the pool.
|
|
518
|
+
*
|
|
519
|
+
* @return {boolean} True if this should not be released, false otherwise.
|
|
520
|
+
*/
|
|
521
|
+
isPersistent: functionThatReturnsTrue
|
|
522
|
+
});
|
|
518
523
|
|
|
519
|
-
|
|
520
|
-
|
|
524
|
+
return SyntheticBaseEvent;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* @interface Event
|
|
528
|
+
* @see http://www.w3.org/TR/DOM-Level-3-Events/
|
|
529
|
+
*/
|
|
521
530
|
|
|
522
|
-
/**
|
|
523
|
-
* We release all dispatched `SyntheticEvent`s after each event loop, adding
|
|
524
|
-
* them back into the pool. This allows a way to hold onto a reference that
|
|
525
|
-
* won't be added back into the pool.
|
|
526
|
-
*/
|
|
527
|
-
persist: function () {// Modern event system doesn't use pooling.
|
|
528
|
-
},
|
|
529
531
|
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
}
|
|
532
|
+
var EventInterface = {
|
|
533
|
+
eventPhase: 0,
|
|
534
|
+
bubbles: 0,
|
|
535
|
+
cancelable: 0,
|
|
536
|
+
timeStamp: function (event) {
|
|
537
|
+
return event.timeStamp || Date.now();
|
|
538
|
+
},
|
|
539
|
+
defaultPrevented: 0,
|
|
540
|
+
isTrusted: 0
|
|
541
|
+
};
|
|
542
|
+
var SyntheticEvent = createSyntheticEvent(EventInterface);
|
|
537
543
|
|
|
538
544
|
var UIEventInterface = _assign({}, EventInterface, {
|
|
539
545
|
view: 0,
|
|
540
546
|
detail: 0
|
|
541
547
|
});
|
|
548
|
+
|
|
549
|
+
var SyntheticUIEvent = createSyntheticEvent(UIEventInterface);
|
|
542
550
|
var lastMovementX;
|
|
543
551
|
var lastMovementY;
|
|
544
552
|
var lastMouseEvent;
|
|
@@ -599,6 +607,8 @@ var MouseEventInterface = _assign({}, UIEventInterface, {
|
|
|
599
607
|
return lastMovementY;
|
|
600
608
|
}
|
|
601
609
|
});
|
|
610
|
+
|
|
611
|
+
var SyntheticMouseEvent = createSyntheticEvent(MouseEventInterface);
|
|
602
612
|
/**
|
|
603
613
|
* @interface DragEvent
|
|
604
614
|
* @see http://www.w3.org/TR/DOM-Level-3-Events/
|
|
@@ -607,6 +617,8 @@ var MouseEventInterface = _assign({}, UIEventInterface, {
|
|
|
607
617
|
var DragEventInterface = _assign({}, MouseEventInterface, {
|
|
608
618
|
dataTransfer: 0
|
|
609
619
|
});
|
|
620
|
+
|
|
621
|
+
var SyntheticDragEvent = createSyntheticEvent(DragEventInterface);
|
|
610
622
|
/**
|
|
611
623
|
* @interface FocusEvent
|
|
612
624
|
* @see http://www.w3.org/TR/DOM-Level-3-Events/
|
|
@@ -615,6 +627,8 @@ var DragEventInterface = _assign({}, MouseEventInterface, {
|
|
|
615
627
|
var FocusEventInterface = _assign({}, UIEventInterface, {
|
|
616
628
|
relatedTarget: 0
|
|
617
629
|
});
|
|
630
|
+
|
|
631
|
+
var SyntheticFocusEvent = createSyntheticEvent(FocusEventInterface);
|
|
618
632
|
/**
|
|
619
633
|
* @interface Event
|
|
620
634
|
* @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface
|
|
@@ -626,6 +640,8 @@ var AnimationEventInterface = _assign({}, EventInterface, {
|
|
|
626
640
|
elapsedTime: 0,
|
|
627
641
|
pseudoElement: 0
|
|
628
642
|
});
|
|
643
|
+
|
|
644
|
+
var SyntheticAnimationEvent = createSyntheticEvent(AnimationEventInterface);
|
|
629
645
|
/**
|
|
630
646
|
* @interface Event
|
|
631
647
|
* @see http://www.w3.org/TR/clipboard-apis/
|
|
@@ -636,6 +652,8 @@ var ClipboardEventInterface = _assign({}, EventInterface, {
|
|
|
636
652
|
return 'clipboardData' in event ? event.clipboardData : window.clipboardData;
|
|
637
653
|
}
|
|
638
654
|
});
|
|
655
|
+
|
|
656
|
+
var SyntheticClipboardEvent = createSyntheticEvent(ClipboardEventInterface);
|
|
639
657
|
/**
|
|
640
658
|
* @interface Event
|
|
641
659
|
* @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents
|
|
@@ -644,6 +662,8 @@ var ClipboardEventInterface = _assign({}, EventInterface, {
|
|
|
644
662
|
var CompositionEventInterface = _assign({}, EventInterface, {
|
|
645
663
|
data: 0
|
|
646
664
|
});
|
|
665
|
+
|
|
666
|
+
var SyntheticCompositionEvent = createSyntheticEvent(CompositionEventInterface);
|
|
647
667
|
/**
|
|
648
668
|
* Normalization of deprecated HTML5 `key` values
|
|
649
669
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
|
|
@@ -827,6 +847,8 @@ var KeyboardEventInterface = _assign({}, UIEventInterface, {
|
|
|
827
847
|
return 0;
|
|
828
848
|
}
|
|
829
849
|
});
|
|
850
|
+
|
|
851
|
+
var SyntheticKeyboardEvent = createSyntheticEvent(KeyboardEventInterface);
|
|
830
852
|
/**
|
|
831
853
|
* @interface PointerEvent
|
|
832
854
|
* @see http://www.w3.org/TR/pointerevents/
|
|
@@ -844,6 +866,8 @@ var PointerEventInterface = _assign({}, MouseEventInterface, {
|
|
|
844
866
|
pointerType: 0,
|
|
845
867
|
isPrimary: 0
|
|
846
868
|
});
|
|
869
|
+
|
|
870
|
+
var SyntheticPointerEvent = createSyntheticEvent(PointerEventInterface);
|
|
847
871
|
/**
|
|
848
872
|
* @interface TouchEvent
|
|
849
873
|
* @see http://www.w3.org/TR/touch-events/
|
|
@@ -859,6 +883,8 @@ var TouchEventInterface = _assign({}, UIEventInterface, {
|
|
|
859
883
|
shiftKey: 0,
|
|
860
884
|
getModifierState: getEventModifierState
|
|
861
885
|
});
|
|
886
|
+
|
|
887
|
+
var SyntheticTouchEvent = createSyntheticEvent(TouchEventInterface);
|
|
862
888
|
/**
|
|
863
889
|
* @interface Event
|
|
864
890
|
* @see http://www.w3.org/TR/2009/WD-css3-transitions-20090320/#transition-events-
|
|
@@ -870,6 +896,8 @@ var TransitionEventInterface = _assign({}, EventInterface, {
|
|
|
870
896
|
elapsedTime: 0,
|
|
871
897
|
pseudoElement: 0
|
|
872
898
|
});
|
|
899
|
+
|
|
900
|
+
var SyntheticTransitionEvent = createSyntheticEvent(TransitionEventInterface);
|
|
873
901
|
/**
|
|
874
902
|
* @interface WheelEvent
|
|
875
903
|
* @see http://www.w3.org/TR/DOM-Level-3-Events/
|
|
@@ -893,6 +921,8 @@ var WheelEventInterface = _assign({}, MouseEventInterface, {
|
|
|
893
921
|
deltaMode: 0
|
|
894
922
|
});
|
|
895
923
|
|
|
924
|
+
var SyntheticWheelEvent = createSyntheticEvent(WheelEventInterface);
|
|
925
|
+
|
|
896
926
|
/**
|
|
897
927
|
* HTML nodeType values that represent the type of the node
|
|
898
928
|
*/
|
|
@@ -935,21 +965,24 @@ function enqueueTask(task) {
|
|
|
935
965
|
return enqueueTaskImpl(task);
|
|
936
966
|
}
|
|
937
967
|
|
|
938
|
-
var
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
getFiberCurrentPropsFromNode = _ReactDOM$__SECRET_IN[2],
|
|
944
|
-
enqueueStateRestore = _ReactDOM$__SECRET_IN[3],
|
|
945
|
-
restoreStateIfNeeded = _ReactDOM$__SECRET_IN[4],
|
|
968
|
+
var EventInternals = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events; // const getInstanceFromNode = EventInternals[0];
|
|
969
|
+
// const getNodeFromInstance = EventInternals[1];
|
|
970
|
+
// const getFiberCurrentPropsFromNode = EventInternals[2];
|
|
971
|
+
// const enqueueStateRestore = EventInternals[3];
|
|
972
|
+
// const restoreStateIfNeeded = EventInternals[4];
|
|
946
973
|
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
IsThisRendererActing = _ReactDOM$__SECRET_IN[6];
|
|
974
|
+
var flushPassiveEffects = EventInternals[5];
|
|
975
|
+
var IsThisRendererActing = EventInternals[6];
|
|
950
976
|
var batchedUpdates = ReactDOM.unstable_batchedUpdates;
|
|
951
|
-
var IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing; //
|
|
952
|
-
//
|
|
977
|
+
var IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing; // This is the public version of `ReactTestUtils.act`. It is implemented in
|
|
978
|
+
// "userspace" (i.e. not the reconciler), so that it doesn't add to the
|
|
979
|
+
// production bundle size.
|
|
980
|
+
// TODO: Remove this implementation of `act` in favor of the one exported by
|
|
981
|
+
// the reconciler. To do this, we must first drop support for `act` in
|
|
982
|
+
// production mode.
|
|
983
|
+
// TODO: Remove support for the mock scheduler build, which was only added for
|
|
984
|
+
// the purposes of internal testing. Internal tests should use
|
|
985
|
+
// `unstable_concurrentAct` instead.
|
|
953
986
|
|
|
954
987
|
var isSchedulerMocked = typeof Scheduler.unstable_flushAllWithoutAsserting === 'function';
|
|
955
988
|
|
|
@@ -981,7 +1014,6 @@ function flushWorkAndMicroTasks(onDone) {
|
|
|
981
1014
|
|
|
982
1015
|
|
|
983
1016
|
var actingUpdatesScopeDepth = 0;
|
|
984
|
-
|
|
985
1017
|
function act(callback) {
|
|
986
1018
|
|
|
987
1019
|
var previousActingUpdatesScopeDepth = actingUpdatesScopeDepth;
|
|
@@ -1094,6 +1126,114 @@ function act(callback) {
|
|
|
1094
1126
|
}
|
|
1095
1127
|
}
|
|
1096
1128
|
|
|
1129
|
+
var EventInternals$1 = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events; // const getInstanceFromNode = EventInternals[0];
|
|
1130
|
+
// const getNodeFromInstance = EventInternals[1];
|
|
1131
|
+
// const getFiberCurrentPropsFromNode = EventInternals[2];
|
|
1132
|
+
// const enqueueStateRestore = EventInternals[3];
|
|
1133
|
+
// const restoreStateIfNeeded = EventInternals[4];
|
|
1134
|
+
// const flushPassiveEffects = EventInternals[5];
|
|
1135
|
+
|
|
1136
|
+
var IsThisRendererActing$1 = EventInternals$1[6];
|
|
1137
|
+
var batchedUpdates$1 = ReactDOM.unstable_batchedUpdates;
|
|
1138
|
+
var IsSomeRendererActing$1 = ReactSharedInternals.IsSomeRendererActing; // This version of `act` is only used by our tests. Unlike the public version
|
|
1139
|
+
// of `act`, it's designed to work identically in both production and
|
|
1140
|
+
// development. It may have slightly different behavior from the public
|
|
1141
|
+
// version, too, since our constraints in our test suite are not the same as
|
|
1142
|
+
// those of developers using React — we're testing React itself, as opposed to
|
|
1143
|
+
// building an app with React.
|
|
1144
|
+
|
|
1145
|
+
var actingUpdatesScopeDepth$1 = 0;
|
|
1146
|
+
function unstable_concurrentAct(scope) {
|
|
1147
|
+
if (Scheduler.unstable_flushAllWithoutAsserting === undefined) {
|
|
1148
|
+
throw Error('This version of `act` requires a special mock build of Scheduler.');
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
if (setTimeout._isMockFunction !== true) {
|
|
1152
|
+
throw Error("This version of `act` requires Jest's timer mocks " + '(i.e. jest.useFakeTimers).');
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
var previousActingUpdatesScopeDepth = actingUpdatesScopeDepth$1;
|
|
1156
|
+
var previousIsSomeRendererActing = IsSomeRendererActing$1.current;
|
|
1157
|
+
var previousIsThisRendererActing = IsThisRendererActing$1.current;
|
|
1158
|
+
IsSomeRendererActing$1.current = true;
|
|
1159
|
+
IsThisRendererActing$1.current = true;
|
|
1160
|
+
actingUpdatesScopeDepth$1++;
|
|
1161
|
+
|
|
1162
|
+
var unwind = function () {
|
|
1163
|
+
actingUpdatesScopeDepth$1--;
|
|
1164
|
+
IsSomeRendererActing$1.current = previousIsSomeRendererActing;
|
|
1165
|
+
IsThisRendererActing$1.current = previousIsThisRendererActing;
|
|
1166
|
+
|
|
1167
|
+
{
|
|
1168
|
+
if (actingUpdatesScopeDepth$1 > previousActingUpdatesScopeDepth) {
|
|
1169
|
+
// if it's _less than_ previousActingUpdatesScopeDepth, then we can
|
|
1170
|
+
// assume the 'other' one has warned
|
|
1171
|
+
error('You seem to have overlapping act() calls, this is not supported. ' + 'Be sure to await previous act() calls before making a new one. ');
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
}; // TODO: This would be way simpler if 1) we required a promise to be
|
|
1175
|
+
// returned and 2) we could use async/await. Since it's only our used in
|
|
1176
|
+
// our test suite, we should be able to.
|
|
1177
|
+
|
|
1178
|
+
|
|
1179
|
+
try {
|
|
1180
|
+
var thenable = batchedUpdates$1(scope);
|
|
1181
|
+
|
|
1182
|
+
if (typeof thenable === 'object' && thenable !== null && typeof thenable.then === 'function') {
|
|
1183
|
+
return {
|
|
1184
|
+
then: function (resolve, reject) {
|
|
1185
|
+
thenable.then(function () {
|
|
1186
|
+
flushActWork(function () {
|
|
1187
|
+
unwind();
|
|
1188
|
+
resolve();
|
|
1189
|
+
}, function (error) {
|
|
1190
|
+
unwind();
|
|
1191
|
+
reject(error);
|
|
1192
|
+
});
|
|
1193
|
+
}, function (error) {
|
|
1194
|
+
unwind();
|
|
1195
|
+
reject(error);
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1198
|
+
};
|
|
1199
|
+
} else {
|
|
1200
|
+
try {
|
|
1201
|
+
// TODO: Let's not support non-async scopes at all in our tests. Need to
|
|
1202
|
+
// migrate existing tests.
|
|
1203
|
+
var didFlushWork;
|
|
1204
|
+
|
|
1205
|
+
do {
|
|
1206
|
+
didFlushWork = Scheduler.unstable_flushAllWithoutAsserting();
|
|
1207
|
+
} while (didFlushWork);
|
|
1208
|
+
} finally {
|
|
1209
|
+
unwind();
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
} catch (error) {
|
|
1213
|
+
unwind();
|
|
1214
|
+
throw error;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
function flushActWork(resolve, reject) {
|
|
1219
|
+
// Flush suspended fallbacks
|
|
1220
|
+
// $FlowFixMe: Flow doesn't know about global Jest object
|
|
1221
|
+
jest.runOnlyPendingTimers();
|
|
1222
|
+
enqueueTask(function () {
|
|
1223
|
+
try {
|
|
1224
|
+
var didFlushWork = Scheduler.unstable_flushAllWithoutAsserting();
|
|
1225
|
+
|
|
1226
|
+
if (didFlushWork) {
|
|
1227
|
+
flushActWork(resolve, reject);
|
|
1228
|
+
} else {
|
|
1229
|
+
resolve();
|
|
1230
|
+
}
|
|
1231
|
+
} catch (error) {
|
|
1232
|
+
reject(error);
|
|
1233
|
+
}
|
|
1234
|
+
});
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1097
1237
|
function invokeGuardedCallbackProd(name, func, context, a, b, c, d, e, f) {
|
|
1098
1238
|
var funcArgs = Array.prototype.slice.call(arguments, 3);
|
|
1099
1239
|
|
|
@@ -1345,22 +1485,14 @@ function clearCaughtError() {
|
|
|
1345
1485
|
}
|
|
1346
1486
|
}
|
|
1347
1487
|
|
|
1348
|
-
var
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
enqueueStateRestore$1 = _ReactDOM$__SECRET_IN$1[3],
|
|
1357
|
-
restoreStateIfNeeded$1 = _ReactDOM$__SECRET_IN$1[4],
|
|
1358
|
-
|
|
1359
|
-
/* eslint-disable no-unused-vars */
|
|
1360
|
-
flushPassiveEffects$1 = _ReactDOM$__SECRET_IN$1[5],
|
|
1361
|
-
IsThisRendererActing$1
|
|
1362
|
-
/* eslint-enable no-unused-vars */
|
|
1363
|
-
= _ReactDOM$__SECRET_IN$1[6];
|
|
1488
|
+
var EventInternals$2 = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;
|
|
1489
|
+
var getInstanceFromNode = EventInternals$2[0];
|
|
1490
|
+
var getNodeFromInstance = EventInternals$2[1];
|
|
1491
|
+
var getFiberCurrentPropsFromNode = EventInternals$2[2];
|
|
1492
|
+
var enqueueStateRestore = EventInternals$2[3];
|
|
1493
|
+
var restoreStateIfNeeded = EventInternals$2[4]; // const flushPassiveEffects = EventInternals[5];
|
|
1494
|
+
// TODO: This is related to `act`, not events. Move to separate key?
|
|
1495
|
+
// const IsThisRendererActing = EventInternals[6];
|
|
1364
1496
|
|
|
1365
1497
|
function Event(suffix) {}
|
|
1366
1498
|
|
|
@@ -1681,7 +1813,7 @@ function nativeTouchData(x, y) {
|
|
|
1681
1813
|
|
|
1682
1814
|
function executeDispatch(event, listener, inst) {
|
|
1683
1815
|
var type = event.type || 'unknown-event';
|
|
1684
|
-
event.currentTarget = getNodeFromInstance
|
|
1816
|
+
event.currentTarget = getNodeFromInstance(inst);
|
|
1685
1817
|
invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event);
|
|
1686
1818
|
event.currentTarget = null;
|
|
1687
1819
|
}
|
|
@@ -1807,7 +1939,7 @@ function getListener(inst, registrationName) {
|
|
|
1807
1939
|
return null;
|
|
1808
1940
|
}
|
|
1809
1941
|
|
|
1810
|
-
var props = getFiberCurrentPropsFromNode
|
|
1942
|
+
var props = getFiberCurrentPropsFromNode(stateNode);
|
|
1811
1943
|
|
|
1812
1944
|
if (!props) {
|
|
1813
1945
|
// Work in progress.
|
|
@@ -1926,7 +2058,7 @@ function makeSimulator(eventType) {
|
|
|
1926
2058
|
var fakeNativeEvent = new Event();
|
|
1927
2059
|
fakeNativeEvent.target = domNode;
|
|
1928
2060
|
fakeNativeEvent.type = eventType.toLowerCase();
|
|
1929
|
-
var targetInst = getInstanceFromNode
|
|
2061
|
+
var targetInst = getInstanceFromNode(domNode);
|
|
1930
2062
|
var event = new SyntheticEvent(reactName, fakeNativeEvent.type, targetInst, fakeNativeEvent, domNode); // Since we aren't using pooling, always persist the event. This will make
|
|
1931
2063
|
// sure it's marked and won't warn when setting additional properties.
|
|
1932
2064
|
|
|
@@ -1943,11 +2075,11 @@ function makeSimulator(eventType) {
|
|
|
1943
2075
|
ReactDOM.unstable_batchedUpdates(function () {
|
|
1944
2076
|
// Normally extractEvent enqueues a state restore, but we'll just always
|
|
1945
2077
|
// do that since we're by-passing it here.
|
|
1946
|
-
enqueueStateRestore
|
|
2078
|
+
enqueueStateRestore(domNode);
|
|
1947
2079
|
executeDispatchesAndRelease(event);
|
|
1948
2080
|
rethrowCaughtError();
|
|
1949
2081
|
});
|
|
1950
|
-
restoreStateIfNeeded
|
|
2082
|
+
restoreStateIfNeeded();
|
|
1951
2083
|
};
|
|
1952
2084
|
} // A one-time snapshot with no plans to update. We'll probably want to deprecate Simulate API.
|
|
1953
2085
|
|
|
@@ -1981,5 +2113,6 @@ exports.scryRenderedComponentsWithType = scryRenderedComponentsWithType;
|
|
|
1981
2113
|
exports.scryRenderedDOMComponentsWithClass = scryRenderedDOMComponentsWithClass;
|
|
1982
2114
|
exports.scryRenderedDOMComponentsWithTag = scryRenderedDOMComponentsWithTag;
|
|
1983
2115
|
exports.traverseTwoPhase = traverseTwoPhase;
|
|
2116
|
+
exports.unstable_concurrentAct = unstable_concurrentAct;
|
|
1984
2117
|
})();
|
|
1985
2118
|
}
|