aboutsummaryrefslogtreecommitdiff
path: root/js/src/button.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/button.js')
-rw-r--r--js/src/button.js21
1 files changed, 6 insertions, 15 deletions
diff --git a/js/src/button.js b/js/src/button.js
index 4ec48ca08..a145fd845 100644
--- a/js/src/button.js
+++ b/js/src/button.js
@@ -1,12 +1,11 @@
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.0-beta2): button.js
+ * Bootstrap (v5.1.0): button.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import { defineJQueryPlugin } from './util/index'
-import Data from './dom/data'
import EventHandler from './dom/event-handler'
import BaseComponent from './base-component'
@@ -36,8 +35,8 @@ const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
class Button extends BaseComponent {
// Getters
- static get DATA_KEY() {
- return DATA_KEY
+ static get NAME() {
+ return NAME
}
// Public
@@ -51,11 +50,7 @@ class Button extends BaseComponent {
static jQueryInterface(config) {
return this.each(function () {
- let data = Data.getData(this, DATA_KEY)
-
- if (!data) {
- data = new Button(this)
- }
+ const data = Button.getOrCreateInstance(this)
if (config === 'toggle') {
data[config]()
@@ -74,11 +69,7 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, event => {
event.preventDefault()
const button = event.target.closest(SELECTOR_DATA_TOGGLE)
-
- let data = Data.getData(button, DATA_KEY)
- if (!data) {
- data = new Button(button)
- }
+ const data = Button.getOrCreateInstance(button)
data.toggle()
})
@@ -90,6 +81,6 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, event => {
* add .Button to jQuery only if jQuery is present
*/
-defineJQueryPlugin(NAME, Button)
+defineJQueryPlugin(Button)
export default Button