diff --git a/externs/closure-compiler.js b/externs/closure-compiler.js index 7894661c23..6fee440810 100644 --- a/externs/closure-compiler.js +++ b/externs/closure-compiler.js @@ -15,3 +15,5 @@ * @see http://www.w3.org/TR/pointerevents/#the-touch-action-css-property */ CSSProperties.prototype.touchAction; + +var global; diff --git a/src/ol/ol.js b/src/ol/ol.js index 211d0198ff..85eef506d2 100644 --- a/src/ol/ol.js +++ b/src/ol/ol.js @@ -275,4 +275,13 @@ ol.inherits = function(childCtor, parentCtor) { ol.nullFunction = function() {}; -ol.global = Function('return this')(); +/** + * @see https://github.com/tc39/proposal-global + */ +if (typeof window !== 'undefined') { + ol.global = window; +} else if (typeof global !== 'undefined') { + ol.global = global; +} else if (typeof self !== 'undefined') { + ol.global = self; +}