-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix when anchorNode is undefined instead of null #1407
Conversation
Fixes facebookarchive#1399 `nativeSelection.anchorNode` can be undefined instead of null, so I'm changing the condition to handle this use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -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 && |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
There was a problem hiding this 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.
In what situation can anchorNode be undefined? |
@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 |
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
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
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
Fixes #1399
nativeSelection.anchorNode
can be undefined instead of null, so I'm changing the condition to handle this use case.