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 9 requires polyfill? #31

Closed
Maxim-Filimonov opened this issue Oct 4, 2015 · 4 comments
Closed

Safari 9 requires polyfill? #31

Maxim-Filimonov opened this issue Oct 4, 2015 · 4 comments

Comments

@Maxim-Filimonov
Copy link

Just noticed that the following warning pops up in Safari 9:
[Warning] webpack-hot-middleware's client requires EventSource to work. You should include a polyfill if you want to support this browser: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events#Tools

According to w3c spec eventsource interface need to have a constructor but it doesn't necessary need to be a function.
It is an object in Safari 9 with following properties

EventSourceConstructor = $1
CLOSED: 2
CONNECTING: 0
OPEN: 1
length: 1
prototype: EventSourcePrototype {URL: undefined, url: undefined, withCredentials: undefined, readyState: undefined, …}
Object Prototype

Is there any reason why not to just check for window.EventSource !== undefined instead of requiring EventSource to be function?

@glenjamin
Copy link
Collaborator

Welp, I learned something new today - the spec says it has to be newable, and apparently Safari makes this work on objects.

I'll accept a PR that makes the check more naive in order to cover this case.

@glenjamin
Copy link
Collaborator

Will be released in 2.4.0

@Maxim-Filimonov
Copy link
Author

@glenjamin Great, thanks! Btw you can probably simplify it even further to window.EventSource === undefined instead of doing typeof

@glenjamin
Copy link
Collaborator

Probably, but for some reason I always feel safer with typeof :)

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

No branches or pull requests

2 participants