mirror of
https://github.com/twbs/bootstrap.git
synced 2025-10-02 00:06:46 +02:00
Move get element functionality to a helper (#33327)
Looking around on js components I found out many checks, different expressed but with same purpose. Some of them are trying to parse string to element, others, jQuery element to js simple nodeElement etc With this Pr, I am trying to give a standard way to parse an element So this pr: * Creates `getElement` helper that tries to parse an argument to element or null * Changes `isElement` to make explicit checks and return Boolean * fixes tests deficiencies
This commit is contained in:
@@ -9,6 +9,7 @@ import * as Popper from '@popperjs/core'
|
||||
|
||||
import {
|
||||
defineJQueryPlugin,
|
||||
getElement,
|
||||
getElementFromSelector,
|
||||
isDisabled,
|
||||
isElement,
|
||||
@@ -166,12 +167,7 @@ class Dropdown extends BaseComponent {
|
||||
if (this._config.reference === 'parent') {
|
||||
referenceElement = parent
|
||||
} else if (isElement(this._config.reference)) {
|
||||
referenceElement = this._config.reference
|
||||
|
||||
// Check if it's jQuery element
|
||||
if (typeof this._config.reference.jquery !== 'undefined') {
|
||||
referenceElement = this._config.reference[0]
|
||||
}
|
||||
referenceElement = getElement(this._config.reference)
|
||||
} else if (typeof this._config.reference === 'object') {
|
||||
referenceElement = this._config.reference
|
||||
}
|
||||
|
Reference in New Issue
Block a user