diff options
| author | XhmikosR <[email protected]> | 2021-10-13 15:19:28 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-10-13 15:19:28 +0300 |
| commit | e8f702666f285a3e69866ed1f8d29fa6eaaaeabb (patch) | |
| tree | 944b2dc894f49f8278d41d096e4388e9ac83157b /js/src/dom | |
| parent | db44392bda22f3d5319d2880c992f76d27d2a60c (diff) | |
| download | bootstrap-e8f702666f285a3e69866ed1f8d29fa6eaaaeabb.tar.xz bootstrap-e8f702666f285a3e69866ed1f8d29fa6eaaaeabb.zip | |
JS: minor refactoring (#35183)
* add missing comments
* shorten block comments
* reorder constants
* reorder public/private methods
* sort exports alphabetically in util/index.js
* fix a couple of typos
Diffstat (limited to 'js/src/dom')
| -rw-r--r-- | js/src/dom/data.js | 2 | ||||
| -rw-r--r-- | js/src/dom/event-handler.js | 12 | ||||
| -rw-r--r-- | js/src/dom/selector-engine.js | 10 |
3 files changed, 4 insertions, 20 deletions
diff --git a/js/src/dom/data.js b/js/src/dom/data.js index c702fc82c..4209f3188 100644 --- a/js/src/dom/data.js +++ b/js/src/dom/data.js @@ -6,9 +6,7 @@ */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const elementMap = new Map() diff --git a/js/src/dom/event-handler.js b/js/src/dom/event-handler.js index bf01694f4..b9ebce324 100644 --- a/js/src/dom/event-handler.js +++ b/js/src/dom/event-handler.js @@ -8,9 +8,7 @@ import { getjQuery } from '../util/index' /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const namespaceRegex = /[^.]*(?=\..*)\.|.*/ @@ -73,9 +71,7 @@ const nativeEvents = new Set([ ]) /** - * ------------------------------------------------------------------------ * Private methods - * ------------------------------------------------------------------------ */ function getUidEvent(element, uid) { @@ -143,7 +139,6 @@ function findHandler(events, handler, delegationSelector = null) { function normalizeParams(originalTypeEvent, handler, delegationFn) { const delegation = typeof handler === 'string' const originalHandler = delegation ? delegationFn : handler - let typeEvent = getTypeEvent(originalTypeEvent) const isNative = nativeEvents.has(typeEvent) @@ -224,7 +219,6 @@ function removeNamespacedHandlers(element, events, typeEvent, namespace) { for (const handlerKey of Object.keys(storeElementEvent)) { if (handlerKey.includes(namespace)) { const event = storeElementEvent[handlerKey] - removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector) } } @@ -277,7 +271,6 @@ const EventHandler = { if (!inNamespace || originalTypeEvent.includes(handlerKey)) { const event = storeElementEvent[keyHandlers] - removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector) } } @@ -312,10 +305,7 @@ const EventHandler = { evt = document.createEvent('HTMLEvents') evt.initEvent(typeEvent, bubbles, true) } else { - evt = new CustomEvent(event, { - bubbles, - cancelable: true - }) + evt = new CustomEvent(event, { bubbles, cancelable: true }) } // merge custom information in our event diff --git a/js/src/dom/selector-engine.js b/js/src/dom/selector-engine.js index 54f270f4c..af27dc379 100644 --- a/js/src/dom/selector-engine.js +++ b/js/src/dom/selector-engine.js @@ -5,14 +5,12 @@ * -------------------------------------------------------------------------- */ +import { isDisabled, isVisible } from '../util/index' + /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ -import { isDisabled, isVisible } from '../util/index' - const NODE_TEXT = 3 const SelectorEngine = { @@ -25,13 +23,11 @@ const SelectorEngine = { }, children(element, selector) { - return [].concat(...element.children) - .filter(child => child.matches(selector)) + return [].concat(...element.children).filter(child => child.matches(selector)) }, parents(element, selector) { const parents = [] - let ancestor = element.parentNode while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) { |
