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)

This commit is contained in:
einarq
2018-11-05 15:19:50 +00:00
committed by Dan Abramov
parent e1e7236940
commit f0e3979c2b
+8
View File
@@ -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);