@samitouri / QOS-React-2 / commits / 3c1a7ac87c

Move TOP_BEFORE_BLUR to bubble phase (#19197)

Dominic Gannaway committed Jun 26, 2020 at 20:35 UTC 3c1a7ac87c5b4903aa0de02d11bd9ec2590ad598
2 files changed +4 -6
packages/react-dom/src/client/ReactDOMHostConfig.js
+4 -4
@@ -508,15 +508,15 @@ export function insertInContainerBefore(
508 }
509 }
510
511 -function createEvent(type: TopLevelType): Event {
511 +function createEvent(type: TopLevelType, bubbles: boolean): Event {
512 const event = document.createEvent('Event');
513 - event.initEvent(((type: any): string), false, false);
513 + event.initEvent(((type: any): string), bubbles, false);
514 return event;
515 }
516
517 function dispatchBeforeDetachedBlur(target: HTMLElement): void {
518 if (enableDeprecatedFlareAPI || enableCreateEventHandleAPI) {
519 - const event = createEvent(TOP_BEFORE_BLUR);
519 + const event = createEvent(TOP_BEFORE_BLUR, true);
520 // Dispatch "beforeblur" directly on the target,
521 // so it gets picked up by the event system and
522 // can propagate through the React internal tree.
@@ -526,7 +526,7 @@ function dispatchBeforeDetachedBlur(target: HTMLElement): void {
526
527 function dispatchAfterDetachedBlur(target: HTMLElement): void {
528 if (enableDeprecatedFlareAPI || enableCreateEventHandleAPI) {
529 - const event = createEvent(TOP_AFTER_BLUR);
529 + const event = createEvent(TOP_AFTER_BLUR, false);
530 // So we know what was detached, make the relatedTarget the
531 // detached target on the "afterblur" event.
532 (event: any).relatedTarget = target;
packages/react-dom/src/events/DOMModernPluginEventSystem.js
-2
@@ -81,7 +81,6 @@ import {
81 TOP_PLAYING,
82 TOP_CLICK,
83 TOP_SELECTION_CHANGE,
84 - TOP_BEFORE_BLUR,
84 TOP_AFTER_BLUR,
85 getRawEventName,
86 } from './DOMTopLevelEventTypes';
@@ -152,7 +151,6 @@ export const capturePhaseEvents: Set<DOMTopLevelEventType> = new Set([
151 ]);
152
153 if (enableCreateEventHandleAPI) {
155 - capturePhaseEvents.add(TOP_BEFORE_BLUR);
154 capturePhaseEvents.add(TOP_AFTER_BLUR);
155 }
156