Skip to content

Commit 31b88d9

Browse files
einarqn8schloss
authored andcommitted
Bugfix: Add back early return in setOffsets which was removed between 16.4.2 and 16.5.0. Fails in Edge in some scenarios. (facebook#14095)
1 parent 124bac2 commit 31b88d9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/react-dom/src/client/ReactDOMSelection.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@ export function getModernOffsetsFromPoints(
153153
export function setOffsets(node, offsets) {
154154
const doc = node.ownerDocument || document;
155155
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+
156164
const selection = win.getSelection();
157165
const length = node.textContent.length;
158166
let start = Math.min(offsets.start, length);

0 commit comments

Comments
 (0)