Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Commit 7096bc6

Browse files
author
Steffan
committedAug 22, 2018
use bind this in expression evaluation
·
1.1.31.0.5
1 parent 126f8a9 commit 7096bc6

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed
 

‎src/fields.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,13 @@
7878
7979
if (isString(expr)) {
8080
81-
const $values = {};
82-
const context = {$match, $values};
81+
const context = {$match, $values: values};
8382
8483
each(config, ({name = key}, key) =>
85-
set($values, name, get(values, name))
84+
set(context, name, get(values, name))
8685
);
8786
88-
return evaluate(expr, assign(context, $values));
87+
return evaluate(this, expr, assign(context, values));
8988
}
9089
9190
return expr.call(this, values, this);

‎src/util.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ export function set(obj, key, val) {
6464
_set(obj, parts.shift(), val);
6565
}
6666

67-
export function evaluate(expr, context) {
67+
export function evaluate(self, expr, context) {
6868

6969
try {
70-
return (Function(`with(this){return ${expr}}`)).call(context);
70+
return (Function('c', `with(c){return ${expr}}`)).call(self, context);
7171
} catch (e) {
7272
warn(e);
7373
}

0 commit comments

Comments
 (0)
This repository has been archived.