Skip to content

Commit

Permalink
Bugfix: Add back early return in setOffsets which was removed between…
Browse files Browse the repository at this point in the history
… 16.4.2 and 16.5.0. Fails in Edge in some scenarios. (#14095)
  • Loading branch information
einarq authored and gaearon committed Nov 5, 2018
1 parent 8eca0ef commit 6c404d8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/react-dom/src/client/ReactDOMSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ export function getModernOffsetsFromPoints(
export function setOffsets(node, offsets) {
const doc = node.ownerDocument || document;
const win = (doc && doc.defaultView) || window;

// Edge fails with "Object expected" in some scenarios.
// (For instance: TinyMCE editor used in a list component that supports pasting to add more,
// fails when pasting 100+ items)
if (!win.getSelection) {
return;
}

const selection = win.getSelection();
const length = node.textContent.length;
let start = Math.min(offsets.start, length);
Expand Down

0 comments on commit 6c404d8

Please sign in to comment.