@twohundrediq

Как исправить Uncaught DOMException: Failed to execute 'getRangeAt' on 'Selection': 0 is not a valid index?

Как исправить ошибку?
Uncaught DOMException: Failed to execute 'getRangeAt' on 'Selection': 0 is not a valid index.
    at Content.isSelection (chrome-extension://hiidjliailpkjeigakikbfedlfijngih/js/content.js:464:53)
    at Content.handleSelection (chrome-extension://hiidjliailpkjeigakikbfedlfijngih/js/content.js:446:19)


Код в котором возникает ошибка:
445:   handleSelection(ev) {
446:       if (!this.isSelection()) return;
447:       if(this.isSelectedTextForbidden(ev.target.tagName)) return;
448:
449:     if (this.storage.icon_trans === 'icon_trans_false') {
450:       return;
451:     }
452:      this.showTranslateButton();
       }


462:    isSelection() {
463:      this.selectedFullObject = window.getSelection();
464:      const objectRange = this.selectedFullObject.getRangeAt(0);
465:      this.selectBounding = objectRange.getBoundingClientRect();
466:     return this.selectedFullObject.toString().trim() ?  true : false;
467:    }
  • Вопрос задан
  • 1207 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы