From cde911c10b5c8a2999b1c4a035a4b844c762fb72 Mon Sep 17 00:00:00 2001 From: Stefan Dobrev Date: Thu, 7 Jan 2016 18:47:40 +0200 Subject: [PATCH] Add global object as another fallback. 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 --- support/browserify.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/support/browserify.js b/support/browserify.js index f420df048..e75c0925e 100644 --- a/support/browserify.js +++ b/support/browserify.js @@ -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 : {}'; }