diff options
author | Johann-S <johann.servoire@gmail.com> | 2018-06-01 15:44:21 +0300 |
---|---|---|
committer | Johann-S <johann.servoire@gmail.com> | 2018-06-03 12:40:08 +0300 |
commit | a79b8aa16ab5fa5c71a91425d8464f0bdcd3fe37 (patch) | |
tree | 201e8438a9df0d1e951bee801808a396fd3fc098 /js/src/dropdown.js | |
parent | ffd31f9b8c8b3a34df888fd66218ee74f1fcaf28 (diff) |
refactor(plugins): query elements without jquery
Diffstat (limited to 'js/src/dropdown.js')
-rw-r--r-- | js/src/dropdown.js | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/js/src/dropdown.js b/js/src/dropdown.js index bef8da1a0c..5494fdb64a 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -242,13 +242,15 @@ const Dropdown = (($) => { _getMenuElement() { if (!this._menu) { const parent = Dropdown._getParentFromElement(this._element) - this._menu = $(parent).find(Selector.MENU)[0] + if (parent) { + this._menu = parent.querySelector(Selector.MENU) + } } return this._menu } _getPlacement() { - const $parentDropdown = $(this._element).parent() + const $parentDropdown = $(this._element.parentNode) let placement = AttachmentMap.BOTTOM // Handle dropup @@ -284,6 +286,7 @@ const Dropdown = (($) => { } else { offsetConf.offset = this._config.offset } + const popperConfig = { placement: this._getPlacement(), modifiers: { @@ -382,7 +385,7 @@ const Dropdown = (($) => { const selector = Util.getSelectorFromElement(element) if (selector) { - parent = $(selector)[0] + parent = document.querySelector(selector) } return parent || element.parentNode @@ -417,7 +420,7 @@ const Dropdown = (($) => { if (!isActive && (event.which !== ESCAPE_KEYCODE || event.which !== SPACE_KEYCODE) || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) { if (event.which === ESCAPE_KEYCODE) { - const toggle = $(parent).find(Selector.DATA_TOGGLE)[0] + const toggle = parent.querySelector(Selector.DATA_TOGGLE) $(toggle).trigger('focus') } @@ -425,7 +428,7 @@ const Dropdown = (($) => { return } - const items = $(parent).find(Selector.VISIBLE_ITEMS).get() + const items = [].slice.call(parent.querySelectorAll(Selector.VISIBLE_ITEMS)) if (items.length === 0) { return |