From 58d3d0a63227366e9d06e1ec16285f64e1dfd006 Mon Sep 17 00:00:00 2001 From: Einar Paul Qvale Date: Mon, 5 Nov 2018 10:53:18 +0100 Subject: [PATCH] Bugfix: Add back early return in setOffsets which was removed between 16.4.2 and 16.5.0. Fails in Edge in some scenarios. --- packages/react-dom/src/client/ReactDOMSelection.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/react-dom/src/client/ReactDOMSelection.js b/packages/react-dom/src/client/ReactDOMSelection.js index 9f247af15b4f5..1f584597514c2 100644 --- a/packages/react-dom/src/client/ReactDOMSelection.js +++ b/packages/react-dom/src/client/ReactDOMSelection.js @@ -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);