diff options
author | Johann-S <johann.servoire@gmail.com> | 2018-09-12 11:08:39 +0300 |
---|---|---|
committer | Johann-S <johann.servoire@gmail.com> | 2018-09-13 23:13:36 +0300 |
commit | a689120fd2af44bfb317f899b42037c46bfcd2fe (patch) | |
tree | d7eb34da370314588d296221a3683e6156046d80 /js/src/util.js | |
parent | 9efed8252249065b7903731d3a2b578df89d2ce0 (diff) |
throw error when folks try to use a bad selector
Diffstat (limited to 'js/src/util.js')
-rw-r--r-- | js/src/util.js | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/js/src/util.js b/js/src/util.js index 653598ae2b..653b14a17f 100644 --- a/js/src/util.js +++ b/js/src/util.js @@ -79,14 +79,11 @@ const Util = (($) => { let selector = element.getAttribute('data-target') if (!selector || selector === '#') { - selector = (element.getAttribute('href') || '').trim() + const hrefAttr = element.getAttribute('href') + selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '' } - try { - return document.querySelector(selector) ? selector : null - } catch (err) { - return null - } + return selector && document.querySelector(selector) ? selector : null }, getTransitionDurationFromElement(element) { |