0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-02-07 04:54:24 +01:00
Bootstrap/js/src/base-component.js

45 lines
991 B
JavaScript
Raw Normal View History

2019-09-04 17:58:29 +03:00
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta2): base-component.js
2019-09-04 17:58:29 +03:00
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import Data from './dom/data'
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const VERSION = '5.0.0-beta2'
2019-09-04 17:58:29 +03:00
class BaseComponent {
constructor(element) {
if (!element) {
return
}
this._element = element
Data.setData(element, this.constructor.DATA_KEY, this)
}
2020-11-20 11:13:11 +01:00
dispose() {
Data.removeData(this._element, this.constructor.DATA_KEY)
this._element = null
}
2019-09-04 17:58:29 +03:00
/** Static */
static getInstance(element) {
return Data.getData(element, this.DATA_KEY)
}
static get VERSION() {
return VERSION
}
2019-09-04 17:58:29 +03:00
}
export default BaseComponent