support short-hand data expressions
This commit is contained in:
parent
747f701d0c
commit
6943c50459
|
@ -107,8 +107,9 @@ export class Mite {
|
||||||
try {
|
try {
|
||||||
const handler = new Function(
|
const handler = new Function(
|
||||||
"event",
|
"event",
|
||||||
`with (this.data) { ${exprContent}; }`
|
`with (this.data) { ${exprContent.replace(/(\w+)/g, (match) => this.data[match] ? `${match}.value` : match)}; }`
|
||||||
).bind(this);
|
).bind(this);
|
||||||
|
|
||||||
node.addEventListener(eventName, handler);
|
node.addEventListener(eventName, handler);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`Invalid expression in ${attr.name}: ${exprContent}`, e);
|
console.error(`Invalid expression in ${attr.name}: ${exprContent}`, e);
|
||||||
|
|
Loading…
Reference in New Issue