diff options
author | XhmikosR <xhmikosr@gmail.com> | 2020-03-31 21:27:35 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-31 21:27:35 +0300 |
commit | f7ed579d91d92aff3bee8358d3de3a5a35246b3d (patch) | |
tree | 889749c6596e2735377cb004a5b510f46fa003b6 /js/src/alert.js | |
parent | 0225c1173b1de2c6d2416df34d9dd5a36554a150 (diff) |
Switch to string constants. (#30490)
This allows the minifier to mangle the constants. It also allows the linter to find unused strings properly.
While at it, remove a few unused properties.
File Before After Diff
--------------------------------------------------------
bootstrap.bundle.min.js 22.09 kB 21.13 kB -0.96 kB (-4.35 %)
bootstrap.min.js 15.4 kB 14.46 kB -0.94 kB (-3.86 %)
Diffstat (limited to 'js/src/alert.js')
-rw-r--r-- | js/src/alert.js | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/js/src/alert.js b/js/src/alert.js index 57ab676f9d..6d961670ff 100644 --- a/js/src/alert.js +++ b/js/src/alert.js @@ -21,21 +21,15 @@ const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' const JQUERY_NO_CONFLICT = $.fn[NAME] -const Selector = { - DISMISS : '[data-dismiss="alert"]' -} +const SELECTOR_DISMISS = '[data-dismiss="alert"]' -const Event = { - CLOSE : `close${EVENT_KEY}`, - CLOSED : `closed${EVENT_KEY}`, - CLICK_DATA_API : `click${EVENT_KEY}${DATA_API_KEY}` -} +const EVENT_CLOSE = `close${EVENT_KEY}` +const EVENT_CLOSED = `closed${EVENT_KEY}` +const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}` -const ClassName = { - ALERT : 'alert', - FADE : 'fade', - SHOW : 'show' -} +const CLASS_NAME_ALERT = 'alert' +const CLASS_NAME_FADE = 'fade' +const CLASS_NAME_SHOW = 'show' /** * ------------------------------------------------------------------------ @@ -87,23 +81,23 @@ class Alert { } if (!parent) { - parent = $(element).closest(`.${ClassName.ALERT}`)[0] + parent = $(element).closest(`.${CLASS_NAME_ALERT}`)[0] } return parent } _triggerCloseEvent(element) { - const closeEvent = $.Event(Event.CLOSE) + const closeEvent = $.Event(EVENT_CLOSE) $(element).trigger(closeEvent) return closeEvent } _removeElement(element) { - $(element).removeClass(ClassName.SHOW) + $(element).removeClass(CLASS_NAME_SHOW) - if (!$(element).hasClass(ClassName.FADE)) { + if (!$(element).hasClass(CLASS_NAME_FADE)) { this._destroyElement(element) return } @@ -118,7 +112,7 @@ class Alert { _destroyElement(element) { $(element) .detach() - .trigger(Event.CLOSED) + .trigger(EVENT_CLOSED) .remove() } @@ -158,8 +152,8 @@ class Alert { */ $(document).on( - Event.CLICK_DATA_API, - Selector.DISMISS, + EVENT_CLICK_DATA_API, + SELECTOR_DISMISS, Alert._handleDismiss(new Alert()) ) |