-
Notifications
You must be signed in to change notification settings - Fork 47.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove an extra allocation for open source bundles (#11797)
* Remove EventListener fbjs utility EventListener normalizes event subscription for <= IE8. This is no longer necessary. element.addEventListener is sufficient. * Remove an extra allocation for open source bundles * Split into two functions to avoid extra runtime checks * Revert unrelated changes
- Loading branch information
Showing
5 changed files
with
82 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
export function addEventBubbleListener( | ||
element: Element, | ||
eventType: string, | ||
listener: Function, | ||
): void { | ||
element.addEventListener(eventType, listener, false); | ||
} | ||
|
||
export function addEventCaptureListener( | ||
element: Element, | ||
eventType: string, | ||
listener: Function, | ||
): void { | ||
element.addEventListener(eventType, listener, true); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
var EventListenerWWW = require('EventListener'); | ||
|
||
import typeof * as EventListenerType from '../EventListener'; | ||
import typeof * as EventListenerShimType from './EventListener-www'; | ||
|
||
export function addEventBubbleListener( | ||
element: Element, | ||
eventType: string, | ||
listener: Function, | ||
): void { | ||
EventListenerWWW.listen(element, eventType, listener); | ||
} | ||
|
||
export function addEventCaptureListener( | ||
element: Element, | ||
eventType: string, | ||
listener: Function, | ||
): void { | ||
EventListenerWWW.capture(element, eventType, listener); | ||
} | ||
|
||
// Flow magic to verify the exports of this file match the original version. | ||
// eslint-disable-next-line no-unused-vars | ||
type Check<_X, Y: _X, X: Y = _X> = null; | ||
// eslint-disable-next-line no-unused-expressions | ||
(null: Check<EventListenerShimType, EventListenerType>); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters