mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
caretPosition: Delete pointless logic in getPosition()
The `line` variable is unconditionally overwritten later, and the function calls do not have side effects, so it is safe to delete this logic.
This commit is contained in:
parent
1dbdaf93d7
commit
91955609af
1 changed files with 1 additions and 10 deletions
|
@ -6,15 +6,6 @@
|
|||
exports.getPosition = () => {
|
||||
const range = getSelectionRange();
|
||||
if (!range || $(range.endContainer).closest('body')[0].id !== 'innerdocbody') return null;
|
||||
let line;
|
||||
|
||||
// when we have the caret in an empty line, e.g. a line with only a <br>,
|
||||
// getBoundingClientRect() returns all dimensions value as 0
|
||||
const selectionIsInTheBeginningOfLine = range.endOffset > 0;
|
||||
if (selectionIsInTheBeginningOfLine) {
|
||||
const clonedRange = createSelectionRange(range);
|
||||
line = getPositionOfElementOrSelection(clonedRange);
|
||||
}
|
||||
|
||||
// when there's a <br> or any element that has no height, we can't get
|
||||
// the dimension of the element where the caret is
|
||||
|
@ -26,7 +17,7 @@ exports.getPosition = () => {
|
|||
clonedRange.insertNode(shadowCaret[0]);
|
||||
clonedRange.selectNode(shadowCaret[0]);
|
||||
|
||||
line = getPositionOfElementOrSelection(clonedRange);
|
||||
const line = getPositionOfElementOrSelection(clonedRange);
|
||||
shadowCaret.remove();
|
||||
return line;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue