Skip to content

Commit

Permalink
Use Object.entries in more places
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Feb 10, 2022
1 parent 5eb4429 commit 9256091
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
10 changes: 4 additions & 6 deletions js/src/dom/event-handler.js
Expand Up @@ -208,9 +208,8 @@ function removeHandler(element, events, typeEvent, handler, delegationSelector)
function removeNamespacedHandlers(element, events, typeEvent, namespace) {
const storeElementEvent = events[typeEvent] || {}

for (const handlerKey of Object.keys(storeElementEvent)) {
for (const [handlerKey, event] of Object.entries(storeElementEvent)) {
if (handlerKey.includes(namespace)) {
const event = storeElementEvent[handlerKey]
removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector)
}
}
Expand Down Expand Up @@ -258,11 +257,10 @@ const EventHandler = {
}

const storeElementEvent = events[typeEvent] || {}
for (const keyHandlers of Object.keys(storeElementEvent)) {
for (const [keyHandlers, event] of Object.entries(storeElementEvent)) {
const handlerKey = keyHandlers.replace(stripUidRegex, '')

if (!inNamespace || originalTypeEvent.includes(handlerKey)) {
const event = storeElementEvent[keyHandlers]
removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector)
}
}
Expand Down Expand Up @@ -295,10 +293,10 @@ const EventHandler = {

// merge custom information in our event
if (typeof args !== 'undefined') {
for (const key of Object.keys(args)) {
for (const [key, value] of Object.entries(args)) {
Object.defineProperty(evt, key, {
get() {
return args[key]
return value
}
})
}
Expand Down
6 changes: 3 additions & 3 deletions js/src/tooltip.js
Expand Up @@ -625,9 +625,9 @@ class Tooltip extends BaseComponent {
_getDelegateConfig() {
const config = {}

for (const key in this._config) {
if (this.constructor.Default[key] !== this._config[key]) {
config[key] = this._config[key]
for (const [key, value] of Object.entries(this._config)) {
if (this.constructor.Default[key] !== value) {
config[key] = value
}
}

Expand Down
3 changes: 1 addition & 2 deletions js/src/util/config.js
Expand Up @@ -46,8 +46,7 @@ class Config {
}

_typeCheckConfig(config, configTypes = this.constructor.DefaultType) {
for (const property of Object.keys(configTypes)) {
const expectedTypes = configTypes[property]
for (const [property, expectedTypes] of Object.entries(configTypes)) {
const value = config[property]
const valueType = isElement(value) ? 'element' : toType(value)

Expand Down

0 comments on commit 9256091

Please sign in to comment.