[IMP] blockdom: t-on supports synthetic and native event handler

Synthetic handler is a sort of event delegation that allows placing
only one listener on the document to improve performance. It is an opt-in option.

Native listener places the listener on the node itself.
This commit is contained in:
Lucas Perais (lpe)
2021-10-26 11:01:57 +02:00
committed by Aaron Bohy
parent 3eb63452e7
commit 2ae0149adb
9 changed files with 244 additions and 18 deletions
+3
View File
@@ -1,7 +1,10 @@
import { filterOutModifiersFromData } from "../blockdom/config";
export function mainEventHandler(data: any, ev: Event) {
if (typeof data === "function") {
data(ev);
} else {
data = filterOutModifiersFromData(data).data;
const ctx = data[0];
const method = data[1];
const args = data[2] || [];