js: Remove ancient IE createTextRange API.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2021-06-25 13:56:06 -07:00
committed by Tim Abbott
parent fa81ae3aa4
commit 9518545128
3 changed files with 12 additions and 28 deletions

View File

@@ -11,19 +11,12 @@ export function change_tab_to(tabname) {
export function place_caret_at_end(el) {
el.focus();
if (window.getSelection !== undefined && document.createRange !== undefined) {
const range = document.createRange();
range.selectNodeContents(el);
range.collapse(false);
const sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
} else if (document.body.createTextRange !== undefined) {
const textRange = document.body.createTextRange();
textRange.moveToElementText(el);
textRange.collapse(false);
textRange.select();
}
const range = document.createRange();
range.selectNodeContents(el);
range.collapse(false);
const sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
}
export function blur_active_element() {