Skip to content

Commit

Permalink
perf(template-compiler): use for loop instead of fromEntries + map
Browse files Browse the repository at this point in the history
  • Loading branch information
cardoso committed Aug 20, 2024
1 parent c11f811 commit c2514fa
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/@lwc/template-compiler/src/codegen/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,11 @@ export default class CodeGen {
}

genEventListeners(listeners: EventListener[]) {
const listenerObj = Object.fromEntries(
listeners.map((listener) => [listener.name, listener])
);
const listenerObj: Record<string, EventListener> = {};
for (const listener of listeners) {
listenerObj[listener.name] = listener;
}

const listenerObjectAST = objectToAST(listenerObj, (key) => {
const componentHandler = this.bindExpression(listenerObj[key].handler);
return this.genBind(componentHandler);
Expand Down

0 comments on commit c2514fa

Please sign in to comment.