Skip to content

Conversation

parport0
Copy link

Apparently on WebKit (including ish's webview), getSelection() can return an object with no ranges (rangeCount == 0).

In those cases, calling getRangeAt(0) causes an error to be thrown: "IndexSizeError: The index is not in the allowed range"

This error was appearing in the JS console when tapping/clicking randomly. Checking rangeCount here fixes the error.

See also:
https://stackoverflow.com/questions/22935320/uncaught-indexsizeerror-failed-to-execute-getrangeat-on-selection-0-is-not

Apparently on WebKit (including ish's webview), getSelection()
can return an object with no ranges (rangeCount == 0).

In those cases, calling getRangeAt(0) causes an error to be thrown:
"IndexSizeError: The index is not in the allowed range"

This error was appearing in the JS console when tapping/clicking randomly.
Checking rangeCount here fixes the error.

See also:
https://stackoverflow.com/questions/22935320/uncaught-indexsizeerror-failed-to-execute-getrangeat-on-selection-0-is-not

Signed-off-by: Elvira Khabirova <lineprinter0@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant