mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2024-11-27 08:39:59 +08:00
improve multiline expression eval
This commit is contained in:
parent
46fa447432
commit
e92ee94203
@ -22,6 +22,19 @@ describe('parseExpression function', () => {
|
||||
[' input1.value '],
|
||||
'!',
|
||||
]);
|
||||
|
||||
const multiline = parseExpression(`{{
|
||||
{ id: 1 }
|
||||
}}`);
|
||||
expect(multiline).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Array [
|
||||
"
|
||||
{ id: 1 }
|
||||
",
|
||||
],
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
||||
it('can parse $listItem expression', () => {
|
||||
|
@ -43,7 +43,10 @@ export class StateManager {
|
||||
const evalText = expChunk.map(ex => this.evalExp(ex, scopeObject)).join('');
|
||||
let evaled;
|
||||
try {
|
||||
evaled = new Function(`with(this) { return ${evalText} }`).call({
|
||||
evaled = new Function(
|
||||
// trim leading space and newline
|
||||
`with(this) { return ${evalText.replace(/^\s+/g, '')} }`
|
||||
).call({
|
||||
...this.store,
|
||||
...this.dependencies,
|
||||
...scopeObject,
|
||||
|
Loading…
Reference in New Issue
Block a user