support short-hand data expressions

This commit is contained in:
Geoff Doty 2025-03-29 12:15:28 -04:00
parent 747f701d0c
commit 6943c50459
1 changed files with 2 additions and 1 deletions

View File

@ -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);