Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selection.getRangeAt(). getRangeAt() issue on Safari #11457

Closed
phpbits opened this issue Nov 3, 2018 · 5 comments
Closed

Selection.getRangeAt(). getRangeAt() issue on Safari #11457

phpbits opened this issue Nov 3, 2018 · 5 comments
Labels
Browser Issues Issues or PRs that are related to browser specific problems

Comments

@phpbits
Copy link
Contributor

phpbits commented Nov 3, 2018

@youknowriad I'm suddenly getting error on safari regarding const range = getSelection().getRangeAt( 0 ); . It says:

IndexSizeError: DOM Exception 1: Index or size was negative, or greater than the allowed value.

Seems like safari doesn't fully support it yet : https://developer.mozilla.org/en-US/docs/Web/API/Selection/getRangeAt .

Thanks!

-- copied from my comment here : #4872 . Thanks!

@ocean90 ocean90 added the Browser Issues Issues or PRs that are related to browser specific problems label Nov 3, 2018
@ocean90
Copy link
Member

ocean90 commented Nov 3, 2018

Thanks for the report! Which script is producing the error? I'm asking because #4872 did not add a getSelection().getRangeAt( 0 ) line. Unlike this and this, the one mentioned in the pull request was checking for selection.rangeCount first. But that line actually doesn't exist anymore.

Other examples checking for rangeCount first:

@phpbits
Copy link
Contributor Author

phpbits commented Nov 3, 2018

@ocean90 how about adding the condition on all getSelection().getRangeAt( 0 )? Hoping this const range = selection.rangeCount ? selection.getRangeAt( 0 ) : null; should be added on both files that you've mentioned. Let me know your thoughts. Thanks!

@johngodley
Copy link
Contributor

Is this fixed in #11209?

@phpbits
Copy link
Contributor Author

phpbits commented Nov 6, 2018

@johngodley Thanks! That's the fixes I've added too and it's working fine :) Hoping it'll got merge soon. Thanks again!

@aduth
Copy link
Member

aduth commented May 13, 2019

Closing per confirmation at #11457 (comment) .

Noting there were similar recent issues in Safari, also fixed in #15576 (expected for Gutenberg 5.7 / WordPress 5.2.1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Browser Issues Issues or PRs that are related to browser specific problems
Projects
None yet
Development

No branches or pull requests

4 participants