1
0
Pārlūkot izejas kodu

Use `global` global variable.

As it is not defined in browser, polyfill it there.
Herby Vojčík 6 gadi atpakaļ
vecāks
revīzija
181d8d429f
3 mainītis faili ar 13 papildinājumiem un 4 dzēšanām
  1. 1 0
      internal/index.html
  2. 1 2
      support/helpers.js
  3. 11 2
      support/kernel-checks.js

+ 1 - 0
internal/index.html

@@ -21,6 +21,7 @@
     startLegacy.parentNode.removeChild(startLegacy);
     var startHelios = document.getElementById("starthelios");
     startHelios.parentNode.removeChild(startHelios);
+    var global = typeof global === "undefined" ? window : global || window;
     require(["require", "amber/es2015-polyfills"], function (require) {
         var loadHelpers = new Promise(function (resolve, reject) {
             setTimeout(function () {

+ 1 - 2
support/helpers.js

@@ -35,8 +35,7 @@ define(["amber/boot", "require"], function (boot, require) {
 
     function settingsInLocalStorage () {
         //jshint evil:true
-        var global = new Function('return this')(),
-            storage = 'localStorage' in global && global.localStorage;
+        var storage = 'localStorage' in global && global.localStorage;
 
         if (storage) {
             var fromStorage;

+ 11 - 2
support/kernel-checks.js

@@ -22,11 +22,20 @@ define(function () {
         var p = {};
         return Object.getPrototypeOf(Object.create(p)) === p;
     });
+    // assert(function () {
+    //     return new Function("return this")().Object === Object;
+    // });
+    // assert(function () {
+    //     return Object.create(new Function("return this")()).Object === Object;
+    // });
     assert(function () {
-        return new Function("return this")().Object === Object;
+        return typeof global !== "undefined";
     });
     assert(function () {
-        return Object.create(new Function("return this")()).Object === Object;
+        return global.Object === Object;
+    });
+    assert(function () {
+        return Object.create(global).Object === Object;
     });
     assert(function () {
         return (function () {