happy-dom
Advanced tools
Comparing version 0.2.11 to 0.2.12
@@ -42,3 +42,3 @@ /// <reference types="node" /> | ||
/** | ||
* Provides a GLOBAL fetch() method that provides an easy, logical way to fetch resources asynchronously across the network. | ||
* Provides a global fetch() method that provides an easy, logical way to fetch resources asynchronously across the network. | ||
* | ||
@@ -45,0 +45,0 @@ * @param {string} url URL to resource. |
@@ -58,3 +58,2 @@ "use strict"; | ||
var FETCH_RESPONSE_TYPE_METHODS = ['blob', 'json', 'formData', 'text']; | ||
var GLOBAL = global || window; | ||
/** | ||
@@ -85,3 +84,3 @@ * Handles the Window. | ||
this.startAsyncTask(); | ||
return GLOBAL.setTimeout(function () { | ||
return global.setTimeout(function () { | ||
callback(); | ||
@@ -97,3 +96,3 @@ _this.endAsyncTask(); | ||
AsyncWindow.prototype.clearTimeout = function (id) { | ||
GLOBAL.clearTimeout(id); | ||
global.clearTimeout(id); | ||
this.endAsyncTask(); | ||
@@ -110,3 +109,3 @@ }; | ||
this.startAsyncTask(); | ||
return GLOBAL.setInterval(callback, delay); | ||
return global.setInterval(callback, delay); | ||
}; | ||
@@ -119,7 +118,7 @@ /** | ||
AsyncWindow.prototype.clearInterval = function (id) { | ||
GLOBAL.clearInterval(id); | ||
global.clearInterval(id); | ||
this.endAsyncTask(); | ||
}; | ||
/** | ||
* Provides a GLOBAL fetch() method that provides an easy, logical way to fetch resources asynchronously across the network. | ||
* Provides a global fetch() method that provides an easy, logical way to fetch resources asynchronously across the network. | ||
* | ||
@@ -183,4 +182,4 @@ * @param {string} url URL to resource. | ||
_this.asyncPromises.push({ resolve: resolve, reject: reject }); | ||
GLOBAL.clearTimeout(_this.asyncTimeout); | ||
_this.asyncTimeout = GLOBAL.setTimeout(function () { return _this.endAsyncTask(); }, 0); | ||
global.clearTimeout(_this.asyncTimeout); | ||
_this.asyncTimeout = global.setTimeout(function () { return _this.endAsyncTask(); }, 0); | ||
})]; | ||
@@ -199,3 +198,3 @@ }); | ||
this.asyncPromises = []; | ||
GLOBAL.clearTimeout(this.asyncTimeout); | ||
global.clearTimeout(this.asyncTimeout); | ||
}; | ||
@@ -202,0 +201,0 @@ /** |
@@ -96,4 +96,4 @@ "use strict"; | ||
var window = new AsyncWindow_1.default(); | ||
var global = Object.assign({}, window, { window: window }); | ||
return vm_1.default.createContext(global); | ||
var sandbox = Object.assign({}, window, { window: window, global: global }); | ||
return vm_1.default.createContext(sandbox); | ||
}; | ||
@@ -100,0 +100,0 @@ return VMContext; |
@@ -39,3 +39,2 @@ "use strict"; | ||
var ShadowRootRenderOptions_1 = __importDefault(require("./shadow-root/ShadowRootRenderOptions")); | ||
var GLOBAL = global || window; | ||
/** | ||
@@ -70,12 +69,12 @@ * Handles the Window. | ||
_this.Window = Window; | ||
_this.Array = typeof GLOBAL !== undefined ? GLOBAL.Array : null; | ||
_this.Object = typeof GLOBAL !== undefined ? GLOBAL.Object : null; | ||
_this.Number = typeof GLOBAL !== undefined ? GLOBAL.Number : null; | ||
_this.Symbol = typeof GLOBAL !== undefined ? GLOBAL.Symbol : null; | ||
_this.Function = typeof GLOBAL !== undefined ? GLOBAL.Function : null; | ||
_this.RegExp = typeof GLOBAL !== undefined ? GLOBAL.RegExp : null; | ||
_this.Date = typeof GLOBAL !== undefined ? GLOBAL.Date : null; | ||
_this.JSON = typeof GLOBAL !== undefined ? GLOBAL.JSON : null; | ||
_this.Promise = typeof GLOBAL !== undefined ? GLOBAL.Promise : null; | ||
_this.Error = typeof GLOBAL !== undefined ? GLOBAL.Error : null; | ||
_this.Array = typeof global !== undefined ? global.Array : null; | ||
_this.Object = typeof global !== undefined ? global.Object : null; | ||
_this.Number = typeof global !== undefined ? global.Number : null; | ||
_this.Symbol = typeof global !== undefined ? global.Symbol : null; | ||
_this.Function = typeof global !== undefined ? global.Function : null; | ||
_this.RegExp = typeof global !== undefined ? global.RegExp : null; | ||
_this.Date = typeof global !== undefined ? global.Date : null; | ||
_this.JSON = typeof global !== undefined ? global.JSON : null; | ||
_this.Promise = typeof global !== undefined ? global.Promise : null; | ||
_this.Error = typeof global !== undefined ? global.Error : null; | ||
_this.customElements = new CustomElementRegistry_1.default(); | ||
@@ -85,3 +84,3 @@ _this.location = new Location_1.default(); | ||
_this.self = _this; | ||
_this.console = typeof GLOBAL !== undefined ? GLOBAL.console : null; | ||
_this.console = typeof global !== undefined ? global.console : null; | ||
// Custom Properties (not part of HTML standard) | ||
@@ -88,0 +87,0 @@ _this.shadowRootRenderOptions = new ShadowRootRenderOptions_1.default(); |
{ | ||
"name": "happy-dom", | ||
"version": "0.2.11", | ||
"version": "0.2.12", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/capricorn86/happy-dom#readme", |
@@ -5,3 +5,2 @@ import NodeFetch from 'node-fetch'; | ||
const FETCH_RESPONSE_TYPE_METHODS = ['blob', 'json', 'formData', 'text']; | ||
const GLOBAL = global || window; | ||
@@ -28,3 +27,3 @@ /** | ||
this.startAsyncTask(); | ||
return GLOBAL.setTimeout(() => { | ||
return global.setTimeout(() => { | ||
callback(); | ||
@@ -41,3 +40,3 @@ this.endAsyncTask(); | ||
public clearTimeout(id: NodeJS.Timeout): void { | ||
GLOBAL.clearTimeout(id); | ||
global.clearTimeout(id); | ||
this.endAsyncTask(); | ||
@@ -55,3 +54,3 @@ } | ||
this.startAsyncTask(); | ||
return GLOBAL.setInterval(callback, delay); | ||
return global.setInterval(callback, delay); | ||
} | ||
@@ -65,3 +64,3 @@ | ||
public clearInterval(id: NodeJS.Timeout): void { | ||
GLOBAL.clearInterval(id); | ||
global.clearInterval(id); | ||
this.endAsyncTask(); | ||
@@ -71,3 +70,3 @@ } | ||
/** | ||
* Provides a GLOBAL fetch() method that provides an easy, logical way to fetch resources asynchronously across the network. | ||
* Provides a global fetch() method that provides an easy, logical way to fetch resources asynchronously across the network. | ||
* | ||
@@ -123,4 +122,4 @@ * @param {string} url URL to resource. | ||
this.asyncPromises.push({ resolve, reject }); | ||
GLOBAL.clearTimeout(this.asyncTimeout); | ||
this.asyncTimeout = GLOBAL.setTimeout(() => this.endAsyncTask(), 0); | ||
global.clearTimeout(this.asyncTimeout); | ||
this.asyncTimeout = global.setTimeout(() => this.endAsyncTask(), 0); | ||
}); | ||
@@ -138,3 +137,3 @@ } | ||
this.asyncPromises = []; | ||
GLOBAL.clearTimeout(this.asyncTimeout); | ||
global.clearTimeout(this.asyncTimeout); | ||
} | ||
@@ -141,0 +140,0 @@ |
@@ -62,5 +62,5 @@ import VM from 'vm'; | ||
const window = new AsyncWindow(); | ||
const global = Object.assign({}, window, { window }); | ||
return VM.createContext(global); | ||
const sandbox = Object.assign({}, window, { window, global }); | ||
return VM.createContext(sandbox); | ||
} | ||
} |
@@ -22,4 +22,2 @@ import CustomElementRegistry from './html-element/CustomElementRegistry'; | ||
const GLOBAL = global || window; | ||
/** | ||
@@ -49,12 +47,12 @@ * Handles the Window. | ||
public Array = typeof GLOBAL !== undefined ? GLOBAL.Array : null; | ||
public Object = typeof GLOBAL !== undefined ? GLOBAL.Object : null; | ||
public Number = typeof GLOBAL !== undefined ? GLOBAL.Number : null; | ||
public Symbol = typeof GLOBAL !== undefined ? GLOBAL.Symbol : null; | ||
public Function = typeof GLOBAL !== undefined ? GLOBAL.Function : null; | ||
public RegExp = typeof GLOBAL !== undefined ? GLOBAL.RegExp : null; | ||
public Date = typeof GLOBAL !== undefined ? GLOBAL.Date : null; | ||
public JSON = typeof GLOBAL !== undefined ? GLOBAL.JSON : null; | ||
public Promise = typeof GLOBAL !== undefined ? GLOBAL.Promise : null; | ||
public Error = typeof GLOBAL !== undefined ? GLOBAL.Error : null; | ||
public Array = typeof global !== undefined ? global.Array : null; | ||
public Object = typeof global !== undefined ? global.Object : null; | ||
public Number = typeof global !== undefined ? global.Number : null; | ||
public Symbol = typeof global !== undefined ? global.Symbol : null; | ||
public Function = typeof global !== undefined ? global.Function : null; | ||
public RegExp = typeof global !== undefined ? global.RegExp : null; | ||
public Date = typeof global !== undefined ? global.Date : null; | ||
public JSON = typeof global !== undefined ? global.JSON : null; | ||
public Promise = typeof global !== undefined ? global.Promise : null; | ||
public Error = typeof global !== undefined ? global.Error : null; | ||
@@ -67,3 +65,3 @@ // Public Properties | ||
public self = this; | ||
public console = typeof GLOBAL !== undefined ? GLOBAL.console : null; | ||
public console = typeof global !== undefined ? global.console : null; | ||
@@ -70,0 +68,0 @@ // Custom Properties (not part of HTML standard) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
530591
13476