From 5e731dfbfd9d40da6d963bb3534827de533a4aba Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Mon, 22 Feb 2021 02:21:02 -0500 Subject: [PATCH] caretPosition: Delete unused var in `getPosition()` --- src/static/js/caretPosition.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/static/js/caretPosition.js b/src/static/js/caretPosition.js index dbab99266..1610219de 100644 --- a/src/static/js/caretPosition.js +++ b/src/static/js/caretPosition.js @@ -6,7 +6,7 @@ exports.getPosition = () => { const range = getSelectionRange(); if (!range || $(range.endContainer).closest('body')[0].id !== 'innerdocbody') return null; - let rect, line; + let line; // when we have the caret in an empty line, e.g. a line with only a
, // getBoundingClientRect() returns all dimensions value as 0 @@ -19,19 +19,17 @@ exports.getPosition = () => { // when there's a
or any element that has no height, we can't get // the dimension of the element where the caret is - if (!rect || rect.height === 0) { - const clonedRange = createSelectionRange(range); + const clonedRange = createSelectionRange(range); - // as we can't get the element height, we create a text node to get the dimensions - // on the position - const shadowCaret = $(document.createTextNode('|')); - clonedRange.insertNode(shadowCaret[0]); - clonedRange.selectNode(shadowCaret[0]); + // as we can't get the element height, we create a text node to get the dimensions + // on the position + const shadowCaret = $(document.createTextNode('|')); + clonedRange.insertNode(shadowCaret[0]); + clonedRange.selectNode(shadowCaret[0]); - line = getPositionOfElementOrSelection(clonedRange); - clonedRange.detach(); - shadowCaret.remove(); - } + line = getPositionOfElementOrSelection(clonedRange); + clonedRange.detach(); + shadowCaret.remove(); return line; };