Fix the JS error "EventSource is not defined" caused by some non-standard browsers (#20584)
* fall back to periodic poller Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
parent
99fc419855
commit
96440e6ada
3 changed files with 71 additions and 64 deletions
|
@ -70,6 +70,13 @@ class Source {
|
|||
self.addEventListener('connect', (e) => {
|
||||
for (const port of e.ports) {
|
||||
port.addEventListener('message', (event) => {
|
||||
if (!self.EventSource) {
|
||||
// some browsers (like PaleMoon, Firefox<53) don't support EventSource in SharedWorkerGlobalScope.
|
||||
// this event handler needs EventSource when doing "new Source(url)", so just post a message back to the caller,
|
||||
// in case the caller would like to use a fallback method to do its work.
|
||||
port.postMessage({type: 'no-event-source'});
|
||||
return;
|
||||
}
|
||||
if (event.data.type === 'start') {
|
||||
const url = event.data.url;
|
||||
if (sourcesByUrl[url]) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue