diff options
author | Gleb Mazovetskiy <glex.spb@gmail.com> | 2021-02-27 01:01:33 +0300 |
---|---|---|
committer | Gleb Mazovetskiy <glex.spb@gmail.com> | 2021-02-27 01:01:33 +0300 |
commit | db61cec2086ab576efc3e328b4e8a5fd06094bff (patch) | |
tree | 4a64e8a4a4a3673b9b5d7fa0c26c1780876ceff1 /assets | |
parent | 083f8d22a9c4231517ea0e5c9e2500cd14cf6901 (diff) |
JS: Define components in the `bootstrap` namespace
They were previously defined directly on `window` when using
`//=require bootstrap-sprockets`.
Diffstat (limited to 'assets')
-rw-r--r-- | assets/javascripts/bootstrap-global-this-define.js | 6 | ||||
-rw-r--r-- | assets/javascripts/bootstrap-global-this-undefine.js | 2 | ||||
-rw-r--r-- | assets/javascripts/bootstrap-sprockets.js | 2 |
3 files changed, 10 insertions, 0 deletions
diff --git a/assets/javascripts/bootstrap-global-this-define.js b/assets/javascripts/bootstrap-global-this-define.js new file mode 100644 index 0000000..82c26f5 --- /dev/null +++ b/assets/javascripts/bootstrap-global-this-define.js @@ -0,0 +1,6 @@ +// Set a `globalThis` so that bootstrap components are defined on window.bootstrap instead of window. +window['bootstrap'] = { + Popper: window.Popper, + _originalGlobalThis: window['globalThis'] +}; +window['globalThis'] = window['bootstrap']; diff --git a/assets/javascripts/bootstrap-global-this-undefine.js b/assets/javascripts/bootstrap-global-this-undefine.js new file mode 100644 index 0000000..6f96eb1 --- /dev/null +++ b/assets/javascripts/bootstrap-global-this-undefine.js @@ -0,0 +1,2 @@ +window['globalThis'] = window['bootstrap']._originalGlobalThis; +window['bootstrap']._originalGlobalThis = null; diff --git a/assets/javascripts/bootstrap-sprockets.js b/assets/javascripts/bootstrap-sprockets.js index 8b251b1..fab8c2f 100644 --- a/assets/javascripts/bootstrap-sprockets.js +++ b/assets/javascripts/bootstrap-sprockets.js @@ -1,3 +1,4 @@ +//= require ./bootstrap-global-this-define //= require ./bootstrap/dom/data //= require ./bootstrap/base-component //= require ./bootstrap/dom/event-handler @@ -14,3 +15,4 @@ //= require ./bootstrap/scrollspy //= require ./bootstrap/tab //= require ./bootstrap/toast +//= require ./bootstrap-global-this-undefine |