mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-07 22:26:57 +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 Data from './dom/data'
|
||||
import {
|
||||
emulateTransitionEnd,
|
||||
execute,
|
||||
getElement,
|
||||
getTransitionDurationFromElement
|
||||
} from './util/index'
|
||||
import EventHandler from './dom/event-handler'
|
||||
@@ -23,7 +24,7 @@ const VERSION = '5.0.0'
|
||||
|
||||
class BaseComponent {
|
||||
constructor(element) {
|
||||
element = typeof element === 'string' ? document.querySelector(element) : element
|
||||
element = getElement(element)
|
||||
|
||||
if (!element) {
|
||||
return
|
||||
|
Reference in New Issue
Block a user