Skip to content

Commit

Permalink
Fix caretRangeFromPoint for Firefox (#6598)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed May 5, 2018
1 parent c37a222 commit fb13235
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions utils/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ function caretRangeFromPoint( doc, x, y ) {
}

const point = doc.caretPositionFromPoint( x, y );

// If x or y are negative, outside viewport, or there is no text entry node.
// https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint
if ( ! point ) {
return null;
}

const range = doc.createRange();

range.setStart( point.offsetNode, point.offset );
Expand Down

0 comments on commit fb13235

Please sign in to comment.