From eab5a9c1e7f735db515689d907b47ba68d7d7230 Mon Sep 17 00:00:00 2001 From: Chris Colvard Date: Wed, 27 Apr 2022 09:39:09 -0400 Subject: [PATCH] Explicitly test that bootstrap and bootstrap.Modal are defined --- app/assets/javascripts/blacklight/blacklight.js | 4 ++-- app/javascript/blacklight/modal.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/blacklight/blacklight.js b/app/assets/javascripts/blacklight/blacklight.js index 665788b426..ca85c669ec 100644 --- a/app/assets/javascripts/blacklight/blacklight.js +++ b/app/assets/javascripts/blacklight/blacklight.js @@ -441,7 +441,7 @@ Blacklight.modal.checkCloseModal = function (event) { }; Blacklight.modal.hide = function (el) { - if (bootstrap.Modal.VERSION >= "5") { + if (typeof bootstrap !== 'undefined' && typeof bootstrap.Modal !== 'undefined' && bootstrap.Modal.VERSION >= "5") { bootstrap.Modal.getOrCreateInstance(el || document.querySelector(Blacklight.modal.modalSelector)).hide(); } else { $(el || Blacklight.modal.modalSelector).modal('hide'); @@ -449,7 +449,7 @@ Blacklight.modal.hide = function (el) { }; Blacklight.modal.show = function (el) { - if (bootstrap.Modal.VERSION >= "5") { + if (typeof bootstrap !== 'undefined' && typeof bootstrap.Modal !== 'undefined' && bootstrap.Modal.VERSION >= "5") { bootstrap.Modal.getOrCreateInstance(el || document.querySelector(Blacklight.modal.modalSelector)).show(); } else { $(el || Blacklight.modal.modalSelector).modal('show'); diff --git a/app/javascript/blacklight/modal.js b/app/javascript/blacklight/modal.js index fa4d94bdb9..d1bf86e338 100644 --- a/app/javascript/blacklight/modal.js +++ b/app/javascript/blacklight/modal.js @@ -206,7 +206,7 @@ Blacklight.modal.checkCloseModal = function(event) { } Blacklight.modal.hide = function(el) { - if (bootstrap && bootstrap.Modal && bootstrap.Modal.VERSION >= "5") { + if (typeof bootstrap !== 'undefined' && typeof bootstrap.Modal !== 'undefined' && bootstrap.Modal.VERSION >= "5") { bootstrap.Modal.getOrCreateInstance(el || document.querySelector(Blacklight.modal.modalSelector)).hide(); } else { $(el || Blacklight.modal.modalSelector).modal('hide'); @@ -214,7 +214,7 @@ Blacklight.modal.hide = function(el) { } Blacklight.modal.show = function(el) { - if (bootstrap && bootstrap.Modal && bootstrap.Modal.VERSION >= "5") { + if (typeof bootstrap !== 'undefined' && typeof bootstrap.Modal !== 'undefined' && bootstrap.Modal.VERSION >= "5") { bootstrap.Modal.getOrCreateInstance(el || document.querySelector(Blacklight.modal.modalSelector)).show(); } else { $(el || Blacklight.modal.modalSelector).modal('show');