strict_filters/strict_variables when creating engine

This commit is contained in:
harttle
2016-11-07 00:01:02 +08:00
parent 1e7873afc0
commit ddd06e12b5
8 changed files with 203 additions and 90 deletions
+3 -10
View File
@@ -4,9 +4,9 @@ const assert = require('./util/assert.js');
const referenceError = /undefined variable|Cannot read property .* of undefined/;
var Scope = {
getAll: function(str) {
getAll: function() {
var ctx = {};
for (i = this.scopes.length - 1; i >= 0; i--) {
for (var i = this.scopes.length - 1; i >= 0; i--) {
_.assign(ctx, this.scopes[i]);
}
return ctx;
@@ -26,13 +26,6 @@ var Scope = {
throw new TypeError('undefined variable: ' + str);
}
},
safeGet: function(str) {
try {
var val = this.safeGet(str);
} catch (e) {;
}
return val;
},
set: function(k, v) {
this.setPropertyByPath(this.scopes[this.scopes.length - 1], k, v);
return this;
@@ -112,7 +105,7 @@ var Scope = {
}
// foo["bar"]
else {
var j = str.indexOf(delemiter, i + 2);
j = str.indexOf(delemiter, i + 2);
assert(j !== -1, `unbalanced ${delemiter}: ${str}`);
name = str.slice(i + 2, j);
seq.push(name);