diff --git a/js/src/util.js b/js/src/util.js index 0d434c4c51..c3e23e8174 100644 --- a/js/src/util.js +++ b/js/src/util.js @@ -82,7 +82,11 @@ const Util = { selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '' } - return selector && document.querySelector(selector) ? selector : null + try { + return document.querySelector(selector) ? selector : null + } catch (err) { + return null + } }, getTransitionDurationFromElement(element) { diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js index 782a86eea0..4d7682aaa7 100644 --- a/js/tests/unit/modal.js +++ b/js/tests/unit/modal.js @@ -619,40 +619,37 @@ $(function () { assert.expect(1) var done = assert.async() - try { - var $toggleBtn = $('