Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksey28 committed Sep 12, 2023
1 parent 0559b91 commit a188426
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/client/core/utils/content-editable.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,15 +285,23 @@ export function getNearestCommonAncestor (node1, node2) {

//selection utils
function getSelectedPositionInParentByOffset (node, offset) {
let currentNode = null;
let currentOffset = null;
const childNodes = nativeMethods.nodeChildNodesGetter.call(node);
const childCount = domUtils.getChildNodesLength(childNodes);
let isSearchForLastChild = offset >= childCount;

// NOTE: we get a child element by its offset index in the parent
if (domUtils.isShadowUIElement(node))
return { node, offset };

let currentNode = childNodes[offset];
let currentOffset = 0;
const childNodes = nativeMethods.nodeChildNodesGetter.call(node);
const childCount = domUtils.getChildNodesLength(childNodes);
let isSearchForLastChild = offset >= childCount;
// NOTE: IE behavior
if (isSearchForLastChild)
currentNode = childNodes[childCount - 1];
else {
currentNode = childNodes[offset];
currentOffset = 0;
}

// NOTE: skip shadowUI elements
if (domUtils.isShadowUIElement(currentNode)) {
Expand Down

0 comments on commit a188426

Please sign in to comment.