mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-10 07:37:27 +02:00
create a base component
This commit is contained in:
31
js/src/base-component.js
Normal file
31
js/src/base-component.js
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Bootstrap (v5.0.0-alpha3): base-component.js
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
import Data from './dom/data'
|
||||
|
||||
class BaseComponent {
|
||||
constructor(element) {
|
||||
if (!element) {
|
||||
return
|
||||
}
|
||||
|
||||
this._element = element
|
||||
Data.setData(element, this.constructor.DATA_KEY, this)
|
||||
}
|
||||
|
||||
/** Static */
|
||||
|
||||
static getInstance(element) {
|
||||
return Data.getData(element, this.DATA_KEY)
|
||||
}
|
||||
|
||||
static get DATA_KEY() {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export default BaseComponent
|
Reference in New Issue
Block a user