mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2024-11-21 03:15:49 +08:00
Merge pull request #314 from webzard-io/fix/eval
fix the bug that expression will re-eval everytime after store updating
This commit is contained in:
commit
4d377630ea
@ -44,15 +44,12 @@ export class StateManager {
|
||||
const evalText = expChunk.map(ex => this.evalExp(ex, scopeObject)).join('');
|
||||
let evaled;
|
||||
try {
|
||||
// eslint-disable-next-line no-new-func
|
||||
// eslint-disable-next-line no-useless-call, no-new-func
|
||||
evaled = new Function(
|
||||
'store, dependencies, scopeObject',
|
||||
// trim leading space and newline
|
||||
`with(this) { return ${evalText.replace(/^\s+/g, '')} }`
|
||||
).call({
|
||||
...this.store,
|
||||
...this.dependencies,
|
||||
...scopeObject,
|
||||
});
|
||||
`with(store) { with(dependencies) { with(scopeObject) { return ${evalText.replace(/^\s+/g, '')} } } }`
|
||||
).call(null, this.store, this.dependencies, scopeObject);
|
||||
} catch (e: any) {
|
||||
return `{{ ${evalText} }}`;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user