mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user