Skip to content

Commit

Permalink
fix: array listeners not working
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenrui committed Feb 9, 2024
1 parent ba7086e commit fea8996
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,15 @@ export default class Entity {

// Add event listeners
Object.keys(this.listener).forEach((key) => {
const { el, eventName, event } = this.listener[key]
el.addEventListener(eventName, event)
const listener = this.listener[key]
if (Array.isArray(listener)) {
listener.forEach(({ el, eventName, event }) => {
el.addEventListener(eventName, event)
})
} else {
const { el, eventName, event } = listener
el.addEventListener(eventName, event)
}
})
}

Expand Down

0 comments on commit fea8996

Please sign in to comment.