Skip to content

Commit

Permalink
fix: prevent duplicate entity init for :each attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenrui committed Feb 9, 2024
1 parent f9746f2 commit 7f263a3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ export default class Entity {
.replaceAll(variable, `'${escapeHTML(item)}'`)
})

// ObserveDOM will be called for updated DOM to initialize the entities
this.element.innerHTML = newHTML
this.initChildren()
}
}

Expand Down Expand Up @@ -422,6 +422,7 @@ export default class Entity {
// Add event listeners
Object.keys(this.listener).forEach((key) => {
const listener = this.listener[key]

if (Array.isArray(listener)) {
listener.forEach(({ el, eventName, event }) => {
el.addEventListener(eventName, event)
Expand Down

0 comments on commit 7f263a3

Please sign in to comment.