Skip to content

Commit

Permalink
correct global detection
Browse files Browse the repository at this point in the history
  • Loading branch information
hax committed Apr 25, 2016
1 parent 5e97afd commit da039cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@


var spec = require('./spec')
var global = require('./global')
var TypeIsObject = spec.TypeIsObject,
WellKnownSymbol = spec.defineSymbol(this.Symbol).WellKnownSymbol,
WellKnownSymbol = spec.defineSymbol(global.Symbol).WellKnownSymbol,
IsCallable = spec.IsCallable,
IsConstructor = spec.IsConstructor,
Call = spec.Call,
Expand Down
10 changes: 10 additions & 0 deletions src/global.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict'

module.exports = function () {

if (typeof System === 'object' && System && typeof System.global === 'object' && System.global) return System.global
if (typeof global === 'object' && global && global.global === global) return global
if (typeof window === 'object' && window && window.window === window) return window
return new Function('return this')()

}()

0 comments on commit da039cc

Please sign in to comment.