support short-hand data expressions
This commit is contained in:
parent
747f701d0c
commit
6943c50459
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue