From 6943c50459b6992c2203bf5afdb6a07a9cb932fd Mon Sep 17 00:00:00 2001 From: Geoff Doty Date: Sat, 29 Mar 2025 12:15:28 -0400 Subject: [PATCH] support short-hand data expressions --- src/Mite.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Mite.js b/src/Mite.js index 9501780..18c9b89 100644 --- a/src/Mite.js +++ b/src/Mite.js @@ -107,8 +107,9 @@ export class Mite { try { const handler = new Function( "event", - `with (this.data) { ${exprContent}; }` + `with (this.data) { ${exprContent.replace(/(\w+)/g, (match) => this.data[match] ? `${match}.value` : match)}; }` ).bind(this); + node.addEventListener(eventName, handler); } catch (e) { console.error(`Invalid expression in ${attr.name}: ${exprContent}`, e);