suppress simple path getter errors

This commit is contained in:
Evan You 2015-05-08 14:05:40 -04:00
parent 46812bd210
commit f7e571c468
2 changed files with 3 additions and 4 deletions

View File

@ -16,9 +16,7 @@ var filterRE = /[^|]\|[^|]/
exports.$get = function (exp) {
var res = expParser.parse(exp)
if (res) {
try {
return res.get.call(this, this)
} catch (e) {}
}
}

View File

@ -219,6 +219,7 @@ function formatAccessor(key) {
/**
* Compiles a getter function with a fixed path.
* The fixed path getter supresses errors.
*
* @param {Array} path
* @return {Function}
@ -226,7 +227,7 @@ function formatAccessor(key) {
exports.compileGetter = function (path) {
var body = 'return o' + path.map(formatAccessor).join('')
return new Function('o', body)
return new Function('o', 'try {' + body + '} catch (e) {}')
}
/**