|
|
@@ -21,6 +21,7 @@ var restoreRE = /"(\d+)"/g
|
|
|
var pathTestRE = /^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*|\['.*?'\]|\[".*?"\]|\[\d+\])*$/
|
|
|
var pathReplaceRE = /[^\w$\.]([A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*|\['.*?'\]|\[".*?"\])*)/g
|
|
|
var keywordsRE = new RegExp('^(' + keywords.replace(/,/g, '\\b|') + '\\b)')
|
|
|
+var booleanLiteralRE = /^(true|false)$/
|
|
|
|
|
|
/**
|
|
|
* Save / Rewrite / Restore
|
|
|
@@ -225,10 +226,14 @@ exports.parse = function (exp, needSet) {
|
|
|
// we do a simple path check to optimize for them.
|
|
|
// the check fails valid paths with unusal whitespaces,
|
|
|
// but that's too rare and we don't care.
|
|
|
- // also skip paths that start with global "Math"
|
|
|
- var res = pathTestRE.test(exp) && exp.slice(0, 5) !== 'Math.'
|
|
|
- ? compilePathFns(exp)
|
|
|
- : compileExpFns(exp, needSet)
|
|
|
+ // also skip boolean literals and paths that start with
|
|
|
+ // global "Math"
|
|
|
+ var res =
|
|
|
+ pathTestRE.test(exp) &&
|
|
|
+ !booleanLiteralRE.test(exp) &&
|
|
|
+ exp.slice(0, 5) !== 'Math.'
|
|
|
+ ? compilePathFns(exp)
|
|
|
+ : compileExpFns(exp, needSet)
|
|
|
expressionCache.put(exp, res)
|
|
|
return res
|
|
|
}
|