Skip to content

Commit e589cd1

Browse files
authored
feat(chore): use modern globalThis
globalThis is quite new feature, but all supported browsers except IE11 should support it - caniuse.com/?search=globalThis I do not consider this a problem, as IE11 is kept supported when window is defined which normally is, only there is no longer a fallback when undefined/shadowed.
1 parent c617b8c commit e589cd1

25 files changed

+32
-72
lines changed

src/definitions/behaviors/api.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@
1414
function isWindow(obj) {
1515
return obj != null && obj === obj.window;
1616
}
17+
1718
function isFunction(obj) {
1819
return typeof obj === 'function' && typeof obj.nodeType !== 'number';
1920
}
2021

2122
window = (typeof window != 'undefined' && window.Math == Math)
2223
? window
23-
: (typeof self != 'undefined' && self.Math == Math)
24-
? self
25-
: Function('return this')();
24+
: globalThis;
2625

2726
$.api = $.fn.api = function (parameters) {
2827
var

src/definitions/behaviors/form.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717

1818
window = (typeof window != 'undefined' && window.Math == Math)
1919
? window
20-
: (typeof self != 'undefined' && self.Math == Math)
21-
? self
22-
: Function('return this')();
20+
: globalThis;
2321

2422
$.fn.form = function (parameters) {
2523
var

src/definitions/behaviors/state.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717

1818
window = (typeof window != 'undefined' && window.Math == Math)
1919
? window
20-
: (typeof self != 'undefined' && self.Math == Math)
21-
? self
22-
: Function('return this')();
20+
: globalThis;
2321

2422
$.fn.state = function (parameters) {
2523
var

src/definitions/behaviors/visibility.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717

1818
window = (typeof window != 'undefined' && window.Math == Math)
1919
? window
20-
: (typeof self != 'undefined' && self.Math == Math)
21-
? self
22-
: Function('return this')();
20+
: globalThis;
2321

2422
$.fn.visibility = function (parameters) {
2523
var

src/definitions/globals/site.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@
99
*/
1010

1111
(function ($, window, document, undefined) {
12+
'use strict';
13+
1214
function isFunction(obj) {
1315
return typeof obj === 'function' && typeof obj.nodeType !== 'number';
1416
}
1517

18+
window = (window !== undefined && window.Math == Math)
19+
? window
20+
: globalThis;
21+
1622
$.site = $.fn.site = function (parameters) {
1723
var
1824
time = new Date().getTime(),

src/definitions/modules/accordion.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717

1818
window = (typeof window != 'undefined' && window.Math == Math)
1919
? window
20-
: (typeof self != 'undefined' && self.Math == Math)
21-
? self
22-
: Function('return this')();
20+
: globalThis;
2321

2422
$.fn.accordion = function (parameters) {
2523
var

src/definitions/modules/calendar.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717

1818
window = (typeof window != 'undefined' && window.Math == Math)
1919
? window
20-
: (typeof self != 'undefined' && self.Math == Math)
21-
? self
22-
: Function('return this')();
20+
: globalThis;
2321

2422
$.fn.calendar = function (parameters) {
2523
var

src/definitions/modules/checkbox.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717

1818
window = (typeof window != 'undefined' && window.Math == Math)
1919
? window
20-
: (typeof self != 'undefined' && self.Math == Math)
21-
? self
22-
: Function('return this')();
20+
: globalThis;
2321

2422
$.fn.checkbox = function (parameters) {
2523
var

src/definitions/modules/dimmer.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717

1818
window = (typeof window != 'undefined' && window.Math == Math)
1919
? window
20-
: (typeof self != 'undefined' && self.Math == Math)
21-
? self
22-
: Function('return this')();
20+
: globalThis;
2321

2422
$.fn.dimmer = function (parameters) {
2523
var

src/definitions/modules/dropdown.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717

1818
window = (typeof window != 'undefined' && window.Math == Math)
1919
? window
20-
: (typeof self != 'undefined' && self.Math == Math)
21-
? self
22-
: Function('return this')();
20+
: globalThis;
2321

2422
$.fn.dropdown = function (parameters) {
2523
var

0 commit comments

Comments
 (0)