Skip to content
Snippets Groups Projects
Commit c84584b6 authored by Yadd's avatar Yadd
Browse files

Fix deprecation warning about "root"

Closes: #935845
parent 679bd40d
No related branches found
No related tags found
No related merge requests found
support-globalThis.diff
Description: Add support for globalThis when detecting global object
Inspired from https://github.com/lodash/lodash/pull/4347/files
Author: Xavier Guimard <yadd@debian.org>
Bug-Debian: https://bugs.debian.org/935845
Forwarded: not-needed
Last-Update: 2020-01-30
--- a/dist/lodash.core.js
+++ b/dist/lodash.core.js
@@ -64,11 +64,14 @@
/** Detect free variable `global` from Node.js. */
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
+ /** Detect free variable `globalThis` */
+ const freeGlobalThis = typeof globalThis == 'object' && globalThis !== null && globalThis.Object == Object && globalThis;
+
/** Detect free variable `self`. */
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
/** Used as a reference to the global object. */
- var root = freeGlobal || freeSelf || Function('return this')();
+ var root = freeGlobalThis || freeGlobal || freeSelf || Function('return this')();
/** Detect free variable `exports`. */
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
--- a/dist/lodash.js
+++ b/dist/lodash.js
@@ -418,8 +418,11 @@
/** Detect free variable `self`. */
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
+ /** Detect free variable `globalThis` */
+ const freeGlobalThis = typeof globalThis == 'object' && globalThis !== null && globalThis.Object == Object && globalThis;
+
/** Used as a reference to the global object. */
- var root = freeGlobal || freeSelf || Function('return this')();
+ var root = freeGlobalThis || freeGlobal || freeSelf || Function('return this')();
/** Detect free variable `exports`. */
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
--- a/lodash-cli/bin/lodash
+++ b/lodash-cli/bin/lodash
@@ -727,9 +727,11 @@
'',
" var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;",
'',
+ " var freeGlobalThis = typeof globalThis == 'object' && globalThis !== null && globalThis.Object == Object && globalThis;",
+ '',
" var freeSelf = typeof self == 'object' && self && self.Object === Object && self;",
'',
- " var root = freeGlobal || freeSelf || Function('return this')();",
+ " var root = freeGlobalThis || freeGlobal || freeSelf || Function('return this')();",
'',
" var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;",
'',
--- a/lodash.js
+++ b/lodash.js
@@ -415,11 +415,14 @@
/** Detect free variable `global` from Node.js. */
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
+ /** Detect free variable `globalThis` */
+ const freeGlobalThis = typeof globalThis == 'object' && globalThis !== null && globalThis.Object == Object && globalThis;
+
/** Detect free variable `self`. */
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
/** Used as a reference to the global object. */
- var root = freeGlobal || freeSelf || Function('return this')();
+ var root = freeGlobalThis || freeGlobal || freeSelf || Function('return this')();
/** Detect free variable `exports`. */
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment