Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
getEntityKeyForSelection.js
Browse files Browse the repository at this point in the history
Summary: `getEntityKeyForSelection.js` could use some flowification. This doesn't change functionality, since  `notEmptyKey` implements the same logic `entityKey` used to be checked with.

Reviewed By: miorel

Differential Revision: D16854973

fbshipit-source-id: 18a56b020a9f98cc27e4d1bd5acb6bd215c6ea05
  • Loading branch information
mrkev authored and facebook-github-bot committed Dec 4, 2019
1 parent 9b4a628 commit c07a404
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/model/entity/getEntityKeyForSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
* @flow strict-local
* @emails oncall+draft_js
*/

Expand All @@ -15,6 +15,8 @@ import type ContentState from 'ContentState';
import type {EntityMap} from 'EntityMap';
import type SelectionState from 'SelectionState';

const {notEmptyKey} = require('draftKeyUtils');

/**
* Return the entity key that should be used when inserting text for the
* specified target selection, only if the entity is `MUTABLE`. `IMMUTABLE`
Expand Down Expand Up @@ -56,7 +58,7 @@ function getEntityKeyForSelection(
* return it. If not, return null.
*/
function filterKey(entityMap: EntityMap, entityKey: ?string): ?string {
if (entityKey) {
if (notEmptyKey(entityKey)) {
const entity = entityMap.__get(entityKey);
return entity.getMutability() === 'MUTABLE' ? entityKey : null;
}
Expand Down

0 comments on commit c07a404

Please sign in to comment.