visibleOn 支持 debugger 功能
This commit is contained in:
parent
e8ee62152a
commit
18050e6e2d
|
@ -30,9 +30,16 @@ export function filter(tpl: string, data: object = {}, ...rest:Array<any>): stri
|
||||||
export function evalExpression(expression: string, data?: object): boolean {
|
export function evalExpression(expression: string, data?: object): boolean {
|
||||||
/* jshint evil:true */
|
/* jshint evil:true */
|
||||||
try {
|
try {
|
||||||
|
let debug = false;
|
||||||
|
const idx = expression.indexOf('debugger');
|
||||||
|
if (~idx) {
|
||||||
|
debug = true;
|
||||||
|
expression = expression.replace(/debugger;?/, '');
|
||||||
|
}
|
||||||
|
|
||||||
const fn = new Function(
|
const fn = new Function(
|
||||||
"data",
|
"data",
|
||||||
`with(data) {return !!(${expression});}`
|
`with(data) {${debug ? 'debugger;' : ''}return !!(${expression});}`
|
||||||
);
|
);
|
||||||
data = data || {};
|
data = data || {};
|
||||||
return fn.call(data, data);
|
return fn.call(data, data);
|
||||||
|
|
Loading…
Reference in New Issue