Skip to content

Commit

Permalink
feat(chore): use modern globalThis
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mvorisek authored Dec 5, 2022
1 parent c617b8c commit e589cd1
Show file tree
Hide file tree
Showing 25 changed files with 32 additions and 72 deletions.
5 changes: 2 additions & 3 deletions src/definitions/behaviors/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
function isWindow(obj) {
return obj != null && obj === obj.window;
}

function isFunction(obj) {
return typeof obj === 'function' && typeof obj.nodeType !== 'number';
}

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.api = $.fn.api = function (parameters) {
var
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/behaviors/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.fn.form = function (parameters) {
var
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/behaviors/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.fn.state = function (parameters) {
var
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/behaviors/visibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.fn.visibility = function (parameters) {
var
Expand Down
6 changes: 6 additions & 0 deletions src/definitions/globals/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@
*/

(function ($, window, document, undefined) {
'use strict';

function isFunction(obj) {
return typeof obj === 'function' && typeof obj.nodeType !== 'number';
}

window = (window !== undefined && window.Math == Math)
? window
: globalThis;

$.site = $.fn.site = function (parameters) {
var
time = new Date().getTime(),
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/modules/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.fn.accordion = function (parameters) {
var
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/modules/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.fn.calendar = function (parameters) {
var
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/modules/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.fn.checkbox = function (parameters) {
var
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/modules/dimmer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.fn.dimmer = function (parameters) {
var
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/modules/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.fn.dropdown = function (parameters) {
var
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/modules/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.fn.embed = function (parameters) {
var
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/modules/flyout.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.flyout = $.fn.flyout = function (parameters) {
var
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/modules/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.modal = $.fn.modal = function (parameters) {
var
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/modules/nag.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.fn.nag = function (parameters) {
var
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/modules/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.fn.popup = function (parameters) {
var
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/modules/progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.fn.progress = function (parameters) {
var
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/modules/rating.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.fn.rating = function (parameters) {
var
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/modules/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.fn.search = function (parameters) {
var
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/modules/shape.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.fn.shape = function (parameters) {
var
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/modules/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.fn.sidebar = function (parameters) {
var
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/modules/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.fn.slider = function (parameters) {
var
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/modules/sticky.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.fn.sticky = function (parameters) {
var
Expand Down
5 changes: 2 additions & 3 deletions src/definitions/modules/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
function isWindow(obj) {
return obj != null && obj === obj.window;
}

function isFunction(obj) {
return typeof obj === 'function' && typeof obj.nodeType !== 'number';
}

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.fn.tab = function (parameters) {
var
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/modules/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.toast = $.fn.toast = function (parameters) {
var
Expand Down
4 changes: 1 addition & 3 deletions src/definitions/modules/transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

window = (typeof window != 'undefined' && window.Math == Math)
? window
: (typeof self != 'undefined' && self.Math == Math)
? self
: Function('return this')();
: globalThis;

$.fn.transition = function () {
var
Expand Down

0 comments on commit e589cd1

Please sign in to comment.