Skip to content

Commit

Permalink
Remove outdated browser workarounds
Browse files Browse the repository at this point in the history
Remove workarounds for bugs in Firefox 22 and Safari 5.
  • Loading branch information
eatyourgreens committed Nov 3, 2023
1 parent 2f7b65f commit 54bee72
Showing 1 changed file with 0 additions and 42 deletions.
42 changes: 0 additions & 42 deletions lib/SugarClient/primus.js
Original file line number Diff line number Diff line change
Expand Up @@ -3782,48 +3782,6 @@ Primus.prototype.decoder = function decoder(data, fn) {
};
Primus.prototype.version = "8.0.8";

if (
'undefined' !== typeof document
&& 'undefined' !== typeof navigator
) {
//
// Hack 2: If you press ESC in FireFox it will close all active connections.
// Normally this makes sense, when your page is still loading. But versions
// before FireFox 22 will close all connections including WebSocket connections
// after page load. One way to prevent this is to do a `preventDefault()` and
// cancel the operation before it bubbles up to the browsers default handler.
// It needs to be added as `keydown` event, if it's added keyup it will not be
// able to prevent the connection from being closed.
//
if (document.addEventListener) {
document.addEventListener('keydown', function keydown(e) {
if (e.keyCode !== 27 || !e.preventDefault) return;

e.preventDefault();
}, false);
}

//
// Hack 3: This is a Mac/Apple bug only, when you're behind a reverse proxy or
// have you network settings set to `automatic proxy discovery` the safari
// browser will crash when the WebSocket constructor is initialised. There is
// no way to detect the usage of these proxies available in JavaScript so we
// need to do some nasty browser sniffing. This only affects Safari versions
// lower then 5.1.4
//
var ua = (navigator.userAgent || '').toLowerCase()
, parsed = ua.match(/.+(?:rv|it|ra|ie)[/: ](\d+)\.(\d+)(?:\.(\d+))?/) || []
, version = +[parsed[1], parsed[2]].join('.');

if (
!~ua.indexOf('chrome')
&& ~ua.indexOf('safari')
&& version < 534.54
) {
Primus.prototype.AVOID_WEBSOCKETS = true;
}
}

//
// Expose the library.
//
Expand Down

0 comments on commit 54bee72

Please sign in to comment.