diff options
author | Mark Otto <markdotto@gmail.com> | 2018-08-19 06:22:08 +0300 |
---|---|---|
committer | Mark Otto <markdotto@gmail.com> | 2018-08-19 06:22:08 +0300 |
commit | c0fd91788ee16ef013fe7201c069cfcfef7d0af9 (patch) | |
tree | 9f2992512c0015338dd804131cbcdba348b4535b /js/dist/util.js | |
parent | ab7ce480f254d70dba1a47a955897d0c29e660bf (diff) |
dist
Diffstat (limited to 'js/dist/util.js')
-rw-r--r-- | js/dist/util.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/js/dist/util.js b/js/dist/util.js index 2468212e2f..9cd6744d2b 100644 --- a/js/dist/util.js +++ b/js/dist/util.js @@ -79,13 +79,21 @@ }, getSelectorFromElement: function getSelectorFromElement(element) { var selector = element.getAttribute('data-target'); + var method = 'querySelector'; if (!selector || selector === '#') { - selector = element.getAttribute('href') || ''; + selector = (element.getAttribute('href') || '').trim(); + } + + var validSelector = selector; + + if (selector.charAt(0) === '#' && selector.indexOf(',') === -1) { + selector = selector.substr(1); + method = 'getElementById'; } try { - return document.querySelector(selector) ? selector : null; + return document[method](selector) ? validSelector : null; } catch (err) { return null; } |