style: using 'Array.prototype.forEach()' (#1826)

This commit is contained in:
xiejiahe 2021-04-13 17:52:51 +08:00 committed by GitHub
parent f84befc00b
commit 62cffd67a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 5 deletions

View File

@ -12,11 +12,11 @@ export default (el: Ref<HTMLElement>, events: Event[]) => {
watch(el, val => {
if (val) {
events.map(({ name, handler }) => {
events.forEach(({ name, handler }) => {
on(el.value, name, handler)
})
} else {
events.map(({ name, handler }) => {
events.forEach(({ name, handler }) => {
off(el.value, name, handler)
})
}

View File

@ -14,7 +14,7 @@ const attachEvents = (el: HTMLElement, binding: DirectiveBinding, vnode: VNode)
popover.triggerRef = el
el.setAttribute('tabindex', popover.tabindex)
// because v-popover cannot modify the vnode itself due to it has already been
Object.entries(popover.events).map(([eventName, e]) => {
Object.entries(popover.events).forEach(([eventName, e]) => {
on(el, eventName.toLowerCase().slice(2), e)
})
}

View File

@ -248,7 +248,7 @@ export default function(
}
if (isArray(props.trigger)) {
Object.values(props.trigger).map(mapEvents)
Object.values(props.trigger).forEach(mapEvents)
} else {
mapEvents(props.trigger as TriggerType)
}

View File

@ -56,7 +56,7 @@ export default defineComponent({
let mapValues = Array.from(map.values()).reverse()
let mapKeys = Array.from(map.keys()).reverse()
resizeObserver = new ResizeObserver(() => {
Array.from(h3).map(item => {
Array.from(h3).forEach(item => {
const text = item.childNodes[1].textContent.trim()
map.set(text, item.offsetTop)
})