Closed wshager closed 11 years ago
Alas, this doesn't work for the condition by closure in filter...
does this approach work?
return "(function(){return " + op.name + "('" + value.name + "').call(this" +
// ...
No, since the operators are wrapped in an object. You'd just be calling "and", so that doesn't make sense. Also, referencing "exports" won't work, so the only thing I can think of is providing a function representation and replacing whatever I can grasp.
i'm not following why op.name
won't work. as i understand it, the goal is to bridge the gap between minified JS and the strings that get passed to eval
. so let's say that the op
function is minified to function e() { ... }
then the reference to op.name
should also be minified to e.name
which would be "e"
and so the string passed to eval
effectively becomes "(function(){return e('" + value.name + "').call(this"
and should work.
i ran my idea through http://closure-compiler.appspot.com/home and got
function e(a) {
return h[a] || f.i(a);
}
function g(a) {
// ...
return a instanceof Date ? a.valueOf() : "(function(){return " + e.name + "('" + a.name + "').call(this" + (a && a.b && 0 < a.b.length ? ", " + a.b.map(g).join(",") : "") + ")})";
}
return "string" === typeof a ? q(a) : a;
}
am i missing something?
You're right. I tested this before, but probably with an anonymous function. I'll open a new pull request.
possible fix for minifying with closure compiler