Skip to content

Commit

Permalink
Use parent node to find text node parent (#1004)
Browse files Browse the repository at this point in the history
  • Loading branch information
davegw authored and ianstormtaylor committed Aug 17, 2017
1 parent 577b5c7 commit 74d697b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/components/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,8 @@ class Content extends React.Component {
isInEditor = (target) => {
const { element } = this
// COMPAT: Text nodes don't have `isContentEditable` property. So, when
// `target` is a text node use its parent element for check.
// COMPAT: `parentElement` is not defined on text nodes in certain browsers:
// https://developer.mozilla.org/en-US/docs/Web/API/Node/parentElement#Browser_compatibility
const el = (target.nodeType === 3 && target.parentElement) ? target.parentElement : target
// `target` is a text node use its parent node for check.
const el = target.nodeType === 3 ? target.parentNode : target
return (
(el.isContentEditable) &&
(el === element || findClosestNode(el, '[data-slate-editor]') === element)
Expand Down

0 comments on commit 74d697b

Please sign in to comment.