Skip to content

Commit

Permalink
Add global object as another fallback.
Browse files Browse the repository at this point in the history
In some JavaScript runtimes like NativeScript the `window` or `self` objects are not present, but the `global` is.

NativeScript is using Karma as it its unit test runner and thus relies on socket.io for communication. The socket.io client file is served by Karma and loaded in NativeScript. Up until version 1.4.0 this problem was not visible because the root object was not accessed. However this is not the case anymore with latest json3 changes: https://github.com/NativeScript/socket.io-client/blob/master/socket.io.js#L5220
  • Loading branch information
ligaz committed Jan 7, 2016
1 parent 9c44eaa commit cde911c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion support/browserify.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ function build(fn){

function glob(){
return 'typeof self !== "undefined" ? self : '
+ 'typeof window !== "undefined" ? window : {}';
+ 'typeof window !== "undefined" ? window : '
+ 'typeof global !== "undefined" ? global : {}';
}

0 comments on commit cde911c

Please sign in to comment.