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

Fix when anchorNode is undefined instead of null #1407

Closed
wants to merge 2 commits into from

Conversation

tleunen
Copy link
Contributor

@tleunen tleunen commented Sep 25, 2017

Fixes #1399

nativeSelection.anchorNode can be undefined instead of null, so I'm changing the condition to handle this use case.

Fixes facebookarchive#1399

`nativeSelection.anchorNode` can be undefined instead of null, so I'm changing the condition to handle this use case.
Copy link
Contributor

@flarnie flarnie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this! Adding it to the queue for merging.

seal_of_approval

@@ -155,7 +155,7 @@ function editOnBeforeInput(
const nativeSelection = global.getSelection();
// Selection is necessarily collapsed at this point due to earlier check.
if (
nativeSelection.anchorNode !== null &&
nativeSelection.anchorNode &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally prefer to be more specific when checking for a value to be defined, but in this case we don't want any other falsy JS values either, so I think this is ok.

Copy link

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flarnie is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flarnie has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@flarnie flarnie added this to the v0.10.4 milestone Oct 5, 2017
@sophiebits
Copy link
Contributor

In what situation can anchorNode be undefined?

@tleunen tleunen deleted the patch-1 branch October 24, 2017 14:49
@tleunen
Copy link
Contributor Author

tleunen commented Oct 24, 2017

@sophiebits You can see an example in #1399 when using Enzyme. But I don't have access to that specific bit of code to really investigate why

midas19910709 added a commit to midas19910709/draft-js that referenced this pull request Mar 30, 2022
Summary:
Fixes #1399

`nativeSelection.anchorNode` can be undefined instead of null, so I'm changing the condition to handle this use case.
Closes facebookarchive/draft-js#1407

Differential Revision: D5974852

fbshipit-source-id: bb24ba0e3bf041530bdbea555f26e61d2b33022f
alicayan008 pushed a commit to alicayan008/draft-js that referenced this pull request Jul 4, 2023
Summary:
Fixes #1399

`nativeSelection.anchorNode` can be undefined instead of null, so I'm changing the condition to handle this use case.
Closes facebookarchive/draft-js#1407

Differential Revision: D5974852

fbshipit-source-id: bb24ba0e3bf041530bdbea555f26e61d2b33022f
aforismesen added a commit to aforismesen/draft-js that referenced this pull request Jul 12, 2024
Summary:
Fixes #1399

`nativeSelection.anchorNode` can be undefined instead of null, so I'm changing the condition to handle this use case.
Closes facebookarchive/draft-js#1407

Differential Revision: D5974852

fbshipit-source-id: bb24ba0e3bf041530bdbea555f26e61d2b33022f
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants