1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-01 05:16:10 +01:00

Fix an occasional crash in Firefox in isInEditor (#2229)

* Fix an occasional crash in Firefox in isInEditor

* Update content.js
This commit is contained in:
Kaspars Dancis 2018-10-05 15:25:32 -06:00 committed by Ian Storm Taylor
parent 10e8ab4db6
commit 1ff050265b

View File

@ -270,6 +270,12 @@ class Content extends React.Component {
let el
try {
// COMPAT: In Firefox, sometimes the node can be comment which doesn't
// have .closest and it crashes.
if (target.nodeType === 8) {
return false
}
// COMPAT: Text nodes don't have `isContentEditable` property. So, when
// `target` is a text node use its parent node for check.
el = target.nodeType === 3 ? target.parentNode : target