Bugfix: Add back early return in setOffsets which was removed between 16.4.2 and 16.5.0. Fails in Edge in some scenarios. (#14095)
einarq committed
Nov 5, 2018 at 16:19 UTC
6c404d82aa082a008dba033eb3f0f9c6803b13c4
1 file changed
+8
packages/react-dom/src/client/ReactDOMSelection.js
+8
@@ -153,6 +153,14 @@ export function getModernOffsetsFromPoints(
153
export function setOffsets(node, offsets) {
154
const doc = node.ownerDocument || document;
155
const win = (doc && doc.defaultView) || window;
156
+
157
+ // Edge fails with "Object expected" in some scenarios.
158
+ // (For instance: TinyMCE editor used in a list component that supports pasting to add more,
159
+ // fails when pasting 100+ items)
160
+ if (!win.getSelection) {
161
+ return;
162
+ }
163
+
164
const selection = win.getSelection();
165
const length = node.textContent.length;
166
let start = Math.min(offsets.start, length);