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

Safari incompatibility with api.Document.selectionchange_event #25743

Open
MurrayIII opened this issue Jan 22, 2025 · 4 comments
Open

Safari incompatibility with api.Document.selectionchange_event #25743

MurrayIII opened this issue Jan 22, 2025 · 4 comments
Labels
data:api Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API

Comments

@MurrayIII
Copy link

What type of issue is this?

Browser bug (a bug with a feature that may impact site compatibility)

What information was incorrect, unhelpful, or incomplete?

Calling setBaseAndExtent() doesn't fire a selection-change event in Safari

What browsers does this problem apply to, if applicable?

Safari

What did you expect to see?

Expected document.onselectionchange() to be called. It is called in Chrome, Edge, Firefox after setBaseAndExtent() is called.

Did you test this? If so, how?

Commit 334f4bdf of https://github.com/MurrayIII/UnicodeMathML has the if statement that fixes the problem in Safari. Basically when navigating a math expression in the output window using right arrows (run the playground demo), some speech was missing in Safari. Calling document.onselectionchange() explicitly after calling setBaseAndExtent() fixes the problem in Safari.

Can you link to any release notes, bugs, pull requests, or MDN pages related to this?

No response

Do you have anything more you want to share?

No response

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/Document/selectionchange_event

MDN metadata

MDN page report details
  • Query: api.Document.selectionchange_event
  • Report started: 2025-01-22T15:21:17.882Z
@github-actions github-actions bot added the data:api Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API label Jan 22, 2025
@caugner
Copy link
Contributor

caugner commented Jan 23, 2025

Related:

@MurrayIII Can you please provide a minimal example to reproduce the issue in Safari?

@MurrayIII
Copy link
Author

I tried the simple codepen but it works correctly both on my PC running Edge and on my mac running Safari. I'll add more context to the codepen to find when the incompatibility occurs.

@MurrayIII
Copy link
Author

MurrayIII commented Jan 25, 2025

The codepen repros the problem. In Edge, typing characters shows

Image

In Safari, typing characters shows

Image

@MurrayIII
Copy link
Author

I worked around the problem by adding a setTimeout() with a time-out function that calls document.onselectionchange() if document.onselectionchange() hasn't been called by 100 msec after the setBaseAndExtent() call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:api Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API
Projects
None yet
Development

No branches or pull requests

2 participants