Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.

Compat issue: document.addEventListener / window.addEventListener('visibilitychange') #68

Closed
jakub-g opened this issue Nov 10, 2020 · 4 comments

Comments

@jakub-g
Copy link

jakub-g commented Nov 10, 2020

I just found out today this compatibility issue:

// works in Chrome, Firefox, Safari
document.addEventListener("visibilitychange", onVisChange);

// works in Chrome, Firefox but NOT in Safari; in Safari it's a no-op
window.addEventListener("visibilitychange", onVisChange);

The spec only talks about Document, I'm wondering if spec should explicitly state that this should be supported on window for better portability?

@cdumez
Copy link

cdumez commented Nov 10, 2020

What version of Safari are you testing? I thought we fixed that not too long ago.

@jakub-g
Copy link
Author

jakub-g commented Nov 10, 2020

This was in 12.1 / 13.1, I don't have 14.0 (only can test on BrowserStack)

@cdumez
Copy link

cdumez commented Nov 10, 2020

I just tested and it is working as intended in Safari 14.0. As I said, we fixed this fairly recently. The event was not marked as bubbling in WebKit: http://trac.webkit.org/r260483.

Can be closed? The specification says "Fire a simple event named visibilitychange that bubbles". The "that bubbles" part is what makes the event get dispatched on the Window.

@jakub-g
Copy link
Author

jakub-g commented Nov 10, 2020

Awesome. Thx for quick reply and verification 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants