File tree Expand file tree Collapse file tree 6 files changed +18
-14
lines changed Expand file tree Collapse file tree 6 files changed +18
-14
lines changed Original file line number Diff line number Diff line change
1
+ module . exports = ( function ( ) {
2
+ if ( typeof self !== 'undefined' ) {
3
+ return self ;
4
+ } else if ( typeof window !== 'undefined' ) {
5
+ return window ;
6
+ } else {
7
+ return Function ( 'return this' ) ( ) ; // eslint-disable-line no-new-func
8
+ }
9
+ } ) ( ) ;
Original file line number Diff line number Diff line change
1
+ module . exports = global ;
Original file line number Diff line number Diff line change 4
4
5
5
var Polling = require ( './polling' ) ;
6
6
var inherit = require ( 'component-inherit' ) ;
7
+ var globalThis = require ( '../globalThis' ) ;
7
8
8
9
/**
9
10
* Module exports.
@@ -30,15 +31,6 @@ var callbacks;
30
31
31
32
function empty ( ) { }
32
33
33
- /**
34
- * Until https://github.com/tc39/proposal-global is shipped.
35
- */
36
- function glob ( ) {
37
- return typeof self !== 'undefined' ? self
38
- : typeof window !== 'undefined' ? window
39
- : typeof global !== 'undefined' ? global : { } ;
40
- }
41
-
42
34
/**
43
35
* JSONP Polling constructor.
44
36
*
@@ -55,8 +47,7 @@ function JSONPPolling (opts) {
55
47
// we do this here (lazily) to avoid unneeded global pollution
56
48
if ( ! callbacks ) {
57
49
// we need to consider multiple engines in the same page
58
- var global = glob ( ) ;
59
- callbacks = global . ___eio = ( global . ___eio || [ ] ) ;
50
+ callbacks = globalThis . ___eio = ( globalThis . ___eio || [ ] ) ;
60
51
}
61
52
62
53
// callback identifier
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ var Polling = require('./polling');
9
9
var Emitter = require ( 'component-emitter' ) ;
10
10
var inherit = require ( 'component-inherit' ) ;
11
11
var debug = require ( 'debug' ) ( 'engine.io-client:polling-xhr' ) ;
12
+ var globalThis = require ( '../globalThis' ) ;
12
13
13
14
/**
14
15
* Module exports.
@@ -403,7 +404,7 @@ if (typeof document !== 'undefined') {
403
404
if ( typeof attachEvent === 'function' ) {
404
405
attachEvent ( 'onunload' , unloadHandler ) ;
405
406
} else if ( typeof addEventListener === 'function' ) {
406
- var terminationEvent = 'onpagehide' in self ? 'pagehide' : 'unload' ;
407
+ var terminationEvent = 'onpagehide' in globalThis ? 'pagehide' : 'unload' ;
407
408
addEventListener ( terminationEvent , unloadHandler , false ) ;
408
409
}
409
410
}
Original file line number Diff line number Diff line change 1
1
// browser shim for xmlhttprequest module
2
2
3
3
var hasCORS = require ( 'has-cors' ) ;
4
+ var globalThis = require ( './globalThis' ) ;
4
5
5
6
module . exports = function ( opts ) {
6
7
var xdomain = opts . xdomain ;
@@ -31,7 +32,7 @@ module.exports = function (opts) {
31
32
32
33
if ( ! xdomain ) {
33
34
try {
34
- return new self [ [ 'Active' ] . concat ( 'Object' ) . join ( 'X' ) ] ( 'Microsoft.XMLHTTP' ) ;
35
+ return new globalThis [ [ 'Active' ] . concat ( 'Object' ) . join ( 'X' ) ] ( 'Microsoft.XMLHTTP' ) ;
35
36
} catch ( e ) { }
36
37
}
37
38
} ;
Original file line number Diff line number Diff line change 69
69
},
70
70
"browser" : {
71
71
"ws" : false ,
72
- "xmlhttprequest-ssl" : " ./lib/xmlhttprequest.js"
72
+ "xmlhttprequest-ssl" : " ./lib/xmlhttprequest.js" ,
73
+ "./lib/globalThis.js" : " ./lib/globalThis.browser.js"
73
74
},
74
75
"repository" : {
75
76
"type" : " git" ,
You can’t perform that action at this time.
0 commit comments