Skip to content

Commit b8834b8

Browse files
committed
Revert "Clean up Selective Hydration / Event Replay flag (#24156)"
This reverts commit b5cca18.
1 parent b5cca18 commit b8834b8

19 files changed

+565
-72
lines changed

packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js

Lines changed: 80 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2418,8 +2418,18 @@ describe('ReactDOMServerPartialHydration', () => {
24182418
await promise;
24192419
});
24202420

2421-
expect(clicks).toBe(0);
2422-
expect(container.textContent).toBe('Click meHello');
2421+
if (
2422+
gate(
2423+
flags =>
2424+
flags.enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay,
2425+
)
2426+
) {
2427+
expect(clicks).toBe(0);
2428+
expect(container.textContent).toBe('Click meHello');
2429+
} else {
2430+
expect(clicks).toBe(1);
2431+
expect(container.textContent).toBe('Hello');
2432+
}
24232433
document.body.removeChild(container);
24242434
});
24252435

@@ -2501,7 +2511,17 @@ describe('ReactDOMServerPartialHydration', () => {
25012511
await promise;
25022512
});
25032513

2504-
expect(onEvent).toHaveBeenCalledTimes(0);
2514+
if (
2515+
gate(
2516+
flags =>
2517+
flags.enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay,
2518+
)
2519+
) {
2520+
expect(onEvent).toHaveBeenCalledTimes(0);
2521+
} else {
2522+
expect(onEvent).toHaveBeenCalledTimes(2);
2523+
}
2524+
25052525
document.body.removeChild(container);
25062526
});
25072527

@@ -2581,7 +2601,16 @@ describe('ReactDOMServerPartialHydration', () => {
25812601
await promise;
25822602
});
25832603

2584-
expect(clicks).toBe(0);
2604+
if (
2605+
gate(
2606+
flags =>
2607+
flags.enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay,
2608+
)
2609+
) {
2610+
expect(clicks).toBe(0);
2611+
} else {
2612+
expect(clicks).toBe(2);
2613+
}
25852614

25862615
document.body.removeChild(container);
25872616
});
@@ -2666,7 +2695,17 @@ describe('ReactDOMServerPartialHydration', () => {
26662695
resolve();
26672696
await promise;
26682697
});
2669-
expect(onEvent).toHaveBeenCalledTimes(0);
2698+
if (
2699+
gate(
2700+
flags =>
2701+
flags.enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay,
2702+
)
2703+
) {
2704+
expect(onEvent).toHaveBeenCalledTimes(0);
2705+
} else {
2706+
expect(onEvent).toHaveBeenCalledTimes(2);
2707+
}
2708+
26702709
document.body.removeChild(container);
26712710
});
26722711

@@ -2737,8 +2776,19 @@ describe('ReactDOMServerPartialHydration', () => {
27372776
await promise;
27382777
});
27392778

2740-
expect(clicksOnChild).toBe(0);
2741-
expect(clicksOnParent).toBe(0);
2779+
if (
2780+
gate(
2781+
flags =>
2782+
flags.enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay,
2783+
)
2784+
) {
2785+
expect(clicksOnChild).toBe(0);
2786+
expect(clicksOnParent).toBe(0);
2787+
} else {
2788+
expect(clicksOnChild).toBe(1);
2789+
// This will be zero due to the stopPropagation.
2790+
expect(clicksOnParent).toBe(0);
2791+
}
27422792

27432793
document.body.removeChild(container);
27442794
});
@@ -2814,7 +2864,16 @@ describe('ReactDOMServerPartialHydration', () => {
28142864
});
28152865

28162866
// We're now full hydrated.
2817-
expect(clicks).toBe(0);
2867+
if (
2868+
gate(
2869+
flags =>
2870+
flags.enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay,
2871+
)
2872+
) {
2873+
expect(clicks).toBe(0);
2874+
} else {
2875+
expect(clicks).toBe(1);
2876+
}
28182877

28192878
document.body.removeChild(parentContainer);
28202879
});
@@ -3083,9 +3142,19 @@ describe('ReactDOMServerPartialHydration', () => {
30833142
await promise;
30843143
});
30853144

3086-
// discrete event not replayed
3087-
expect(submits).toBe(0);
3088-
expect(container.textContent).toBe('Click meHello');
3145+
if (
3146+
gate(
3147+
flags =>
3148+
flags.enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay,
3149+
)
3150+
) {
3151+
// discrete event not replayed
3152+
expect(submits).toBe(0);
3153+
expect(container.textContent).toBe('Click meHello');
3154+
} else {
3155+
expect(submits).toBe(1);
3156+
expect(container.textContent).toBe('Hello');
3157+
}
30893158

30903159
document.body.removeChild(container);
30913160
});

0 commit comments

Comments
 (0)